Skip to content

Commit e99c923

Browse files
committed
docker: change containers to run with non root user
1 parent ba29400 commit e99c923

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

docker/docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ services:
2525
restart: no
2626
container_name: backend-build
2727
command: cargo build --release
28+
user: "${UID:-1000}:${GID:-1000}"
2829
working_dir: /app
2930
volumes:
3031
- ../backend:/app
@@ -35,6 +36,7 @@ services:
3536
restart: always
3637
container_name: backend
3738
command: ./backend
39+
user: "${UID:-1000}:${GID:-1000}"
3840
depends_on:
3941
postgres:
4042
condition: service_healthy
@@ -70,12 +72,16 @@ services:
7072
restart: no
7173
build:
7274
dockerfile: wg-webclient-builder/Dockerfile
75+
user: "${UID:-1000}:${GID:-1000}"
7376
volumes:
7477
- ../wg-webclient:/build
7578

7679
frontend-build:
7780
build:
7881
dockerfile: frontend-build/Dockerfile
82+
args:
83+
USER_ID: ${USER_ID:-1000}
84+
GROUP_ID: ${GROUP_ID:-1000}
7985
restart: no
8086
command:
8187
- /bin/sh
@@ -87,6 +93,7 @@ services:
8793
wg-webclient-builder:
8894
condition: service_completed_successfully
8995
working_dir: /build
96+
user: "${UID:-1000}:${GID:-1000}"
9097
environment:
9198
- IS_SEB=${IS_SEB}
9299
volumes:
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
FROM rust:1-bookworm
22

3-
RUN apt update && apt install clang -y
4-
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
3+
RUN apt update && apt install -y clang && rm -rf /var/lib/apt/lists/*
4+
5+
ARG USER_ID=1000
6+
ARG GROUP_ID=1000
7+
8+
RUN addgroup --gid ${GROUP_ID} builder && \
9+
adduser --disabled-password --gecos "" \
10+
--uid ${USER_ID} --ingroup builder \
11+
--shell /bin/sh --home /home/builder --quiet builder
12+
13+
USER builder
14+
15+
RUN cargo install wasm-pack
16+
517
WORKDIR /build
6-
CMD wasm-pack build
18+
CMD ["wasm-pack", "build"]

0 commit comments

Comments
 (0)