Skip to content

Commit

Permalink
AG-1592: externalize agora-api mongo port and db name, fix agora-apex…
Browse files Browse the repository at this point in the history
… healthcheck, add missing agora-app env variables
  • Loading branch information
hallieswan committed Jan 16, 2025
1 parent f6b550a commit 5339314
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/agora/api/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
MONGODB_PASS="changeme"
MONGODB_USER="root"
MONGODB_HOST="agora-mongo"
MONGODB_PORT="27017"
MONGODB_NAME="agora"
NODE_ENV="development"
14 changes: 13 additions & 1 deletion apps/agora/api/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
const mongodbUser = process.env.MONGODB_USER;
const mongodbPass = process.env.MONGODB_PASS;
const mongodbHost = process.env.MONGODB_HOST;
const mongodbPort = process.env.MONGODB_PORT;
const mongodbName = process.env.MONGODB_NAME;

if (!mongodbUser) {
console.error('No MONGODB_USER environment variable has been defined.');
Expand All @@ -33,7 +35,17 @@ if (!mongodbHost) {
process.exit(1);
}

const mongoUri = `mongodb://${mongodbUser}:${mongodbPass}@${mongodbHost}:27017/agora?authSource=admin`;
if (!mongodbPort) {
console.error('No MONGODB_PORT environment variable has been defined.');
process.exit(1);
}

if (!mongodbName) {
console.error('No MONGODB_NAME environment variable has been defined.');
process.exit(1);
}

const mongoUri = `mongodb://${mongodbUser}:${mongodbPass}@${mongodbHost}:${mongodbPort}/${mongodbName}?authSource=admin`;

mongoose
.connect(mongoUri)
Expand Down
4 changes: 3 additions & 1 deletion apps/agora/app/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
API_DOCS_URL="http://localhost:8000/api-docs"
APP_VERSION="4.0.0"
CSR_API_URL="http://localhost:8000/api/v1"
SSR_API_URL="http://agora-api:3333/v1"
SSR_API_URL="http://agora-api:3333/v1"
ROLLBAR_TOKEN="e788198867474855a996485580b08d03"
TAG_NAME="agora/v4.0.0-rc1"
2 changes: 1 addition & 1 deletion docker/agora/services/apex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
ports:
- '8000:80'
healthcheck:
test: ['CMD', 'curl', '--fail', 'http://localhost:80/health']
test: ['CMD', 'wget', '--spider', '--quiet', 'http://localhost:80/health']
interval: 30s
timeout: 10s
retries: 3
Expand Down

0 comments on commit 5339314

Please sign in to comment.