-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
48 lines (40 loc) · 1.42 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
###########################################################
# Stage: base
#
# This stage serves as the base for all of the other stages.
# By using this stage, it provides a consistent base for both
# the dev and prod versions of the image.
###########################################################
FROM node:22-slim AS base
# Remove npm to resolve a currently known and fixable vulnerability
RUN npm uninstall npm -g
# Setup a non-root user to run the app
WORKDIR /usr/local/app
RUN useradd -m appuser && chown -R appuser /usr/local/app
USER appuser
###########################################################
# Stage: dev
#
# This stage is used to run the application in a development
# environment. It installs all app dependencies and will
# start the app in a mode that will watch for file changes
# and automatically restart the app.
###########################################################
FROM base AS dev
ENV NODE_ENV=development
COPY package.json yarn.lock ./
RUN yarn install
CMD ["yarn", "dev-container"]
###########################################################
# Stage: final
#
# This stage serves as the final image for production. It
# installs only the production dependencies.
###########################################################
FROM base AS final
ENV NODE_ENV=production
COPY package.json yarn.lock ./
RUN yarn install && yarn cache clean --force
COPY ./src ./src
EXPOSE 3000
CMD [ "node", "src/index.js" ]