From c7ba6a537e5396ffbd7fffa4ece3037536ddcfb6 Mon Sep 17 00:00:00 2001 From: Christopher Horrell Date: Mon, 9 Feb 2026 18:00:47 -0500 Subject: [PATCH 1/2] Optimize Docker image size with multi-stage build Use multi-stage build with minimal Alpine base to reduce image size from 227MB to 187MB. Copy only Node binary, required libraries, and the json package to runtime stage, eliminating npm and unnecessary Node.js tooling. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- Dockerfile | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0cc4e50..86732c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,27 @@ # syntax=docker/dockerfile:1 -FROM node:lts-alpine3.23 -LABEL org.opencontainers.image.source=https://github.com/chorrell/docker-json +# Build stage - install dependencies +FROM node:lts-alpine3.23 AS builder ARG MAJOR_VERSION=11 RUN set -ex \ && npm install -g json@^$MAJOR_VERSION.0.0 -COPY --link docker-entrypoint.sh /usr/local/bin/ +# Minimal runtime stage - use alpine base and copy only Node binary +FROM alpine:3.23 + +LABEL org.opencontainers.image.source=https://github.com/chorrell/docker-json + +# Copy only the Node binary and essential libraries from builder +COPY --from=builder /usr/local/bin/node /usr/local/bin/node +COPY --from=builder /usr/lib/libstdc++.so.6 /usr/lib/libstdc++.so.6 +COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/libgcc_s.so.1 + +# Copy only the json package (no dependencies) +COPY --from=builder /usr/local/lib/node_modules/json /usr/local/lib/node_modules/json -ENTRYPOINT ["docker-entrypoint.sh"] +# Use node to run json.js directly +ENTRYPOINT ["/usr/local/bin/node", "/usr/local/lib/node_modules/json/lib/json.js"] CMD ["--version"] From 1411a4657f77606a8cc134c16d9a1a6b238cca0d Mon Sep 17 00:00:00 2001 From: Christopher Horrell Date: Mon, 9 Feb 2026 18:06:09 -0500 Subject: [PATCH 2/2] Remove shellcheck workflow and docker-entrypoint.sh These are no longer needed as the optimized image runs Node directly without shell script wrappers. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .github/workflows/shellcheck.yml | 18 ------------------ docker-entrypoint.sh | 8 -------- 2 files changed, 26 deletions(-) delete mode 100644 .github/workflows/shellcheck.yml delete mode 100755 docker-entrypoint.sh diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml deleted file mode 100644 index 91e77ef..0000000 --- a/.github/workflows/shellcheck.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Check Shell scripts - -on: - pull_request: - -jobs: - shfmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - run: docker run --rm -v "$(pwd)":/sh -w /sh mvdan/shfmt:v3.1.1 -sr -i 2 -l -w -ci . - - run: git diff --color --exit-code - - shellcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - run: shellcheck *.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100755 index b8c6270..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then - set -- json "$@" -fi - -exec "$@"