Refactor Docker configuration and SQL initialization for improved resource management and table structure
This commit is contained in:
parent
5d268e8a5d
commit
4ee047fb9b
@ -1,7 +1,5 @@
|
|||||||
services:
|
services:
|
||||||
api1:
|
api1:
|
||||||
container_name: api1
|
|
||||||
hostname: api1
|
|
||||||
image: payment2:latest
|
image: payment2:latest
|
||||||
networks:
|
networks:
|
||||||
- backend
|
- backend
|
||||||
@ -12,13 +10,11 @@ services:
|
|||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "0.35"
|
cpus: "0.40"
|
||||||
memory: "90MB"
|
memory: "85MB"
|
||||||
|
|
||||||
|
|
||||||
api2:
|
api2:
|
||||||
container_name: api2
|
|
||||||
hostname: api2
|
|
||||||
image: payment2:latest
|
image: payment2:latest
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
@ -29,14 +25,12 @@ services:
|
|||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "0.35"
|
cpus: "0.40"
|
||||||
memory: "90MB"
|
memory: "85MB"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
container_name: nginx
|
|
||||||
hostname: nginx
|
|
||||||
ports:
|
ports:
|
||||||
- "9999:9999"
|
- "9999:9999"
|
||||||
volumes:
|
volumes:
|
||||||
@ -54,14 +48,11 @@ services:
|
|||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7.2-alpine
|
image: redis:7.2-alpine
|
||||||
hostname: redis
|
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
networks:
|
networks:
|
||||||
- backend
|
- backend
|
||||||
volumes:
|
|
||||||
- redis_data1:/data
|
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
@ -69,9 +60,8 @@ services:
|
|||||||
memory: "70MB"
|
memory: "70MB"
|
||||||
|
|
||||||
database:
|
database:
|
||||||
container_name: database
|
image: postgres:17-alpine
|
||||||
image: postgres:alpine
|
command: postgres -c checkpoint_timeout=600 -c max_wal_size=4096 -c synchronous_commit=0 -c fsync=0 -c full_page_writes=0
|
||||||
hostname: database
|
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
@ -80,15 +70,19 @@ services:
|
|||||||
- POSTGRES_USER=postgres
|
- POSTGRES_USER=postgres
|
||||||
- POSTGRES_PASSWORD=postgres_pwd
|
- POSTGRES_PASSWORD=postgres_pwd
|
||||||
volumes:
|
volumes:
|
||||||
- database_volume1:/var/lib/postgresql/data
|
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||||
- ./docker/db_init.sql:/docker-entrypoint-initdb.d/
|
healthcheck:
|
||||||
|
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
|
||||||
|
interval: 3s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 5
|
||||||
networks:
|
networks:
|
||||||
- backend
|
- backend
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "0.50"
|
cpus: "0.30"
|
||||||
memory: "90MB"
|
memory: "100MB"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
backend:
|
backend:
|
||||||
@ -97,5 +91,5 @@ networks:
|
|||||||
external: true
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
database_volume1:
|
db_volume:
|
||||||
redis_data1:
|
redis_data:
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
CREATE UNLOGGED TABLE payments (
|
|
||||||
id UUID PRIMARY KEY,
|
|
||||||
correlation_id UUID NOT NULL,
|
|
||||||
amount DECIMAL NOT NULL,
|
|
||||||
payment_processor VARCHAR(50,
|
|
||||||
status VARCHAR(50) NOT NULL,
|
|
||||||
error_message TEXT,
|
|
||||||
attempts INTEGER,
|
|
||||||
created_at TIMESTAMP default now() NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX payments_created_at ON payments (created_at );
|
|
||||||
CREATE INDEX payments_correlation_id ON payments (correlation_id);
|
|
||||||
9
init.sql
Normal file
9
init.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
CREATE UNLOGGED TABLE payments (
|
||||||
|
correlation_id UUID PRIMARY KEY,
|
||||||
|
amount DECIMAL(10, 2) NOT NULL,
|
||||||
|
payment_processor VARCHAR(10),
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX payments_created_at ON payments (created_at );
|
||||||
|
CREATE INDEX payments_correlation_id ON payments (correlation_id);
|
||||||
Loading…
x
Reference in New Issue
Block a user