Skip to content

Commit

Permalink
Fixes broken Docker image build
Browse files Browse the repository at this point in the history
The `npm audit fix` in the `Dockerfile` is currently
deleting vulnerable packages. Although we do want to have package
security, this should be done in a development process, not as part
of the Docker build.

This commit also reduces the Docker image size and improves security.
  • Loading branch information
pazaan committed Dec 6, 2021
1 parent 1477c79 commit 5e0e592
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ FROM node:14.15.3-alpine

LABEL maintainer="Nightscout Contributors"

RUN mkdir -p /opt/app
ADD . /opt/app
WORKDIR /opt/app
RUN chown -R node:node /opt/app
USER node
ADD . /opt/app

RUN npm install && \
# TODO: We should be able to do `RUN npm install --only=production`.
# For this to work, we need to copy only package.json and things needed for `npm`'s to succeed.
# TODO: Do we need to re-add `npm audit fix`? Or should that be part of a development process/stage?
RUN npm install --cache /tmp/empty-cache && \
npm run postinstall && \
npm run env && \
npm audit fix
rm -rf /tmp/*
# TODO: These should be added in the future to correctly cache express-minify content to disk
# Currently, doing this breaks the browser cache.
# mkdir /tmp/public && \
# chown node:node /tmp/public

USER node
EXPOSE 1337

CMD ["node", "lib/server/server.js"]

0 comments on commit 5e0e592

Please sign in to comment.