Skip to content

Commit

Permalink
Parametrize uid and gid for non 1000 runner's
Browse files Browse the repository at this point in the history
Signed-off-by: Benoit Donneaux <benoit@leastauthority.com>
  • Loading branch information
btlogy committed Feb 1, 2024
1 parent 64035af commit 6381dd4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: prepare
run: |
docker-compose build
docker-compose build --build-arg uid="$(id -u)" --build-arg gid="$(id -g)"
docker-compose run client npm i
- name: deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Set up containers
run: |
docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e build
docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e build --build-arg uid="$(id -u)" --build-arg gid="$(id -g)"
docker compose run --rm client npm i
docker compose run --rm client ./scripts/setup.sh
docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e run --rm client-e2e npm i
Expand Down
21 changes: 19 additions & 2 deletions client-e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
FROM node:16-alpine

# Switch to the existing node user instead of root
USER node
# Parameters for default user:group
ARG uid=1000
ARG user=appuser
ARG gid=1000
ARG group=appgroup

# Remove exising node user to avoid possible conflict
RUN deluser node && rm -rf /home/node && chown -R root:root /opt

# Add user and group for build and runtime
RUN addgroup -g "${gid}" "${group}" && adduser -D -h /home/${user} -s /bin/bash -G "${group}" -u "${uid}" "${user}"

# Prepare directories
RUN DIRS="/usr/src/app" && \
mkdir -p ${DIRS} && \
chown -R ${user}:${group} $DIRS

# Switch to non-root user
USER ${user}

# Switch to the directory where the client code will live
WORKDIR /usr/src/app/client-e2e
Expand Down
23 changes: 20 additions & 3 deletions client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@ FROM node:16-alpine
# Install some require system packages
RUN apk add git openssh openssl lftp curl rust bash

# Switch to the existing node user instead of root
USER node
# Parameters for default user:group
ARG uid=1000
ARG user=appuser
ARG gid=1000
ARG group=appgroup

# Remove exising node user to avoid possible conflict
RUN deluser node && rm -rf /home/node && chown -R root:root /opt

# Add user and group for build and runtime
RUN addgroup -g "${gid}" "${group}" && adduser -D -h /home/${user} -s /bin/bash -G "${group}" -u "${uid}" "${user}"

# Prepare directories
RUN DIRS="/usr/src/app" && \
mkdir -p ${DIRS} && \
chown -R ${user}:${group} $DIRS

# Switch to non-root user
USER ${user}

# Install latest rust on top of it
# FIXME: make it reproducible!
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/home/node/.cargo/bin:${PATH}"
ENV PATH="/home/${user}/.cargo/bin:${PATH}"

# Install wasm-pack to build the WebAssembly packages
# FIXME: make it reproducible!
Expand Down

0 comments on commit 6381dd4

Please sign in to comment.