Docker compose for symfony + mysql + angular project
- Clone this repository
$ git clone https://github.com/zhooravell/symfony-angular-docker-compose.git
- Create
.env
file
$ cd symfony-angular-docker-compose && cp env.dist .env
- Set value to environment variables in
.env
SYMFONY_APP=/absolute/path/to/symfony/app
ANGULAR_APP=/absolute/path/to/angular/app
- Fixing file permissions in Symfony App (Official documentation)
// For Linux
$ HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1)
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX var
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX var
- Prepare docker
$ docker-compose pull
$ docker-compose build --force-rm
$ docker volume create --name=mysql-data
- Check docker config
$ docker-compose config
- Add
symfony-app.dev
to/etc/hosts
127.0.0.1 symfony-app.dev
Run development environment
$ docker-compose up
or run in background
$ docker-compose up -d
To down environment
$ docker-compose down
Show all container
$ docker-compose ps
Connect to container
$ docker exec -it {container_name} bash
Fix minor problem with docker images
$ docker-compose up --force-recreate
For correct work with angular app you must fix package.json
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
....
Symfony: http://symfony-app.dev
Angular: http://localhost:4200
Phpmyadmin: http://localhost:3000