eletrotupi / tcc/ ansible/roles/app/files/docker-compose.production.ymlfb32fbf5090f5a80cadcf65e58ac16ae9a97c29b
2.5 KB | 86 lines Raw
1
# /srv/app/production/docker-compose.yml
2
# Secrets: cp .env.production.example .env.production and fill in values
3
# Start:   docker compose up -d
4
# Logs UI: https://<host>/logs/ (nginx proxies it; loopback only otherwise)
5

6
services:
7
  db:
8
    image: postgres:17-alpine
9
    shm_size: 1g
10
    user: postgres
11
    restart: unless-stopped
12
    healthcheck:
13
      test: "pg_isready -U ${POSTGRES_USER} --dbname=${POSTGRES_DB}"
14
      interval: 10s
15
      timeout: 5s
16
      retries: 5
17
    # No ports exposed: only reachable inside the Docker network
18
    environment:
19
      POSTGRES_USER: ${POSTGRES_USER}
20
      POSTGRES_DB: ${POSTGRES_DB}
21
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
22
    volumes:
23
      - db_data:/var/lib/postgresql/data
24
    logging: &default-logging
25
      driver: json-file
26
      options:
27
        max-size: "${LOG_MAX_SIZE:-10m}"
28
        max-file: "${LOG_MAX_FILE:-3}"
29

30
  valkey:
31
    image: valkey/valkey:9.0-alpine
32
    restart: unless-stopped
33
    # No ports exposed
34
    volumes:
35
      - valkey_data:/data
36
      - ./valkey.conf:/etc/valkey/valkey.conf
37
    command: valkey-server /etc/valkey/valkey.conf
38
    logging: *default-logging
39

40
  api:
41
    image: ghcr.io/${GITHUB_REPOSITORY}:${IMAGE_TAG:-latest}
42
    restart: unless-stopped
43
    ports:
44
      # Only bind on localhost: Nginx proxies to this
45
      - "127.0.0.1:3000:3000"
46
    env_file:
47
      - .env.production
48
    depends_on:
49
      valkey:
50
        condition: service_started
51
      db:
52
        condition: service_healthy
53
    logging: *default-logging
54

55
  # Logs store — UI at http://127.0.0.1:9428/logs/select/vmui/ (loopback only)
56
  victorialogs:
57
    image: victoriametrics/victoria-logs:${VICTORIALOGS_TAG:-v1.53.0}
58
    command:
59
      - "-storageDataPath=/vlogs"
60
      - "-http.pathPrefix=/logs"
61
      - "-retentionPeriod=${VICTORIALOGS_RETENTION:-14d}"
62
      - "-retention.maxDiskSpaceUsageBytes=${VICTORIALOGS_MAX_DISK:-2GiB}"
63
    volumes:
64
      - vlogs_data:/vlogs
65
    ports:
66
      - "127.0.0.1:${VICTORIALOGS_PORT:-9428}:9428"
67
    restart: unless-stopped
68
    logging: *default-logging
69

70
  # Reads container logs through the Docker API and ships them to VictoriaLogs
71
  # `docker compose logs` keeps working: this does not replace the log driver
72
  vector:
73
    image: timberio/vector:${VECTOR_TAG:-0.59.X-distroless-libc}
74
    user: root
75
    volumes:
76
      - /var/run/docker.sock:/var/run/docker.sock:ro
77
      - ./vector.yaml:/etc/vector/vector.yaml:ro
78
    depends_on:
79
      - victorialogs
80
    restart: unless-stopped
81
    logging: *default-logging
82

83
volumes:
84
  db_data:
85
  valkey_data:
86
  vlogs_data: