-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
82 lines (77 loc) · 2.12 KB
/
docker-compose.yml
File metadata and controls
82 lines (77 loc) · 2.12 KB
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
# Docker Compose for LocalStore API - Production/EC2
# PostgreSQL 17, Redis 8, NestJS API
services:
postgres:
image: postgres:17-alpine
container_name: localstore-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${DATABASE_NAME:-localstore}
POSTGRES_USER: ${DATABASE_USERNAME:-postgres}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:?Database password required}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 10s
timeout: 5s
retries: 5
networks:
- localstore-network
redis:
image: redis:8-alpine
container_name: localstore-redis
restart: unless-stopped
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 10s
timeout: 5s
retries: 5
networks:
- localstore-network
api:
image: ${API_IMAGE:-localstore/api:latest}
container_name: localstore-api
restart: unless-stopped
environment:
- NODE_ENV=production
- PORT=8080
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_NAME=${DATABASE_NAME:-localstore}
- DATABASE_USERNAME=${DATABASE_USERNAME:-postgres}
- DATABASE_PASSWORD=${DATABASE_PASSWORD:?Database password required}
- REDIS_HOST=redis
- REDIS_PORT=6379
ports:
- '8080:8080'
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
logging:
driver: local
options:
max-size: '50m'
max-file: '5'
healthcheck:
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:8080/api/v1/health']
interval: 30s
timeout: 10s
start_period: 30s
retries: 3
networks:
- localstore-network
volumes:
postgres_data:
driver: local
redis_data:
driver: local
networks:
localstore-network:
driver: bridge