Skip to content

Commit 65b561f

Browse files
committed
Use a secrets file for the postgres password
[refs %60f29fdc993a]
1 parent 5b102a7 commit 65b561f

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

swarm/swarm-demo-frontend/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM ruby:2.4.3-alpine
22

3-
RUN apk --no-cache add build-base postgresql-dev
3+
RUN apk --no-cache add bash build-base postgresql-dev
44

55
WORKDIR /tmp
66
COPY Gemfile* ./
@@ -11,4 +11,5 @@ COPY . .
1111

1212
EXPOSE 8080
1313

14+
ENTRYPOINT ["/app/docker-entrypoint.sh"]
1415
CMD ["/usr/local/bin/bundle", "exec", "ruby", "app.rb"]

swarm/swarm-demo-frontend/app.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
set :bind, '0.0.0.0'
66
set :port, 8080
77

8-
raise "Simulating an error"
9-
108
AppState = {}
119
AppState[:total_requests] = 0
1210

swarm/swarm-demo-frontend/docker-compose.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@ version: "3.3"
22

33
services:
44
frontend:
5-
image: jfahrer/swarm-demo-frontend:v7
5+
image: jfahrer/swarm-demo-frontend:v8
66
build:
77
context: .
88
ports:
99
- 8080:8080
1010
volumes:
1111
- .:/app
12+
- ./pg_secret:/var/run/pg_secret
1213
environment:
1314
- POSTGRES_USER=demo
14-
- POSTGRES_PASSWORD=secret
1515
- POSTGRES_DB=demo
1616
- POSTGRES_HOST=db
17+
- POSTGRES_PASSWORD_FILE=/var/run/pg_secret
1718

1819
db:
1920
image: jfahrer/swarm-demo-db:v1
2021
environment:
2122
- POSTGRES_USER=demo
22-
- POSTGRES_PASSWORD=secret
2323
- POSTGRES_DB=demo
24+
- POSTGRES_PASSWORD_FILE=/var/run/pg_secret
25+
volumes:
26+
- ./pg_secret:/var/run/pg_secret
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set +e
4+
5+
if [ ! -z "$POSTGRES_PASSWORD_FILE" ]; then
6+
echo "Reading password from $POSTGRES_PASSWORD_FILE"
7+
export POSTGRES_PASSWORD="$(< "${POSTGRES_PASSWORD_FILE}")"
8+
fi
9+
10+
exec "$@"

swarm/swarm-demo-frontend/pg_secret

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foobar

0 commit comments

Comments
 (0)