Files
2026-06-08 22:55:30 +04:00

85 lines
2.1 KiB
YAML

# Stack: Postgres + Rails API + Vite frontend.
# First run: `make prepare` (build, start, DB schema, frontend deps).
services:
database:
image: postgres:15
container_name: database
networks:
- app-network
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: app_development
ports:
- "5432:5432"
volumes:
- database_data:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d app_development"]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
backend:
container_name: backend
depends_on:
database:
condition: service_healthy
networks:
- app-network
build:
context: ./api
dockerfile: Dockerfile
working_dir: /api
volumes:
- ./api:/api:cached
environment:
RAILS_ENV: development
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
DATABASE_HOSTNAME: database
DATABASE_PORT: "5432"
ports:
- "3000:3000"
restart: unless-stopped
# Dev: Puma directly so docker-entrypoint can run db:prepare before "server" (see bin/docker-entrypoint).
command: ["./bin/rails", "server", "-b", "0.0.0.0", "-p", "3000"]
healthcheck:
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:3000/up >/dev/null"]
interval: 10s
timeout: 5s
retries: 6
start_period: 90s
frontend:
container_name: frontend
depends_on:
backend:
condition: service_healthy
networks:
- app-network
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "5173:5173"
volumes:
- ./frontend:/app
- frontend_node_modules:/app/node_modules
environment:
NODE_ENV: development
restart: unless-stopped
# Named volume for node_modules (empty on first run) — npm install on each start.
command: ["/bin/sh", "-c", "npm install --no-audit --no-fund && exec npm run dev"]
networks:
app-network:
driver: bridge
volumes:
database_data:
frontend_node_modules: