Answer the question
In order to leave comments, you need to log in
Symfony 4 how to properly deploy to production?
Hello guys.
The Symfony documentation says that the /public/build folder must be kept in .gitignore
https://symfony.com/doc/current/frontend/encore/fa...
Then when pushing to the production server, this folder will not be there.
And doing build assets on the server is also not right.
So what is the correct solution?
Thanks to.
Answer the question
In order to leave comments, you need to log in
Building the frontend is best done locally. For example, I usually use Ansible for such things.
Here's an example of what it might look like in a shell script (you can just copy and execute commands on the command line step by step and see what happens):
#!/bin/sh
# Создание временной директории
cd "$(mktemp --directory)";
# Клонирование репозитория во временную директорию
git clone https://github.com/symfony/demo .;
# Извлечение ветки для релиза
git checkout master;
# Установка зависимостей фронтенда
npm install
# Сборка фронтенда
node_modules/.bin/encore production
# Загрузка кода из временной директории на сервер при помощи rsync
# Остальные действия производятся уже на сервере
Build locally, archive, unzip on the server.
Use deployment automation tools for this.
My favorite: https://ansistrano.com/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question