File size: 4,691 Bytes
fee2f22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eac73a9
 
fee2f22
 
 
 
 
 
eac73a9
 
 
 
fee2f22
 
 
 
 
eac73a9
 
fee2f22
 
 
 
eac73a9
 
 
 
 
 
 
fee2f22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eac73a9
 
fee2f22
 
eac73a9
 
fee2f22
 
 
 
 
 
eac73a9
fee2f22
 
 
 
 
 
 
 
 
 
eac73a9
fee2f22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eac73a9
 
fee2f22
 
eac73a9
 
fee2f22
 
 
eac73a9
 
fee2f22
 
 
eac73a9
 
 
 
 
 
fee2f22
 
 
 
 
 
 
 
 
 
 
 
eac73a9
 
 
 
 
fee2f22
 
 
eac73a9
 
 
fee2f22
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
version: "3.9"

services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-data_cleaning}
      POSTGRES_USER: ${POSTGRES_USER:-admin}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
      PGOPTIONS: "-c log_min_messages=WARNING -c shared_buffers=256MB"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: unless-stopped
    networks:
      - database_tier
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s
    deploy:
      resources:
        limits:
          memory: 2GB
        reservations:
          memory: 512MB
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  redis:
    image: redis:7-alpine
    command: redis-server --maxmemory 512mb --maxmemory-policy allkeys-lru
    restart: unless-stopped
    networks:
      - backend_tier
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 3
    deploy:
      resources:
        limits:
          memory: 512MB
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  backend:
    image: ghcr.io/${REGISTRY_OWNER}/data-cleaning-openenv-backend:latest
    pull_policy: always
    environment:
      DATABASE_URL: ${DATABASE_URL:-postgresql://admin:password@postgres:5432/data_cleaning}
      REDIS_URL: ${REDIS_URL:-redis://redis:6379/0}
      JWT_SECRET: ${JWT_SECRET:-change-me-in-production}
      ENVIRONMENT: ${ENVIRONMENT:-production}
      LOG_LEVEL: ${LOG_LEVEL:-INFO}
      PYTHONUNBUFFERED: 1
      POSTGRES_USER: ${POSTGRES_USER:-admin}
      POSTGRES_DB: ${POSTGRES_DB:-data_cleaning}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    volumes:
      - uploads_data:/app/data/uploads
    restart: unless-stopped
    networks:
      - backend_tier
      - frontend_tier
      - database_tier
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:8000/api/health || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 30s
    read_only: true
    tmpfs:
      - /tmp
    deploy:
      resources:
        limits:
          memory: 1GB
          cpus: "1"
        reservations:
          memory: 256MB
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    security_opt:
      - no-new-privileges:true

  celery:
    image: ghcr.io/${REGISTRY_OWNER}/data-cleaning-openenv-backend:latest
    pull_policy: always
    command: celery -A backend.tasks worker --loglevel=info --concurrency=2
    environment:
      DATABASE_URL: ${DATABASE_URL:-postgresql://admin:password@postgres:5432/data_cleaning}
      REDIS_URL: ${REDIS_URL:-redis://redis:6379/0}
      ENVIRONMENT: ${ENVIRONMENT:-production}
      LOG_LEVEL: ${LOG_LEVEL:-INFO}
      PYTHONUNBUFFERED: 1
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
      backend:
        condition: service_started
    restart: unless-stopped
    networks:
      - backend_tier
      - database_tier
    read_only: true
    tmpfs:
      - /tmp
    deploy:
      resources:
        limits:
          memory: 512MB
          cpus: "0.5"
        reservations:
          memory: 128MB
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    security_opt:
      - no-new-privileges:true

  frontend:
    image: ghcr.io/${REGISTRY_OWNER}/data-cleaning-openenv-frontend:latest
    pull_policy: always
    environment:
      VITE_API_BASE_URL: ${VITE_API_BASE_URL:-/api}
    depends_on:
      backend:
        condition: service_started
    restart: unless-stopped
    networks:
      - frontend_tier
    healthcheck:
      test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:3000 || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 20s
    deploy:
      resources:
        limits:
          memory: 512MB
          cpus: "0.5"
        reservations:
          memory: 128MB
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
    read_only: true
    tmpfs:
      - /tmp
    security_opt:
      - no-new-privileges:true

volumes:
  postgres_data:
    driver: local
  uploads_data:
    driver: local

networks:
  frontend_tier:
    internal: false
  backend_tier:
    internal: true
  database_tier:
    internal: true