61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
services:
|
|
api:
|
|
build: .
|
|
env_file:
|
|
- .env
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
ports:
|
|
- "${PORT:-8080}:8080"
|
|
environment:
|
|
- PORT=${PORT:-8080}
|
|
- GEOIP_DB_PATH=${GEOIP_DB_PATH:-/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:
|
|
- ./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:
|
|
postgres_data:
|
|
|
|
networks:
|
|
geo-ip:
|