Skip to content

Commit

Permalink
update db configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
d-buckner committed Jan 20, 2025
1 parent 3d8f56f commit cbd6b1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- uses: actions/checkout@v4
- name: Build the server image
run: |
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
build: ./service
restart: always
environment:
- NODE_ENV=production
- NODE_ENV=compose
depends_on:
database:
condition: service_started
Expand Down
9 changes: 6 additions & 3 deletions service/src/clients/Database.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {MongoClient} from "mongodb";

const HOST = process.env.NODE_ENV === 'production'
? 'database'
: 'localhost';
const ENV_HOSTS = {
production: 'http://p2piano.home',
compose: 'database',
} as const;

const HOST = ENV_HOSTS[process.env.NODE_ENV] ?? 'localhost';
const URI = `mongodb://root:password@${HOST}:27017`;
const client = new MongoClient(URI);

Expand Down

0 comments on commit cbd6b1e

Please sign in to comment.