Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Docker to run as non-root user. #337

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Start with first build stage

FROM node:14-alpine AS build

# Add and set user to ackee. Disable the password and do not create a home folder.
RUN adduser -D ackee ackee
USER ackee

WORKDIR /srv/app/

# Add dependencies first so that Docker can use the cache as long as the dependencies stay unchanged
Expand All @@ -24,6 +29,12 @@ WORKDIR /srv/app/

COPY --from=build /srv/app/ /srv/app/

# Create User/Group to run as and change ownership of files
RUN adduser -D ackee ackee && chown -R ackee:ackee /srv/app

# Adjust to run as the new user
USER ackee

# Run healthcheck against MongoDB, server and API.
# Wait a bit before start to ensure the `yarn build` is done.

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ services:
container_name: mongo
restart: always
volumes:
- ./data:/data/db
- ./data:/data/db