-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
68 lines (50 loc) · 1.76 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Two stage build
# Stage 1: builder image
FROM registry.access.redhat.com/ubi9/nodejs-16 AS builder
## Add application sources
ADD . $HOME
## Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi
# Stage 2: deployment image
## 1. Unversial Base Image (UBI)
FROM registry.access.redhat.com/ubi9/nodejs-16-minimal
## 2. Non-root, arbitrary user IDs
USER 1001
## 3. Image identification
LABEL name="jeremycaine/hello-word" \
vendor="Acme, Inc." \
version="1.2.3" \
release="45" \
summary="hello world web application" \
description="This application says hello world."
USER root
## 4. Image license
## Red Hat requires that the image store the license file(s) in the /licenses directory.
## Store the license in the image to self-document
COPY ./licenses /licenses
## 5. Latest security updates
## RUN dnf -y update-minimal --security --sec-severity=Important --sec-severity=Critical && \
## dnf clean all
## on minimal UBI images use microdnf
RUN microdnf -y upgrade && \
microdnf clean all
## 6. Group ownership and file permission
RUN chgrp -R 0 $HOME && \
chmod -R g=u $HOME
USER 1001
RUN chown -R 1001:0 $HOME
## 7. Application source
## Copy the application source and build artifacts from the builder image to this one
COPY --from=builder $HOME $HOME
## Set environment environment variables and expose port
ENV NODE_ENV production
ENV PORT 3000
EXPOSE 3000
## Run script uses standard ways to run the application
CMD npm run -d start