-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (36 loc) · 1.49 KB
/
Dockerfile
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#Docker instructions necessary for Docker Engine to build the image
FROM node:18.17.0-alpine3.17@sha256:e0641d0ac1f49f045c8dc05bbedc066fc7c88bc2730ead423088eeb0788623a1
LABEL maintainer="Maria Dmytrenko"
LABEL description="Fragments node.js microservice"
# We default to use port 8080 in our service
ENV PORT=8080
# Reduce npm spam when installing within Docker
# https://docs.npmjs.com/cli/v8/using-npm/config#loglevel
ENV NPM_CONFIG_LOGLEVEL=warn
# Disable colour when run inside Docker
# https://docs.npmjs.com/cli/v8/using-npm/config#color
ENV NPM_CONFIG_COLOR=false
# Use /app as our working directory
WORKDIR /app
# Copies the package.json and package-lock.json files into the working dir (./app)
COPY package.json package-lock.json ./
# Install node dependencies defined in package-lock.json
# Install tini to handle signals (terminate container, etc)
RUN npm ci --production && \
apk add --no-cache tini=0.19.0-r1
# Copy src to /app/src/
COPY ./src ./src
# Copy our HTPASSWD file
COPY ./tests/.htpasswd ./tests/.htpasswd
#changing the ownership of the files to node user
COPY --chown=node:node . /app
#changing the user to a less privileged user
USER node
# Use tini to handle signals (terminate container, etc)
ENTRYPOINT ["tini", "--"]
# Start the container by running our server
CMD ["node", "src/server.js"]
# Run service on port 8080
EXPOSE 8080
HEALTHCHECK --interval=3m --retries=3 \
CMD curl --fail http://localhost:${PORT}/ || exit 1