Migrate architecture to PostgreSQL for Swarm HA
This commit is contained in:
1 parent
ee28968a70
commit
2317f9f133
39 files changed
+3849
-10
No files matched your search
+24
-10
@@ -1,23 +1,37 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
inventory-app:
|
||||
image: inventory-app:latest
|
||||
container_name: portal-inventory
|
||||
ports:
|
||||
- "3000:3000"
|
||||
postgres-db:
|
||||
image: postgres:15-alpine
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DATABASE_URL=file:/app/dev.db
|
||||
- SESSION_SECRET=ganti_dengan_rahasia_acak_anda
|
||||
- POSTGRES_USER=inventory_user
|
||||
- POSTGRES_PASSWORD=sandi_rahasia_db_123
|
||||
- POSTGRES_DB=inventory_db
|
||||
volumes:
|
||||
# PENTING: Ganti '/opt/inventory' dengan lokasi folder Anda di VPS Node Manager
|
||||
- /opt/inventory/dev.db:/app/dev.db
|
||||
# PENTING: Lokasi folder data PostgreSQL di Node Manager
|
||||
- /opt/inventory/pgdata:/var/lib/postgresql/data
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
# Database tetap dikunci di Node Manager agar file data tidak hilang
|
||||
- node.role == manager
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
|
||||
inventory-app:
|
||||
image: inventory-app:latest
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DATABASE_URL=postgresql://inventory_user:sandi_rahasia_db_123@postgres-db:5432/inventory_db?schema=public
|
||||
- SESSION_SECRET=ganti_dengan_rahasia_acak_anda
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 2 # Aplikasi kini bisa disebar ke beberapa server!
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
depends_on:
|
||||
- postgres-db
|
||||
Reference in new issue
Block a user