Skip to content

Commit

Permalink
Merge pull request #471 from panoratech/docker-hc
Browse files Browse the repository at this point in the history
🩺 Updated docker healthchecks
  • Loading branch information
rflihxyz authored Jun 1, 2024
2 parents a669f61 + a657503 commit 106779e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OAUTH_REDIRECT_BASE=http://localhost:3000
JWT_SECRET=secret_jwt
ENCRYPT_CRYPTO_SECRET_KEY="0123456789abcdef0123456789abcdef"
BACKEND_PORT=3000

BACKEND_HOSTNAME="0.0.0.0"
#Managed only
SENTRY_DSN=

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-compose.healthcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
environment: SELF_HOSTED
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
BACKEND_PORT: ${{ secrets.BACKEND_PORT }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ services:
REDIS_HOST: ${REDIS_HOST}
REDIS_PASS: ${REDIS_PASS}
REDIS_PORT: ${REDIS_PORT}
BACKEND_HOSTNAME: ${BACKEND_HOSTNAME}
BACKEND_PORT: ${BACKEND_PORT}
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CRM_CLOUD_CLIENT_ID: ${HUBSPOT_CRM_CLOUD_CLIENT_ID}
HUBSPOT_CRM_CLOUD_CLIENT_SECRET: ${HUBSPOT_CRM_CLOUD_CLIENT_SECRET}
Expand Down
14 changes: 12 additions & 2 deletions docker-compose.source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ services:
REDIS_HOST: ${REDIS_HOST}
REDIS_PASS: ${REDIS_PASS}
REDIS_PORT: ${REDIS_PORT}
BACKEND_HOSTNAME: ${BACKEND_HOSTNAME}
BACKEND_PORT: ${BACKEND_PORT}
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CRM_CLOUD_CLIENT_ID: ${HUBSPOT_CRM_CLOUD_CLIENT_ID}
HUBSPOT_CRM_CLOUD_CLIENT_SECRET: ${HUBSPOT_CRM_CLOUD_CLIENT_SECRET}
Expand Down Expand Up @@ -119,6 +121,12 @@ services:
condition: service_healthy
networks:
- backend
healthcheck:
test: ["CMD-SHELL", "curl", "-f", "http://localhost:3000/health"]
start_period: 60s
interval: 10s
timeout: 1s
retries: 50

redis:
image: valkey/valkey:7.2-alpine
Expand All @@ -144,7 +152,8 @@ services:
ports:
- 80:8090
depends_on:
- api
api:
condition: service_healthy
networks:
- backend
- frontend
Expand All @@ -159,7 +168,8 @@ services:
ports:
- 81:80
depends_on:
- api
api:
condition: service_healthy
networks:
- backend
- frontend
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ services:
image: panoradotdev/backend-api:selfhosted
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?ssl=false
PORT: ${BACKEND_PORT}
DISTRIBUTION: ${DISTRIBUTION}
JWT_SECRET: ${JWT_SECRET}
REDIS_HOST: ${REDIS_HOST}
REDIS_PASS: ${REDIS_PASS}
REDIS_PORT: ${REDIS_PORT}
BACKEND_HOSTNAME: ${BACKEND_HOSTNAME}
BACKEND_PORT: ${BACKEND_PORT}
ENCRYPT_CRYPTO_SECRET_KEY: ${ENCRYPT_CRYPTO_SECRET_KEY}
HUBSPOT_CRM_CLOUD_CLIENT_ID: ${HUBSPOT_CRM_CLOUD_CLIENT_ID}
HUBSPOT_CRM_CLOUD_CLIENT_SECRET: ${HUBSPOT_CRM_CLOUD_CLIENT_SECRET}
Expand Down Expand Up @@ -106,7 +107,6 @@ services:
MAILCHIMP_MARKETINGAUTOMATION_CLOUD_CLIENT_SECRET: ${MAILCHIMP_MARKETINGAUTOMATION_CLOUD_CLIENT_SECRET}
PODIUM_MARKETINGAUTOMATION_CLOUD_CLIENT_ID: ${PODIUM_MARKETINGAUTOMATION_CLOUD_CLIENT_ID}
PODIUM_MARKETINGAUTOMATION_CLOUD_CLIENT_SECRET: ${PODIUM_MARKETINGAUTOMATION_CLOUD_CLIENT_SECRET}

restart: unless-stopped
ports:
- 3000:3000
Expand All @@ -116,11 +116,11 @@ services:
networks:
- backend
healthcheck:
#test: ["CMD", "nc", "-z", "localhost", "${BACKEND_PORT}"]
test: ["CMD", "curl", "-f", "http://api:3000/health"] # Alternative healthcheck method
test: ["CMD-SHELL", "curl", "-f", "https://google.com"]
start_period: 60s
interval: 10s
timeout: 1s
retries: 5
retries: 50

redis:
image: valkey/valkey:7.2-alpine
Expand Down
6 changes: 5 additions & 1 deletion packages/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ async function bootstrap() {
app.useGlobalInterceptors(new LoggerErrorInterceptor());
app.use(cookieParser());

await app.listen(3000);

// Passing a host is required by some PaaS providers such as flightcontrol
const port = process.env.BACKEND_PORT || 3000;
const host = process.env.BACKEND_HOSTNAME || '0.0.0.0';
await app.listen(port, host);
}
bootstrap();

0 comments on commit 106779e

Please sign in to comment.