From 61f288450594a833b54bdb88d96fb8230829f70b Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 14 Dec 2023 17:46:03 -0600 Subject: [PATCH] Reduce base image size (first round of improvements) (#690) --- .../data/container-build/cerc-nextjs-base/Dockerfile | 4 ++-- .../container-build/cerc-nextjs-base/scripts/build-app.sh | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile b/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile index d3ff3f1b..8949c4e9 100644 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile @@ -1,6 +1,6 @@ # Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile # [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster -ARG VARIANT=20-bullseye +ARG VARIANT=20-bullseye-slim FROM node:${VARIANT} ARG USERNAME=node @@ -30,7 +30,7 @@ RUN \ # [Optional] Uncomment this section to install additional OS packages. RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends jq gettext-base moreutils + && apt-get -y install --no-install-recommends jq gettext-base # [Optional] Uncomment if you want to install more global node modules # RUN su node -c "npm install -g " diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh index ef6244cf..759ba255 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh @@ -104,7 +104,8 @@ CUR_NEXT_VERSION="`jq -r '.dependencies.next' package.json`" if [ "$CERC_NEXT_VERSION" != "keep" ] && [ "$CUR_NEXT_VERSION" != "$CERC_NEXT_VERSION" ]; then echo "Changing 'next' version specifier from '$CUR_NEXT_VERSION' to '$CERC_NEXT_VERSION' (set with '--extra-build-args \"--build-arg CERC_NEXT_VERSION=$CERC_NEXT_VERSION\"')" - cat package.json | jq ".dependencies.next = \"$CERC_NEXT_VERSION\"" | sponge package.json + cat package.json | jq ".dependencies.next = \"$CERC_NEXT_VERSION\"" > package.json.$$ + mv package.json.$$ package.json fi $CERC_BUILD_TOOL install || exit 1 @@ -128,7 +129,8 @@ to use for the build with: ############################################################################### EOF - cat package.json | jq ".dependencies.next = \"^$CERC_MIN_NEXTVER\"" | sponge package.json + cat package.json | jq ".dependencies.next = \"^$CERC_MIN_NEXTVER\"" > package.json.$$ + mv package.json.$$ package.json $CERC_BUILD_TOOL install || exit 1 fi