version: "3.9"
networks:
local:
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
volumes:
- ./backend:/app # TODO: убрать в продакшене
networks:
- local
environment:
- DATABASE_HOST=mysql
- DATABASE_USER=root
- DATABASE_PASSWORD=rootpassword
- DATABASE_NAME=tasker
depends_on:
mysql:
condition: service_healthy
mysql:
image: mysql:8.0
container_name: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: tasker
MYSQL_USER: tasker_user
MYSQL_PASSWORD: tasker_password
# Если нужен доступ извне, то нужно раскомментировать
# ports:
# - "3306:3306"
volumes:
- ./mysql_data:/var/lib/mysql
networks:
- local
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h localhost -uroot -prootpassword --silent || exit 1"]
interval: 5s
timeout: 3s
retries: 5
start_period: 10s
phpmyadmin:
image: phpmyadmin:latest
container_name: phpmyadmin
restart: always
environment:
PMA_HOST: mysql
PMA_USER: root
PMA_PASSWORD: rootpassword
ports:
- "8080:80"
networks:
- local
depends_on:
- mysql
nginx:
image: nginx:latest
container_name: nginx
ports:
- "80:80"
volumes:
- ./frontend:/usr/share/nginx/html:ro # Статические файлы фронтенда
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
networks:
- local
depends_on:
- backend