Skip to content

Commit

Permalink
fix(docker): allow to customize user uid and gid via build args
Browse files Browse the repository at this point in the history
since ubuntu 24.04 the dedicated 'ubuntu' user with id 1000 is added, with build arg
and default value 1000 we keep backward compatibility with ubuntu:20.04 images, but
can override the value for ubuntu:24.04 images
  • Loading branch information
pavel-snyk committed Dec 9, 2024
1 parent 850fc7e commit 0c438db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ workflows:
- team-broker-snyk
requires:
- Scan repository for secrets
additional_arguments: "--build-arg BASE_IMAGE=ubuntu:24.04"
additional_arguments: "--build-arg BASE_IMAGE=ubuntu:24.04 --build-arg USER_UID=2000"
dockerfile: dockerfiles/base/Dockerfile
nodejs_cycle: "23"
project_name: broker-nlatest
Expand Down
6 changes: 4 additions & 2 deletions dockerfiles/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ ARG NODE_VERSION
ENV DEBIAN_FRONTEND=noninteractive
ENV NODE_VERSION=${NODE_VERSION}
ENV PATH=$PATH:/home/node/.npm-global/bin
ARG USER_UID=1000
ARG USER_GID=${USER_UID}

RUN <<EOF
set -ex
groupadd --gid 1000 node
useradd --uid 1000 --gid node --shell /bin/bash --create-home node
groupadd --gid ${USER_GID} node
useradd --uid ${USER_UID} --gid node --shell /bin/bash --create-home node
apt update
apt upgrade --assume-yes
# install packages needed for node installation
Expand Down

0 comments on commit 0c438db

Please sign in to comment.