diff --git a/Dockerfile b/Dockerfile index 632c03e1..862e1c03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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. diff --git a/docker-compose.yml b/docker-compose.yml index 20181ae9..2fd0aabd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,4 +18,4 @@ services: container_name: mongo restart: always volumes: - - ./data:/data/db \ No newline at end of file + - ./data:/data/db