File size: 4,070 Bytes
90c6b42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
version: '3.8'

services:
  # Local PostgreSQL for development
  postgres-local:
    image: postgres:15-alpine
    container_name: atom-postgres-local
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-atom_local}
      POSTGRES_USER: ${POSTGRES_USER:-atom_user}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-local_password}
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
    volumes:
      - postgres_local_data:/var/lib/postgresql/data
+      - ./init-test-db.sql:/docker-entrypoint-initdb.d/init.sql:ro
+    profiles:
+      - local
+    networks:
+      - atom-local-net
+    healthcheck:
+      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-atom_user} -d ${POSTGRES_DB:-atom_local}"]
+      interval: 5s
+      timeout: 5s
+      retries: 5
+    labels:
+      - "atom.environment=local"
+      - "atom.service=database"

+  # Local Redis for caching
+  redis-local:
+    image: redis:7-alpine
+    container_name: atom-redis-local
+    ports:
+      - "${REDIS_PORT:-6379}:6379"
+    volumes:
+      - redis_local_data:/data
+    profiles:
+      - local
+    networks:
+      - atom-local-net
+    healthcheck:
+      test: ["CMD", "redis-cli", "ping"]
+      interval: 10s
+      timeout: 5s
+      retries: 3
+    labels:
+      - "atom.environment=local"
+      - "atom.service=cache"

+  # Development server with hot reload
+  app-dev:
+    build:
+      context: .
+      dockerfile: Dockerfile.dev
+    container_name: atom-app-dev
+    ports:
+      - "${PORT:-3000}:3000"
+    environment:
+      NODE_ENV: development
+      POSTGRES_HOST: postgres-local
+      POSTGRES_PORT: 5432
+      POSTGRES_DB: ${POSTGRES_DB:-atom_local}
+      POSTGRES_USER: ${POSTGRES_USER:-atom_user}
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-local_password}
+      DATABASE_URL: postgresql://${POSTGRES_USER:-atom_user}:${POSTGRES_PASSWORD:-local_password}@postgres-local:5432/${POSTGRES_DB:-atom_local}
+      REDIS_URL: redis://redis-local:6379
+    volumes:
+      - .:/app
+      - /app/node_modules
+      - /app/.next
+    depends_on:
+      postgres-local:
+        condition: service_healthy
+      redis-local:
+        condition: service_healthy
+    profiles:
+      - dev
+      - local
+    networks:
+      - atom-local-net
+    labels:
+      - "atom.environment=local"
+      - "atom.service=app"

+  # Production server (for local testing)
+  app-prod:
+    build:
+      context: .
+      dockerfile: Dockerfile
+    container_name: atom-app-prod
+    ports:
+      - "${PORT:-3000}:3000"
+    environment:
+      NODE_ENV: production
+      POSTGRES_HOST: postgres-local
+      POSTGRES_PORT: 5432
+      POSTGRES_DB: ${POSTGRES_DB:-atom_local}
+      POSTGRES_USER: ${POSTGRES_USER:-atom_user}
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-local_password}
+      DATABASE_URL: postgresql://${POSTGRES_USER:-atom_user}:${POSTGRES_PASSWORD:-local_password}@postgres-local:5432/${POSTGRES_DB:-atom_local}
+    depends_on:
+      postgres-local:
+        condition: service_healthy
+    profiles:
+      - prod
+    networks:
+      - atom-local-net
+    labels:
+      - "atom.environment=local"
+      - "atom.service=app"

+  # Prisma studio for database management
+  prisma-studio:
+    image: node:18-alpine
+    container_name: atom-prisma-studio
+    working_dir: /app
+    command: sh -c "npx prisma studio --host 0.0.0.0 --port 5555"
+    ports:
+      - "5555:5555"
+    environment:
+      DATABASE_URL: postgresql://${POSTGRES_USER:-atom_user}:${POSTGRES_PASSWORD:-local_password}@postgres-local:5432/${POSTGRES_DB:-atom_local}
+    volumes:
+      - .:/app
+    depends_on:
+      postgres-local:
+        condition: service_healthy
+    profiles:
+      - studio
+    networks:
+      - atom-local-net
+    labels:
+      - "atom.environment=local"
+      - "atom.service=tool"
+
+volumes:
+  postgres_local_data:
+  redis_local_data:
+
+networks:
+  atom-local-net:
+    driver: bridge