-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 869 Bytes
/
Dockerfile
File metadata and controls
36 lines (25 loc) · 869 Bytes
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
FROM node:22-bookworm-slim
# Set up directories in advance so we can control the permissions
RUN mkdir -p /usr/app/bin && mkdir -p /usr/app/node_modules && chown -R node:node /usr/app
# Set the work directory
WORKDIR /usr/app
# Set the user
USER node
## Dependencies are handled in their own layer so that we can leverage layer cache and save time on rebuild
# Copy over the dependencies
COPY --chown=node:node package.json .
COPY --chown=node:node yarn.lock .
# Install the dependencies
RUN yarn install --frozen-lockfile
# Copy over application files
COPY --chown=node:node . .
# Set ARGs and ENV vars
ARG BUILD_VERSION
ARG ENV
ENV ENV=${ENV}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV NODE_ENV=${ENV}
# If this is a prod environment, package the code
RUN if [ "$ENV" != "local" ]; then node --run build; fi
# Start the service
CMD ["bash", "./start-service"]