-
-
Notifications
You must be signed in to change notification settings - Fork 385
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (29 loc) · 1.15 KB
/
Dockerfile
File metadata and controls
47 lines (29 loc) · 1.15 KB
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
# Start with first build stage
FROM node:24-alpine AS build
ENV NODE_ENV=production
# Add and set non-root user. Disable the password and do not create a home folder.
RUN [ "adduser", "-D", "ackee", "ackee" ]
USER ackee
WORKDIR /srv/app/
# Add dependencies first so that Docker can use the cache as long as the dependencies stay unchanged
COPY package.json package-lock.json /srv/app/
RUN [ "npm", "ci" ]
# Copy source after the dependency step as it's more likely that the source changes
COPY build.js /srv/app/
COPY src /srv/app/src
COPY dist /srv/app/dist
# Start with second build stage
FROM node:24-alpine
EXPOSE 3000
WORKDIR /srv/app/
# Copy the source from the build stage to the second stage
COPY --from=build /srv/app/ /srv/app/
# Create user/group to run as, change ownership of files and set user
RUN [ "adduser", "-D", "ackee", "ackee" ]
RUN [ "chown", "-R", "ackee:ackee", "/srv/app" ]
USER ackee
# Run healthcheck against MongoDB, server and API.
# Wait a bit before start to ensure the build is done.
HEALTHCHECK --interval=1m --timeout=45s --start-period=45s CMD [ "npm", "run", "healthcheck" ]
# Start Ackee
CMD [ "npm", "run", "start" ]