Handy boilerplate to get up and running with the following:
- PHP-FPM v7.4.1
- Symfony v5.x
- Nginx
- Docker
- jQuery
- Monolog
$ git clone git@github.com:mferly/xx-array.gitYou'll need to edit a few files before you get up and running. They're are:
./docker/nginx/conf/app.confroot /path/to/your/project;server_name localhost; # assuming you need to- Setup up SSL if you desire.
./docker/nginx/Dockerfile- Ensure paths are correct
- Setup SSL if desired
./.env- Change APP_NAME to whatever you want
- It's used in:
docker-compose.ymldocker-compose-develop.yml
- It's used in:
- Change APP_NAME to whatever you want
./docker-compose.yml- Not much, if anything, that needs changing in here
./docker-compose-develop.yml- Changes needed if you want SSL
./Dockerfile- Add/remove PHP packages as needed
- Also check that the following are correct for your env:
COPY . /var/www/appRUN sh /var/www/app/bin/build.sh
Once all of that is sorted out move on down to the 'Run' section (but first check out 'Certs/SSL' if you want SSL).
NOTE: If you don't want to run over HTTPS then you can skip the following set of instructions. However, I'd strongly encourage you to run over HTTPS at all times, especially since it's such an easy setup. Either way, it's setup for both port 80 and 443.
To create a local self-signed cert I recommend looking into mkcert. Super simple setup. Eg..
$ git clone git@github.com:FiloSottile/mkcert.git
$ cd mkcert
$ mkcert -installThen you can create a cert for an array of hosts or simply specify a single one..
$ mkcert example.local "*.example.local" localhost 127.0.0.1 ::1
// or simply
$ mkcert example.localDon't forget to edit your /etc/hosts file if you're using a host other than localhost..
$ sudo vi /etc/hosts
>> /etc/hosts
// add a line similar to the following..
127.0.0.1 example.localNow we..
- Copy those new
.pemfiles to./docker/nginx/certs - Update the following to reflect your new certs (if applicable)
./docker-compose-develop.yml./Dockerfile-nginx./docker/nginx/conf/self-signed.conf
Alternatively, when you're ready to go prime time, you can look into Let's Encrypt as a free solution to your SSL needs. Local, self-signed certs (as we have here) won't suffice in production, but they're easy to setup to get the ball rolling.
/**
* Replace PROJECT_NAME with your project name
* eg. my_app
* The following will build and tag your docker images
* per PROJECT_NAME
*/
$ sh ./docker-build.sh PROJECT_NAMEDevelop is mounted to local app directory for ease of development via volumes.
Update APP_ENV to dev, eg. APP_ENV=dev
// let's use the composer.lock file
$ composer updateInstall Yarn and then run it to install the packages in package.json.
/**
* Make sure you have yarn installed
* Yarn will use the provided yarn.lock file
*/
$ yarn/**
* This command will watch changes made to your
* .css and .js files
*/
$ yarn run encore dev --watch$ docker-compose -f docker-compose-develop.yml upFor production we don't mount local volumes (obviously).
Update APP_ENV to prod, eg. APP_ENV=prod
$ docker-compose up -d$ docker stack deploy --compose-file docker-compose.yml appWe're using Monolog (more specifically the symfony/monolog-bundle).
More resources here:
- https://github.com/symfony/monolog-bundle
- https://symfony.com/doc/current/logging.html
- https://github.com/Seldaek/monolog
- Docker alpine images
- Tests