geo ip 데이터 load후 api 수행하도록 구조 변경
This commit is contained in:
@@ -1,35 +1,58 @@
|
||||
services:
|
||||
postgres:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.postgres
|
||||
environment:
|
||||
- POSTGRES_DB=geoip
|
||||
- POSTGRES_USER=geoip_admin
|
||||
- POSTGRES_PASSWORD=geoip_admin
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
- ./GeoLite2-City.mmdb:/data/GeoLite2-City.mmdb:ro
|
||||
- ./deploy/postgres/init:/docker-entrypoint-initdb.d:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U geoip_admin -d geoip"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
api:
|
||||
build: .
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
postgres:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- "${PORT:-8080}:8080"
|
||||
environment:
|
||||
- PORT=8080
|
||||
- GEOIP_BACKEND=postgres
|
||||
- DATABASE_URL=postgres://geoip_readonly:geoip_readonly@postgres:5432/geoip?sslmode=disable
|
||||
- GEOIP_DB_PATH=/data/GeoLite2-City.mmdb
|
||||
- PORT=${PORT:-8080}
|
||||
- GEOIP_DB_PATH=${GEOIP_DB_PATH:-/data/GeoLite2-City.mmdb}
|
||||
- GEOIP_BACKEND=${GEOIP_BACKEND:-mmdb}
|
||||
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST:-db}:${POSTGRES_PORT:-5432}/${POSTGRES_DB}?sslmode=disable
|
||||
command: >
|
||||
sh -c '
|
||||
if [ "${GEOIP_BACKEND}" = "postgres" ]; then
|
||||
echo "[api] running geoip-loader before api start";
|
||||
geoip-loader;
|
||||
else
|
||||
echo "[api] skipping geoip-loader (backend=${GEOIP_BACKEND})";
|
||||
fi;
|
||||
exec geoip
|
||||
'
|
||||
volumes:
|
||||
- ./GeoLite2-City.mmdb:/data/GeoLite2-City.mmdb:ro
|
||||
networks:
|
||||
- geo-ip
|
||||
|
||||
db:
|
||||
image: postgres:17.7-trixie
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
ports:
|
||||
- "${POSTGRES_PORT:-5432}:5432"
|
||||
volumes:
|
||||
- ./GeoLite2-City.mmdb:/data/GeoLite2-City.mmdb:ro
|
||||
- ./deploy/postgres/init:/docker-entrypoint-initdb.d:ro
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
networks:
|
||||
- geo-ip
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
postgres_data:
|
||||
|
||||
networks:
|
||||
geo-ip:
|
||||
|
||||
Reference in New Issue
Block a user