Docker containers for Viblo development.
- Docker version at least 18.06
- Docker compose version at least 1.22.0
Make a .env file
cp .env.example .env
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
andDB_TEST_PORT
: Ports published by database so you can connect with your DB management tool. Default values depend on which database you choose (5432
&5433
for Postgres,3306
&3307
for MySQL)DOMAIN_BACKEND
: Backend domain to access some backend services (traefik, mailhog .etc). Default:backend.localhost
Note: All directory paths can be relative to where you run ./project
.
Make a modules file
cp modules.example modules
Specify which module to include. Example:
postgres
redis
php
frameworks/laravel
web
Available modules 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 web
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.