Docker containers for Viblo development.
- Docker version at least 18.06
- Docker compose version at least 1.22.0
# clone repo:
git clone git@github.com:sun-asterisk-research/docker-php-development.git docker
# init project:
./project init
There are 2 files that will be created: .env
& services
. They are copying files of .env.example
and services.example
. Therefore, please make them manually if the command init
does not work.
Notable things are:
PATH_PHP
,PATH_WEB
: paths to your code directories. They will be mounted into the containers.DOMAIN
andPORT
: Domain and port to access the application.COMPOSE_PROJECT_NAME
: used to isolate environments when you run multiple projects.
Not very important things:
PATH_DATA
: Path to the directory you want to persist data to (Database, uploads .etc)PATH_LOGS
: Where to persist logs of some services.DB_PORT
: Port published by database so you can connect with your DB management tool. Default value depends on which database you choose (5432
for Postgres,3306
for MySQL)DOMAIN_SECONDARY
: Secondary domain to access some backend services (traefik, mailhog .etc). Default:localhost
Note: All directory paths can be relative to where you run ./project
.
Open services file. Specify which service to include. Example:
mysql
redis
php
Available services are in compose folder. For development, most likely you will only need the above ones.
./project up
./project down
To get inside a container you can use
./project sh <service>
e.g
./project sh php
If you are not inside this folder, you can use docker exec
to enter containers. Most containers uses alpine
image so you can get into them with sh
docker exec -it <container_name> sh
You can run commands like this
./project exec <service> <command>
Example
./project exec web yarn dev
Container names are prefixed with the COMPOSE_PROJECT_NAME
environment variable (default: php-project
). You can list them all with
./project ps
or use docker ps
. e.g.
docker ps -f name=php-project_
You can override services or add new services by adding them to a docker-compose.override.yml
file.