From 6a34c33f0d17a68698b370eeab779aa5df3e28c9 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 21 Sep 2024 18:34:49 -0400 Subject: [PATCH] Consolidate env vars + fix minion under compose Since we're not deploying this, we can try to set environment variables in fewer places. --- .env | 17 +++++++++++--- docker-compose.yml | 25 ++++++++++++--------- localapi.env | 9 -------- pg/docker-entrypoint-initdb.d/100-roles.sql | 2 +- 4 files changed, 29 insertions(+), 24 deletions(-) delete mode 100644 localapi.env diff --git a/.env b/.env index 074398d..854abd3 100644 --- a/.env +++ b/.env @@ -1,4 +1,15 @@ -COMPOSE_PROJECT_NAME=metacpan +API_SERVER="morbo -l http://*:5000 -w app.psgi -w bin -w lib -w templates --verbose" +COLUMNS=80 +ES=elasticsearch:9200 +ES_TEST=elasticsearch_test:9200 +MINICPAN=/CPAN +MOJO_MODE=development +NET_ASYNC_HTTP_MAXCONNS=1 +PERL_CARTON_PATH=/carton +PERL_MM_USE_DEFAULT=1 +PG_DATABASE=metacpan +PG_HOST=pghost +PG_PASSWORD=t00lchain +PG_PORT=5432 +PG_USER=metacpan PLACK_ENV=development -PGDB=pgdb:5432 -API_SERVER=morbo -l http://*:5000 -w app.psgi -w bin -w lib -w templates --verbose diff --git a/docker-compose.yml b/docker-compose.yml index 5f1d52f..9d961a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,6 @@ --- - +x-project: + name: metacpan # ____ _____ ______ _____ ____ _____ ____ # / ___|| ____| _ \ \ / /_ _/ ___| ____/ ___| # \___ \| _| | |_) \ \ / / | | | | _| \___ \ @@ -100,16 +101,18 @@ services: api: depends_on: - elasticsearch - - pgdb + - pghost - traefik image: metacpan/metacpan-api:latest build: context: ./src/metacpan-api + # put variables for compose inside a .env file + # use env_file for variables to be set inside the container env_file: - - localapi.env + - .env command: > /metacpan-api/wait-for-es.sh http://elasticsearch:9200 "" -- - /metacpan-api/wait-for-it.sh -t 15 -s ${PGDB} -- + /metacpan-api/wait-for-it.sh -t 15 -s -h ${PG_HOST} -p ${PG_PORT} -- ${API_SERVER} ./bin/api.pl volumes: - type: volume @@ -154,7 +157,7 @@ services: api_test: depends_on: - elasticsearch_test - - pgdb + - pghost image: metacpan/metacpan-api:latest build: context: ./src/metacpan-api @@ -162,7 +165,7 @@ services: - localapi_test.env command: > /metacpan-api/wait-for-es.sh http://elasticsearch_test:9200 "" -- - /metacpan-api/wait-for-it.sh -t 15 -s ${PGDB} -- + /metacpan-api/wait-for-it.sh -t 15 -s -h ${PG_HOST} -p ${PG_PORT} -- ${API_SERVER} ./bin/api.pl volumes: - type: volume @@ -315,8 +318,8 @@ services: # |_| |___/ |_| # - pgdb: - hostname: pgdb + pghost: + hostname: pghost image: "postgres:${PG_VERSION_TAG:-9.6-alpine}" build: context: "./pg" @@ -324,7 +327,7 @@ services: PG_TAG: "${PG_VERSION_TAG:-9.6-alpine}" environment: POSTGRES_PASSWORD: metacpan - POSTGRES_USERNAME: metacpan123 + POSTGRES_USER: metacpan123 POSTGRES_DB: metacpan networks: - database @@ -336,7 +339,7 @@ services: test: ["CMD", "/healthcheck.sh"] volumes: - type: volume - source: pgdb-data + source: pghost-data target: /var/lib/postgresql/data - type: bind source: ./pg/docker-entrypoint-initdb.d @@ -373,6 +376,6 @@ volumes: cpan: elasticsearch: elasticsearch_test: - pgdb-data: + pghost-data: metacpan_git_shared: external: true diff --git a/localapi.env b/localapi.env deleted file mode 100644 index 97514a8..0000000 --- a/localapi.env +++ /dev/null @@ -1,9 +0,0 @@ -NET_ASYNC_HTTP_MAXCONNS=1 -COLUMNS=80 -ES=elasticsearch:9200 -ES_TEST=elasticsearch_test:9200 -ES_TEST=elasticsearch_test:9200 -MINICPAN=/CPAN -PERL_MM_USE_DEFAULT=1 -PERL_CARTON_PATH=/carton -MOJO_MODE=development diff --git a/pg/docker-entrypoint-initdb.d/100-roles.sql b/pg/docker-entrypoint-initdb.d/100-roles.sql index 6094210..867939c 100644 --- a/pg/docker-entrypoint-initdb.d/100-roles.sql +++ b/pg/docker-entrypoint-initdb.d/100-roles.sql @@ -1,4 +1,4 @@ -CREATE ROLE metacpan WITH LOGIN PASSWORD 'metacpan'; +CREATE ROLE metacpan WITH LOGIN PASSWORD 't00lchain'; CREATE ROLE "metacpan-api" WITH LOGIN; -- make things easier for when we're poking around from inside the container