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/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"] 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 "$@"