53 lines
1.1 KiB
YAML
53 lines
1.1 KiB
YAML
services:
|
|
api:
|
|
build:
|
|
context: ./serv_golang_rest_api
|
|
dockerfile: Dockerfile
|
|
ports:
|
|
- "8888:8080"
|
|
container_name: serv_golang_rest_api
|
|
restart: unless-stopped
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
environment:
|
|
# Database connection settings
|
|
DB_HOST: db
|
|
DB_PORT: 5432
|
|
DB_USER: postgres
|
|
DB_PASSWORD: postgres
|
|
DB_NAME: mydb
|
|
APP_PORT: 8080
|
|
networks:
|
|
- app-network
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
db:
|
|
image: postgres:15-alpine
|
|
ports:
|
|
- "5432:5432"
|
|
environment:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: mydb
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./migrations:/docker-entrypoint-initdb.d
|
|
networks:
|
|
- app-network
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
volumes:
|
|
postgres_data:
|
|
|
|
networks:
|
|
app-network:
|
|
driver: bridge |