Skip to content

Commit

Permalink
Merge pull request #33 from vgenev/fix/docker-file-with-builder
Browse files Browse the repository at this point in the history
fix: refactored dockerfile to follow builder and not use root
  • Loading branch information
vgenev authored Feb 9, 2021
2 parents a30b6bb + c988fab commit 7e04a91
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM node:12.16.0-alpine

FROM node:12.16.1-alpine as builder
WORKDIR /opt/event-sidecar

RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool autoconf automake \
Expand All @@ -8,12 +7,26 @@ RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool aut
&& npm install -g node-gyp

COPY package.json package-lock.json* /opt/event-sidecar/
RUN npm install --production
RUN npm install

RUN apk del build-dependencies

COPY config /opt/event-sidecar/config
COPY src /opt/event-sidecar/src

FROM node:12.16.1-alpine
WORKDIR /opt/event-sidecar

# Create empty log file & link stdout to the application log file
RUN mkdir ./logs && touch ./logs/combined.log
RUN ln -sf /dev/stdout ./logs/combined.log

# Create a non-root user: ml-user
RUN adduser -D ml-user
USER ml-user

COPY --chown=ml-user --from=builder /opt/event-sidecar .
RUN npm prune --production

EXPOSE 4001
CMD ["npm", "run", "start"]

0 comments on commit 7e04a91

Please sign in to comment.