Ocelot-Social/Dockerfile
Robert Schäfer bef8aa1d6a Reduce docker image size with multistage build
We don't need development dependencies in production. I also added the
BUILD_COMMIT environment variable to the image for convenience.
2018-12-14 22:41:13 +01:00

30 lines
816 B
Docker

FROM node:10-alpine as builder
LABEL Description="Backend of the Social Network Human-Connection.org" Vendor="Human Connection gGmbH" Version="0.0.1" Maintainer="Human Connection gGmbH (developer@human-connection.org)"
# Expose the app port
EXPOSE 4000
ARG BUILD_COMMIT
ENV BUILD_COMMIT=$BUILD_COMMIT
ARG WORKDIR=/nitro-backend
RUN mkdir -p $WORKDIR
WORKDIR $WORKDIR
# Install the Application Dependencies
COPY package.json .
COPY yarn.lock .
RUN yarn install --frozen-lockfile --non-interactive
COPY . .
COPY .env.template .env
RUN yarn run build
CMD ["yarn", "run", "start"]
# reduce image size with a multistage build
FROM node:10-alpine as production
ENV NODE_ENV=production
COPY --from=builder /nitro-backend/dist ./dist
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --non-interactive