From 0614cfe97971a72433b4cceb9fdfab4a23589c24 Mon Sep 17 00:00:00 2001 From: keyan Date: Wed, 6 Mar 2024 17:38:34 -0600 Subject: [PATCH] refine docker config --- .env.sample | 24 ++++++++++++------------ Dockerfile | 4 +++- docker-compose.yml | 34 ++++++++++++++++++++++++++-------- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.env.sample b/.env.sample index 79f31442..62936a5c 100644 --- a/.env.sample +++ b/.env.sample @@ -4,16 +4,16 @@ ############################################################################ # github -GITHUB_ID= -GITHUB_SECRET= +GITHUB_ID= +GITHUB_SECRET= # twitter -TWITTER_ID= -TWITTER_SECRET= +TWITTER_ID= +TWITTER_SECRET= # email -LOGIN_EMAIL_SERVER=smtp://:@:587 -LOGIN_EMAIL_FROM= +LOGIN_EMAIL_SERVER= +LOGIN_EMAIL_FROM= LIST_MONK_AUTH= ##################################################################### @@ -48,16 +48,16 @@ OPENSEARCH_MODEL_ID= ####################################################### # lnd -LND_CERT= -LND_MACAROON= -LND_SOCKET=: +LND_CERT= +LND_MACAROON= +LND_SOCKET= # lnurl -LNAUTH_URL= -LNWITH_URL= +LNAUTH_URL= +LNWITH_URL= # nostr (NIP-57 zap receipts) -NOSTR_PRIVATE_KEY= +NOSTR_PRIVATE_KEY= ############### # LEAVE AS IS # diff --git a/Dockerfile b/Dockerfile index 5425a3ad..94125406 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,6 @@ WORKDIR /app EXPOSE 3000 -CMD npm install --loglevel verbose --legacy-peer-deps; npx prisma migrate dev; npm run dev \ No newline at end of file +RUN npm install --loglevel verbose --legacy-peer-deps +RUN npx prisma migrate dev +CMD npm run dev \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 43cb7020..382d152d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,12 +9,19 @@ services: ports: - "5431:5432" env_file: - - ./.env.sample + - ./.env.sndev + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 volumes: + - ./anon.sql:/docker-entrypoint-initdb.d/anon.sql - db:/var/lib/postgresql/data app: container_name: app build: ./ + restart: always healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3000"] interval: 10s @@ -22,9 +29,12 @@ services: retries: 10 start_period: 1m30s depends_on: - - db + db: + condition: service_healthy env_file: - - ./.env.sample + - ./.env.sndev + expose: + - "3000" ports: - "3000:3000" volumes: @@ -35,13 +45,16 @@ services: worker: container_name: worker build: ./worker + restart: always depends_on: db: - condition: service_started + condition: service_healthy app: condition: service_healthy + opensearch: + condition: service_healthy env_file: - - ./.env.sample + - ./.env.sndev ports: - "8080:8080" volumes: @@ -52,7 +65,7 @@ services: - opensearch entrypoint: ["/bin/sh", "-c"] command: - - npm run worker + - npm run worker:dev imgproxy: container_name: imgproxy image: darthsim/imgproxy:v3.18.1 @@ -63,7 +76,7 @@ services: retries: 3 restart: always env_file: - - ./.env.sample + - ./.env.sndev expose: - "8080" ports: @@ -73,6 +86,12 @@ services: opensearch: image: opensearchproject/opensearch:latest container_name: opensearch + healthcheck: + test: ["CMD-SHELL", "curl -ku admin:admin --silent --fail localhost:9200/_cluster/health || exit 1"] + interval: 10s + timeout: 10s + retries: 10 + restart: always environment: - discovery.type=single-node - plugins.security.disabled=true @@ -81,7 +100,6 @@ services: - 9600:9600 # Performance Analyzer volumes: - os:/usr/share/opensearch/data - - ./:/app command: > bash -c ' set -m