Files
geoip-rest/docker-compose.yml
2025-12-10 09:55:35 +09:00

62 lines
1.6 KiB
YAML

services:
api:
build: .
env_file:
- .env
depends_on:
db:
condition: service_healthy
ports:
- "${SERVICE_PORT:-8080}:8080"
environment:
- SERVICE_PORT=${SERVICE_PORT:-8080}
- GEOIP_DB_PATH=${GEOIP_DB_PATH:-/app/initial_data/GeoLite2-City.mmdb}
- GEOIP_BACKEND=${GEOIP_BACKEND:-mmdb}
- GEOIP_LOADER_TIMEOUT=${GEOIP_LOADER_TIMEOUT:-30m}
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST:-db}:${POSTGRES_PORT:-5432}/${POSTGRES_DB}?sslmode=disable
command: >
sh -c '
set -e;
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:
- ./initial_data:/app/initial_data:ro
- ./update_data:/app/update_data
- ./log:/app/log
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:
- ./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:
postgres_data:
networks:
geo-ip: