Skip to content

Commit 03896bc

Browse files
committed
feat: increase security by using a non-root user in the container
1 parent 9d75313 commit 03896bc

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,26 @@
88
# https://github.com/BretFisher/nodejs-rocks-in-docker
99
FROM node:16-bullseye-slim
1010

11-
WORKDIR /app
11+
ARG USERNAME=migrator
12+
ARG USER_UID=2000
13+
ARG USER_GID=$USER_UID
1214

13-
LABEL version="1.0.0"
15+
LABEL version="0.1.5"
1416
LABEL description="Migrate Issues, Wiki from gitlab to github."
1517

18+
WORKDIR /app
19+
20+
# Add a non-root user, so later we can explore methods to scale
21+
# privileges within this container.
22+
# https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
23+
RUN groupadd --gid $USER_GID $USERNAME
24+
RUN useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
25+
RUN chown -R $USERNAME /app
26+
1627
# Copy the project contents to the container
17-
COPY . /app
28+
COPY --chown=$USERNAME . /app
29+
30+
USER $USERNAME
1831

1932
# Install dependencies
2033
RUN npm i

0 commit comments

Comments
 (0)