Skip to content

Commit e7d3a07

Browse files
authored
chore(docker): avoid running container as root
1 parent b991453 commit e7d3a07

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
FROM node:20-alpine AS builder
22
LABEL maintainer="Simone Locci <simonelocci88@gmail.com>"
33

4+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
5+
46
WORKDIR /app
57
COPY . .
68
RUN yarn install --immutable \
7-
&& yarn build
9+
&& yarn build \
10+
&& chown -R appuser:appgroup /app/docs
811

912
FROM node:20-alpine
1013
LABEL maintainer="Simone Locci <simonelocci88@gmail.com>"
@@ -20,7 +23,10 @@ COPY --from=builder /app/package.json ./
2023
COPY --from=builder /app/.yarn ./.yarn
2124
COPY --from=builder /app/.yarnrc.yml ./.yarnrc.yml
2225
COPY --from=builder /app/yarn.lock ./yarn.lock
26+
COPY --from=builder /etc/passwd /etc/passwd
27+
COPY --from=builder /etc/group /etc/group
2328

2429
EXPOSE 3000
2530

31+
USER appuser
2632
CMD ["node", "dist/main"]

0 commit comments

Comments
 (0)