diff --git a/.justfile b/.justfile index 89e362b..dbb1a6e 100644 --- a/.justfile +++ b/.justfile @@ -15,7 +15,7 @@ # Build image with local docker daemon. @build: - docker build . --tag=kokuwaio/markdownlint:dev --load + docker build . --tag=kokuwaio/markdownlint:dev --build-arg=NPM_CONFIG_REGISTRY --load # Inspect image with docker. @inspect: build diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index cb1ff39..9ea4b47 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -15,6 +15,7 @@ steps: registry.kokuwa.io: username: {from_secret: kokuwa_io_username} password: {from_secret: kokuwa_io_password} + build-args: {NPM_CONFIG_REGISTRY: "${NPM_CONFIG_REGISTRY}"} platform: [linux/amd64, linux/arm64] annotation: org.opencontainers.image.title: Markdownlint WoodpeckerCI Plugin diff --git a/Dockerfile b/Dockerfile index ba1dc0f..4174c92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,23 +39,21 @@ RUN --mount=type=cache,target=/build \ "https://nodejs.org/download/release/v22.16.0/SHASUMS256.txt.sig" && \ sha256sum --quiet --check --strict --ignore-missing SHASUMS256.txt && \ gpg --verify SHASUMS256.txt.sig SHASUMS256.txt 2>/dev/null && \ - tar --xz --extract --file="node-v22.16.0-linux-$SUFFIX.tar.xz" --exclude=include --exclude=share && \ + tar --xz --extract --file="node-v22.16.0-linux-$SUFFIX.tar.xz" --exclude=bin/npx --exclude=bin/corepack --exclude=lib/node_modules/corepack --exclude=include --exclude=share --no-same-owner && \ mv "node-v22.16.0-linux-$SUFFIX" /opt/node -ENV PATH="$PATH:/opt/node/bin" -# https://github.com/igorshubovych/markdownlint-cli/releases - -RUN --mount=type=tmpfs,target=/root/.npm /opt/node/bin/npm install "markdownlint-cli@0.42.0" --global --no-fund +ARG NPM_CONFIG_REGISTRY +RUN --mount=type=tmpfs,target=/tmp PATH="$PATH:/opt/node/bin" npm install "markdownlint-cli@0.42.0" --global --no-fund --cache=/tmp ## ## Final stage ## FROM docker.io/library/debian:12.11-slim@sha256:e5865e6858dacc255bead044a7f2d0ad8c362433cfaa5acefb670c1edf54dfef -COPY --chmod=555 --from=build /opt/node/bin/node /opt/node/bin/node -COPY --chmod=555 --from=build /opt/node/bin/markdownlint /opt/node/bin/markdownlint +COPY --chmod=555 --from=build /opt/node/bin/node /opt/node/bin/ COPY --from=build /opt/node/lib/node_modules/markdownlint-cli /opt/node/lib/node_modules/markdownlint-cli COPY --chmod=555 entrypoint.sh /usr/local/bin/entrypoint.sh -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] ENV PATH="$PATH:/opt/node/bin" +RUN ln -s /opt/node/lib/node_modules/markdownlint-cli/markdownlint.js /opt/node/bin/markdownlint && markdownlint --version +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] USER 1000:1000