forked from smartiniOnGitHub/fastify-healthcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.example
executable file
·35 lines (25 loc) · 1.02 KB
/
Dockerfile.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
FROM node:14-slim
LABEL version="1.0.0"
LABEL description="Example Fastify (Node.js) Docker Image"
LABEL maintainer "Sandro Martini <sandro.martini@gmail.com>"
RUN mkdir -p /work
WORKDIR /work
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
# ENV NODE_ENV production
# to be able to run tests (for example in CI), do not set production as environment
ENV NPM_CONFIG_LOGLEVEL warn
# copy project definition/dependencies files, for better reuse of layers
COPY ./package*.json ./$WORKDIR
# install dependencies here, for better reuse of layers
RUN npm install
# RUN npm install --only=production
# copy all sources in the container (exclusions in .dockerignore file)
COPY . $WORKDIR
EXPOSE 3000
# add an healthcheck, useful
# healthcheck with curl, but not recommended
# HEALTHCHECK CMD curl --fail http://localhost:3000/health || exit 1
# healthcheck by calling the additional script exposed by the plugin
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD npm start
CMD [ "npm", "run", "example" ]