Copy .env.example to .env and set real values for the database user, password, JWT secret, and
token expiry.
For Docker Compose:
- the app service automatically uses
dbasDB_HOST - the MySQL container still listens on
3306internally DB_PORTonly controls the host machine port, so using3307avoids conflicts if local MySQL is already using3306
docker compose up --build -dThis starts:
api: the Express applicationdb: a MySQL 8.4 database with a persistent named volume
The API will be available on http://localhost:8080 when PORT=8080 in .env.
docker compose exec api yarn db:migratedocker compose exec api yarn db:seeddocker compose downTo stop and also remove the database volume:
docker compose down -vIf the MySQL container fails to start with an error like bind: address already in use, change
DB_PORT in .env to a free host port such as 3307, then restart the stack.
You can also use the executable run.sh helper to run common Docker tasks:
./run.sh up
./run.sh down
./run.sh restart
./run.sh logs
./run.sh migrate
./run.sh seed
./run.sh statusIf run.sh is not executable on your machine, run the same commands with bash instead:
bash run.sh upTo make it executable:
chmod +x run.shCommand summary:
./run.sh up: build and start the containers in detached mode./run.sh down: stop the containers./run.sh restart: rebuild and restart the containers./run.sh logs: follow container logs./run.sh migrate: run database migrations in theapicontainer./run.sh seed: run database seeders in theapicontainer./run.sh status: show running container status
Typical Docker flow:
./run.sh up
./run.sh migrate
./run.sh seed
./run.sh logs