Skip to content

Commit 5931483

Browse files
committed
prepare for prod deployment
- User namespace remapping with UID/GID build args - Bind mount volumes with relative paths - Hardcoded container names for backup service integration - Secrets passed via systemd environment variables status-im/infra-sites#89 status-im/infra-sites#35
1 parent dc8f4a1 commit 5931483

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

.env.prod.db

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
POSTGRES_USER=root
2+
POSTGRES_DB=shell_db_prod

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ local_settings.py
8888
.env.dev
8989
.env.prod
9090
.env.dev.db
91-
.env.prod.db
9291
db.sqlite3
9392
node_modules/
9493
static/keycard_shell/js

Dockerfile.prod

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# pull official base image
55
FROM python:3.13.2-alpine as builder
66

7+
# Build args for UID/GID
8+
ARG UID=1000
9+
ARG GID=1000
10+
711
# set work directory
812
WORKDIR /usr/src/keycard_shell
913
# set environment variables
@@ -30,11 +34,15 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/keycard_shell/wheels
3034
# pull official base image
3135
FROM python:3.13.2-alpine
3236

37+
# Build args for UID/GID
38+
ARG UID=1000
39+
ARG GID=1000
40+
3341
# create directory for the app user
3442
RUN mkdir -p /home/keycard_shell
3543

3644
# create the app user
37-
RUN addgroup -S keycard_shell && adduser -S keycard_shell -G keycard_shell
45+
RUN addgroup -g ${GID} -S keycard_shell && adduser -u ${UID} -S keycard_shell -G keycard_shell
3846

3947
# create the appropriate directories
4048
ENV HOME=/home/keycard_shell
@@ -61,16 +69,16 @@ COPY . $APP_HOME
6169
RUN sed -i 's/\r//g' $APP_HOME/entrypoint.prod.sh
6270
RUN chmod +x $APP_HOME/entrypoint.prod.sh
6371

64-
# chown all the files to the app user
65-
RUN chown -R keycard_shell:keycard_shell $APP_HOME
66-
RUN mkdir -p /var/lib/keycard_shell/data
67-
RUN chown -R keycard_shell:keycard_shell /var/lib/keycard_shell/data
68-
6972
# build JS, CSS
7073
RUN npm install
7174
RUN npm run build
7275
RUN npm cache clean --force
7376

77+
# chown all the files to the app user
78+
RUN chown -R ${UID}:${GID} $APP_HOME
79+
RUN mkdir -p /var/lib/keycard_shell/data
80+
RUN chown -R ${UID}:${GID} /var/lib/keycard_shell/data
81+
7482
# change to the app user
7583
USER keycard_shell
7684

docker-compose.prod.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
services:
22
web:
3+
container_name: keycard-shell-webapp
34
build:
45
context: .
56
dockerfile: Dockerfile.prod
7+
args:
8+
UID: ${UID:-1000}
9+
GID: ${GID:-1000}
610
volumes:
7-
- kpro_data:/var/lib/keycard_shell/data/
8-
- static_volume:/home/keycard_shell/web/staticfiles
11+
- ../upload:/var/lib/keycard_shell/data/
12+
- ../static:/home/keycard_shell/web/staticfiles
13+
environment:
14+
- SECRET_KEY=${SECRET_KEY}
15+
- DB_SIGN_KEY=${DB_SIGN_KEY}
16+
- DEVICE_VERIFICATION_SIGN_KEY=${DEVICE_VERIFICATION_SIGN_KEY}
17+
- SALT_KEY=${SALT_KEY}
18+
- DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD}
19+
- SQL_PASSWORD=${SQL_PASSWORD}
920
env_file:
1021
- ./.env.prod
1122
depends_on:
1223
- db
1324
db:
25+
container_name: keycard-shell-db # Used by backup service - do not change!
1426
image: postgres:17.4-alpine
1527
volumes:
16-
- /docker/shell/db/data:/var/lib/postgresql/data/
28+
- ../db/data:/var/lib/postgresql/data/
29+
environment:
30+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
1731
env_file:
1832
- ./.env.prod.db
1933
nginx:
34+
container_name: kshell-nginx
2035
build: ./nginx
2136
ports:
2237
- 3000:3000
2338
depends_on:
2439
- web
2540
volumes:
26-
- kpro_data:/var/lib/keycard_shell/data/
27-
- static_volume:/home/keycard_shell/web/staticfiles
28-
volumes:
29-
kpro_data:
30-
static_volume:
31-
41+
- ../upload:/var/lib/keycard_shell/data/
42+
- ../static:/home/keycard_shell/web/staticfiles

0 commit comments

Comments
 (0)