From be46add18291cf69c12b9cef4a12bc20fc59bf60 Mon Sep 17 00:00:00 2001 From: achmad Date: Sun, 10 May 2026 21:35:31 +0700 Subject: [PATCH] chore: add .env.example and wire compose.yml to env vars - .env.example documents all env vars with defaults (postgres creds, DATABASE_URL, TTLs, pool sizes) - compose.yml reads postgres credentials and app config from .env via env_file - .gitignore: track .env.example, ignore .env --- .env.example | 18 ++++++++++++++++++ .gitignore | 3 +-- compose.yml | 14 ++++++-------- 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..636f50d --- /dev/null +++ b/.env.example @@ -0,0 +1,18 @@ +# PostgreSQL +POSTGRES_DB=goyomi +POSTGRES_USER=goyomi +POSTGRES_PASSWORD=goyomi + +# App +DATABASE_URL=postgres://goyomi:goyomi@postgres:5432/goyomi?sslmode=disable +FLARESOLVERR_URL=http://flaresolverr:8191 +ADDR=:8080 + +# Connection pool +DB_MAX_CONNS=10 +DB_MIN_CONNS=2 + +# Cache TTLs (seconds) +MANGA_LIST_TTL_SECONDS=600 +MANGA_DETAIL_TTL_SECONDS=3600 +CHAPTER_LIST_TTL_SECONDS=600 diff --git a/.gitignore b/.gitignore index e390285..dcb6f1d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,8 @@ /goyomi /cmd/server/server -# Environment +# Environment (copy .env.example → .env and fill in values) .env -.env.* # Go tooling *.test diff --git a/compose.yml b/compose.yml index 403810e..c073b9d 100644 --- a/compose.yml +++ b/compose.yml @@ -3,13 +3,13 @@ services: image: postgres:16-alpine restart: unless-stopped environment: - POSTGRES_DB: goyomi - POSTGRES_USER: goyomi - POSTGRES_PASSWORD: goyomi + POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: - test: ["CMD-SHELL", "pg_isready -U goyomi -d goyomi"] + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 5s timeout: 5s retries: 10 @@ -25,11 +25,9 @@ services: app: build: . restart: unless-stopped + env_file: .env ports: - - "8080:8080" - environment: - DATABASE_URL: postgres://goyomi:goyomi@postgres:5432/goyomi?sslmode=disable - FLARESOLVERR_URL: http://flaresolverr:8191 + - "${ADDR:-8080}:8080" depends_on: postgres: condition: service_healthy