Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(agora): change agora-api to construct mongo URI from host, username, password, port, and DB name env variables (AG-1592) #2967

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/agora/api/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
MONGODB_URI="mongodb://root:changeme@agora-mongo:27017/agora?authSource=admin"
MONGODB_PASS="changeme"
MONGODB_USER="root"
MONGODB_HOST="agora-mongo"
MONGODB_PORT="27017"
MONGODB_NAME="agora"
NODE_ENV="development"
32 changes: 29 additions & 3 deletions apps/agora/api/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,39 @@ import {
teamsRoute,
} from './components';

const mongoUri = process.env.MONGODB_URI;
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 (!mongoUri) {
console.error('No MONGODB_URI environment variable has been defined.');
if (!mongodbUser) {
console.error('No MONGODB_USER environment variable has been defined.');
process.exit(1);
}

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

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

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`;
tschaffter marked this conversation as resolved.
Show resolved Hide resolved

mongoose
.connect(mongoUri)
.then(() => console.log('Connected to MongoDB'))
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 apps/agora/app/src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"csrApiUrl": "http://localhost:3333/v1",
"ssrApiUrl": "http://agora-api:3333/v1",
"rollbarToken": "e788198867474855a996485580b08d03",
"tagName": "agora/v0.0.2"
"tagName": "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
Loading