Skip to content

Commit 0761f90

Browse files
committed
Use secrets, again
1 parent eea12a8 commit 0761f90

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

docker/compose.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ services:
2525
- DB_USER=lntuser
2626
- DB_HOST=dbserver
2727
- DB_NAME=lnt.db
28-
- DB_PASSWORD=${LNT_DB_PASSWORD}
29-
- AUTH_TOKEN=${LNT_AUTH_TOKEN}
28+
- DB_PASSWORD_FILE=/run/secrets/lnt-db-password
29+
- AUTH_TOKEN_FILE=/run/secrets/lnt-auth-token
30+
secrets:
31+
- lnt-db-password
32+
- lnt-auth-token
3033
depends_on:
3134
- db
3235
deploy:
@@ -42,13 +45,21 @@ services:
4245
container_name: dbserver
4346
image: docker.io/postgres:18-alpine
4447
environment:
45-
- POSTGRES_PASSWORD=${LNT_DB_PASSWORD}
48+
- POSTGRES_PASSWORD_FILE=/run/secrets/lnt-db-password
4649
- POSTGRES_USER=lntuser
4750
- POSTGRES_DB=lnt.db
51+
secrets:
52+
- lnt-db-password
4853
volumes:
4954
- database:/var/lib/postgresql
5055

5156
volumes:
5257
instance:
5358
logs:
5459
database:
60+
61+
secrets:
62+
lnt-db-password:
63+
environment: "LNT_DB_PASSWORD"
64+
lnt-auth-token:
65+
environment: "LNT_AUTH_TOKEN"

docker/docker-entrypoint.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
set -u
44

5-
DB_PATH="postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}"
5+
password="$(cat ${DB_PASSWORD_FILE})"
6+
token="$(cat ${AUTH_TOKEN_FILE})"
7+
DB_PATH="postgres://${DB_USER}:${password}@${DB_HOST}"
68

79
# Set up the instance the first time this gets run.
810
if [ ! -e /var/lib/lnt/instance/lnt.cfg ]; then
@@ -12,7 +14,7 @@ if [ ! -e /var/lib/lnt/instance/lnt.cfg ]; then
1214
--tmp-dir /tmp/lnt \
1315
--db-dir "${DB_PATH}" \
1416
--default-db "${DB_NAME}"
15-
sed -i "s/# \(api_auth_token =\).*/\1 '${AUTH_TOKEN}'/" /var/lib/lnt/instance/lnt.cfg
17+
sed -i "s/# \(api_auth_token =\).*/\1 '${token}'/" /var/lib/lnt/instance/lnt.cfg
1618
fi
1719

1820
# Run the server under gunicorn.

docker/lnt.dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# This image is intended to be built from a Docker Compose file, as it
33
# requires additional information passed as environment variables:
44
#
5-
# ENV DB_USER
5+
# DB_USER
66
# The username to use for logging into the database.
77
#
8-
# ENV DB_HOST
8+
# DB_HOST
99
# The hostname to use to access the database.
1010
#
11-
# ENV DB_NAME
11+
# DB_NAME
1212
# The name of the database on the server.
1313
#
14-
# ENV DB_PASSWORD
15-
# The password to use for logging into the database.
14+
# DB_PASSWORD_FILE
15+
# File containing the password to use for logging into the database.
1616
#
17-
# ENV AUTH_TOKEN
18-
# The authentication token used to require authentication
17+
# AUTH_TOKEN_FILE
18+
# File containing the authentication token used to require authentication
1919
# to perform destructive actions.
2020

2121
FROM python:3.10-alpine
@@ -37,6 +37,5 @@ VOLUME /var/lib/lnt /var/log/lnt
3737

3838
# Set up the actual entrypoint that gets run when the container starts.
3939
COPY docker/docker-entrypoint.sh docker/lnt-wait-db /usr/local/bin/
40-
ENV DB_USER= DB_HOST= DB_NAME= DB_PASSWORD= AUTH_TOKEN=
4140
ENTRYPOINT ["docker-entrypoint.sh"]
4241
EXPOSE 8000

0 commit comments

Comments
 (0)