Skip to content

Instantly share code, notes, and snippets.

@chill-cod3r
Created November 6, 2018 12:59
Show Gist options
  • Save chill-cod3r/6efea2f71804e509f615321ba188f046 to your computer and use it in GitHub Desktop.
Save chill-cod3r/6efea2f71804e509f615321ba188f046 to your computer and use it in GitHub Desktop.
FROM node:10-alpine AS build
# install gyp tools
# if you have an npm dependency that depends on native code
# like the redis package, you'll need these tools to compile
# that dependency
RUN apk add --update --no-cache \
python \
make \
g++
ADD . /src
WORKDIR /src
RUN npm install
# RUN npm run lint
# RUN npm run test
RUN npm run build
RUN npm prune --production
FROM node:10-alpine
RUN apk add --update --no-cache curl
ENV PORT=3000
EXPOSE $PORT
ENV DIR=/usr/src/service
WORKDIR $DIR
COPY --from=build /src/package.json package.json
COPY --from=build /src/package-lock.json package-lock.json
COPY --from=build /src/node_modules node_modules
COPY --from=build /src/.next .next
HEALTHCHECK --interval=5s \
--timeout=5s \
--retries=6 \
CMD curl -fs http://localhost:$PORT/_health || exit 1
CMD ["npm", "run", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment