A template for a common Docker Symfony stack, allowing multiple projects (xxx.local => www/xxx/public/index.php
) and provides all common php extensions.
Provides a local development environment for the TEMPLATE and its required projects.
Based on: https://github.com/maxpou/docker-symfony
Each project provides its own Docker container
- PHP X.X
- XDebug (activate via "WITH_XDEBUG=true" inside dotenv)
- MariaDB X.X
- nodejs / gulp / yarn / webpack
- Mailcatcher for local mailing
- local SSH Key injecting
.data
For general storage eg: databasewww/<project-name>
Webserver root for projects (you can just add more by adding container in same Symfony structure)install.sh
andupdate.sh
for all projects inside container to build and update maintenance
You can access container application directly via localhost
- Webserver: 80 (http only)
- MySql / MariaDB: 3306 (User: "root"; Password: "admin")
- Mailcatcher: 1080 (http://127.0.0.1:1080)
For Mac users it's important to not use the Docker provided by the Homebrew package installer. If you do so, you will probably run into problems with "WARNING: Connection pool is full, discarding connection" warnings. Using the "original" Docker install package from docker.com will solve problems like that.
-
Create a
.env
from the.env.dist
file. Adapt it according to your symfony applicationcp .env.dist .env
- For Windows you must also provide a PWD variable with the project dir in
.env
see documentation inside file, if you are not taking the nfs mount stuff opt of "Optimizations" section
- For Windows you must also provide a PWD variable with the project dir in
-
Update your system host file
127.0.0.1 TEMPLATE.local
-
Inject SSH storage
If you need access to ssh key related stuff have valid ssh key inside local folder:
~/.ssh/id_rsa
Docker secret features is taken: https://docs.docker.com/compose/compose-file/#secrets
-
Build/run containers
docker-compose build # Run visible; eh good for first run to see output docker-compose up # Run in background # docker-compose up -d
-
Prepare Projects
-
Install projects via build container
docker-compose run --rm php-cli bash -c "/var/install.sh" # or via make make install
-
Create the databases
Boot up the stack if not already done
docker-compose up -d
Create database
docker-compose exec db bash -c "mysql -u root -padmin -e 'create database TEMPLATE'"
-
Check project
The
www
contains all projects and nginx just you any subfolder you provide as subdomainTEMPLATE
=>TEMPLATE.local
.
-
-
Enjoy
Open browser with: http://TEMPLATE.local
make
is used for several regular scripts task.
Update includes
- checkout develop branch
- composer install
- build frontend
make update
For speeding up the file access for non Linux user you can use for example an NFS server mount via provided scripts.
Depending on your OS change NFS_MOUNT_WWW
the variable inside .env
for the project www
folder
NFS_MOUNT_WWW
must be absolute and inside the Users folder structure. Execute the bash file to configure the nfs server
```bash
./nfs_macos.sh
```
-
Set
NFS_MOUNT_WWW
to /www -
https://github.com/winnfsd/winnfsd/releases download latest version and put this into the folder
winnfsd
. -
Force the
winnfsd.exe
to execute as admin user via the Windows Configuration tab. (right click the file and go to Security) -
Run the follong script inside a cmd window
nfs_windows.bat
Run docker-compose up using the nfs configuration file
```bash
docker-compose -f docker-compose.yml -f docker-compose.nfs.yml up -d
```
To make this persisted you can also just copy docker-compose.nfs.yml
to docker-compose.override.yml
Permission problem? (docker: Got permission denied while trying to connect to the Docker daemon socket at)
sudo groupadd docker
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
# restart / relogin
else:
How to config Xdebug?
Xdebug is configured out of the box!
Just config your IDE to connect port 9001
and id key PHPSTORM
See also some main project: https://github.com/maxpou/docker-symfony