generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* frontend dockerized * run nginx as unprivileged user * bump node to bugfix version 20.15.1, as per Chainguard requirement * add Dockerfile * re-add run.container.sh script * update dpendabot to include Dockerfile in updates * resolve new CVE in glibc * update nginx.conf --------- Co-authored-by: Joseph Andersen <[email protected]>
- Loading branch information
1 parent
130f09b
commit dddd6f4
Showing
7 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.dockerignore | ||
*.sh | ||
build | ||
Dockerfile* | ||
node_modules | ||
node_modules | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.15 | ||
20.15.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Start with the latest version of hardened builder image | ||
FROM cgr.dev/chainguard/wolfi-base:latest AS builder | ||
|
||
# Install required dependencies | ||
RUN apk add --no-cache bash curl git ca-certificates libstdc++ coreutils && \ | ||
update-ca-certificates && \ | ||
touch ~/.bash_profile | ||
|
||
# Get desired Node.js version and install it | ||
COPY .nvmrc /tmp/.nvmrc | ||
RUN export NODE_VERSION=$(cat /tmp/.nvmrc | tr -d '[:space:]') && \ | ||
ARCH=$(uname -m) && \ | ||
echo $ARCH && \ | ||
case $ARCH in \ | ||
x86_64) ARCH_NAME="x64";; \ | ||
aarch64) ARCH_NAME="arm64";; \ | ||
*) echo "Unsupported architecture: $ARCH" && exit 1;; \ | ||
esac && \ | ||
echo "Architecture: $ARCH_NAME" && \ | ||
PLATFORM_ARCH="linux-${ARCH_NAME}" && \ | ||
echo "Platform architecture: $PLATFORM_ARCH https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-${PLATFORM_ARCH}.tar.gz" && \ | ||
echo "Installing Node.js version: ${NODE_VERSION} for $ARCH_NAME" && \ | ||
DOWNLOAD_URL="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-${PLATFORM_ARCH}.tar.gz" && \ | ||
echo "Downloading from: $DOWNLOAD_URL" && \ | ||
curl -fsSL --retry 3 "$DOWNLOAD_URL" -o /tmp/node.tar.gz && \ | ||
tar -xzf /tmp/node.tar.gz -C /usr/local --strip-components=1 && \ | ||
rm /tmp/node.tar.gz /tmp/.nvmrc && \ | ||
echo -n "Node.js installed version: " && node -v && \ | ||
echo -n "npm installed version: " && npm -v && \ | ||
apk del glibc # Remove glibc package to resolve CVE CVE-2025-0395 | ||
|
||
|
||
# Install yarn and resolve vulnerability in cross-spawn, by upgrading it to a version with resolved CVE | ||
# Newly found CVEs can be resolved in similar manner - by upgrading to the closest fixed version | ||
RUN apk add --no-cache yarn && \ | ||
npm install -g [email protected] | ||
# Extract Node.js version from the image | ||
SHELL ["/bin/ash", "-o", "pipefail", "-c"] | ||
RUN node --version | awk -F'v' '{print $2}' | ||
WORKDIR /app | ||
# Prep package manager as root and drop privileges | ||
USER root | ||
COPY --chown=nonroot . . | ||
RUN chown nonroot:nonroot ./ && npm install -g corepack | ||
# Run install/buiuld as unprivileged user | ||
USER nonroot | ||
RUN yarn install --immutable && yarn build:production | ||
|
||
# Web server stage | ||
# This image runs as a unprivileged user by default, so there's no need to explicitly set user - see the Note block in the link below for more context | ||
# https://edu.chainguard.dev/chainguard/chainguard-images/getting-started/nginx/#advanced-usage | ||
FROM cgr.dev/chainguard/nginx AS server | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
COPY --from=builder /app/build /usr/share/nginx/html | ||
EXPOSE 8080 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pid /var/run/nginx.pid; | ||
|
||
http { | ||
include mime.types; | ||
|
||
server { | ||
listen 8080; | ||
server_name localhost; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
try_files $uri /index.html; # Pass all non-files to our react app | ||
} | ||
} | ||
} | ||
|
||
events {} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker build . --build-arg NODE_VERSION=$(cat .nvmrc) -t rs-frontend:latest |