From 036574ec035d8425b40cb1506fa2d6753f462dea Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 14 Dec 2023 17:17:42 -0600 Subject: [PATCH 1/4] Reduce image size --- .../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 -- 2.45.2 From 95652f9c27494d037a77ad2a05912f00b3187e82 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 14 Dec 2023 17:34:52 -0600 Subject: [PATCH 2/4] --omit=dev --- .../cerc-nextjs-base/scripts/build-app.sh | 9 +++++++++ 1 file changed, 9 insertions(+) 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 759ba255..8c11e83b 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 @@ -136,4 +136,13 @@ fi $CERC_BUILD_TOOL run cerc_compile || exit 1 +case $CERC_BUILD_TOOL in + yarn) + yarn install --production --frozen-lockfile --force + ;; + npm) + npm prune --omit=dev + ;; +esac + exit 0 -- 2.45.2 From 1be612bd17737cb68fbd77d68a1492ed7afa1990 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 14 Dec 2023 17:41:11 -0600 Subject: [PATCH 3/4] Pruning doesn't work. --- .../cerc-nextjs-base/scripts/build-app.sh | 9 --------- 1 file changed, 9 deletions(-) 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 8c11e83b..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 @@ -136,13 +136,4 @@ fi $CERC_BUILD_TOOL run cerc_compile || exit 1 -case $CERC_BUILD_TOOL in - yarn) - yarn install --production --frozen-lockfile --force - ;; - npm) - npm prune --omit=dev - ;; -esac - exit 0 -- 2.45.2 From 639d14400fe8efcd23c012b3e678867abc4e352f Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 14 Dec 2023 19:44:47 -0600 Subject: [PATCH 4/4] Fix for hanging next generate --- .../cerc-nextjs-base/scripts/start-serving-app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh index bf35bcdb..3692f2f6 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh @@ -42,7 +42,7 @@ if [ "$CERC_NEXTJS_SKIP_GENERATE" != "true" ]; then while [ $count -lt $CERC_MAX_GENERATE_TIME ] && [ "$generate_done" == "false" ]; do sleep 1 count=$((count + 1)) - grep 'rendered as static HTML' gen.out > /dev/null + grep 'rendered as static' gen.out > /dev/null if [ $? -eq 0 ]; then generate_done="true" fi -- 2.45.2