Skip to content

Commit

Permalink
fix: only expose postgres to other containers
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Aug 12, 2024
1 parent 87d5f47 commit 987cb24
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=spacetraders
ports:
- "5432:5432"
# Only expose the port to other containers.
expose: [5432]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
Expand Down
3 changes: 2 additions & 1 deletion cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ words:
- chalkdart
- cirruslabs
- pubspec
- templating
- templating
- PGHOST
2 changes: 1 addition & 1 deletion packages/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WORKDIR /app/cli
RUN dart pub get --offline

RUN mkdir -p /app/bin
RUN dart compile exe bin/${BIN}.dart -o /app/bin/server
RUN dart compile exe -DPGHOST=db bin/${BIN}.dart -o /app/bin/server

Check warning on line 25 in packages/cli/Dockerfile

View workflow job for this annotation

GitHub Actions / 🔤 Check Spelling / build

Unknown word (DPGHOST)

# Build minimal serving image from AOT-compiled `/server` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
Expand Down
2 changes: 1 addition & 1 deletion packages/db/lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:postgres/postgres.dart' as pg;
// TODO(eseidel): Move this up to cli/config.dart.
/// Default database config for connecting to a local postgres database.
pg.Endpoint defaultDatabaseEndpoint = pg.Endpoint(
host: 'db',
host: const String.fromEnvironment('PGHOST', defaultValue: 'localhost'),
username: 'postgres',
password: 'postgres',
database: 'spacetraders',
Expand Down

0 comments on commit 987cb24

Please sign in to comment.