From f8c661229f23fb22796c9200480733355eb77263 Mon Sep 17 00:00:00 2001 From: brooke Date: Fri, 7 Jun 2024 17:25:46 -0400 Subject: [PATCH] got npm build instructions from alpinelinux package build, switch to multi-stage build process, currently wont support yarn or pnpm but may add a second version that does --- .forgejo/workflows/build.yml | 2 +- Dockerfile | 58 +++++++++++++++++++++++++----------- Dockerfile.multistage | 30 ------------------- README.md | 2 +- 4 files changed, 43 insertions(+), 49 deletions(-) delete mode 100644 Dockerfile.multistage diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 80cced9..8d9325e 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - hugo-version: ["0.127.0", "0.126.0", "0.125.0"] + hugo-version: ["0.127.0", "0.126.0"] node-version: ["22"] steps: diff --git a/Dockerfile b/Dockerfile index db46ade..4f153b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ -FROM alpine:3.20 +FROM alpine:3.20 as build ARG HUGO_VERSION="0.127.0" -ARG NODE_VERSION="22" +ARG NODE_VERSION="22.2.0" -RUN apk add --update --no-cache rsync unzip openssh libssl3 openssl-dev curl ninja pkgconf icu-dev git linux-headers libc6-compat make g++ gcc libgcc libstdc++ python3 py3-pip -# RUN apk add --update --no-cache rsync curl openssh git libc6-compatlibgcc libstdc++ +RUN apk add --update --no-cache xz libssl3 ca-certificates openssl-dev curl ninja pkgconf icu-dev git linux-headers libc6-compat make g++ gcc ada-dev brotli-dev c-ares-dev nghttp2-dev python3 samurai zlib-dev py3-pip libuv-dev WORKDIR /tmp @@ -12,23 +11,48 @@ RUN curl -sL -o hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz https://github. cp ./hugo /usr/bin/hugo && \ hugo version -RUN curl -sL -o node-${NODE_VERSION}.x.zip "https://github.com/nodejs/node/archive/refs/heads/v${NODE_VERSION}.x.zip" && unzip "node-${NODE_VERSION}.x.zip" &&\ - cd node-${NODE_VERSION}.x && \ - ./configure --with-intl=system-icu --ninja --shared-openssl --shared && \ - make && \ +RUN curl -sL -o node-v${NODE_VERSION}.tar.xz "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.tar.xz" && \ + tar -xf "node-v${NODE_VERSION}.tar.xz" && \ + cd node-v22.2.0 && \ + ./configure --prefix=/usr \ + --shared-brotli \ + --shared-zlib \ + --shared-libuv \ + --shared-openssl \ + --shared-cares \ + --shared-nghttp2 \ + --ninja \ + --without-npm \ + --with-intl=system-icu \ + --openssl-use-def-ca-store && \ + make BUILDTYPE=Release && \ make install -# RUN curl -fsSL https://unofficial-builds.nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64-musl.tar.gz -o node-v${NODE_VERSION}.tar.gz && \ -# tar -xzf node-v${NODE_VERSION}.tar.gz && \ -# mv /tmp/node-v${NODE_VERSION}-linux-x64-musl /usr/local/lib/nodejs && \ -# ln -s /usr/local/lib/nodejs/bin/node /usr/local/bin/node && \ -# ln -s /usr/local/lib/nodejs/bin/npm /usr/local/bin/npm && \ -# npm i -g yarn pnpm +FROM alpine:3.20 +RUN apk add --update --no-cache \ + brotli \ + zlib \ + libuv \ + openssl \ + c-ares \ + nghttp2 \ + icu \ + ca-certificates \ + libgcc \ + libstdc++ \ + libc6-compat \ + linux-headers \ + rsync \ + openssh \ + npm \ + && rm -rf /var/cache/apk/* + +COPY --from=build /usr/bin/hugo /usr/bin/hugo +COPY --from=build /usr/bin/node /usr/bin/node +COPY --from=build /usr/lib/node_modules /usr/lib/node_modules +COPY --from=build /usr/include/node /usr/include/node RUN mkdir /home/app WORKDIR /home/app -RUN rm -rfv /tmp/* && \ - apk del git linux-headers python3 py3-pip make g++ gcc ninja - ENTRYPOINT [ "/bin/sh" ] \ No newline at end of file diff --git a/Dockerfile.multistage b/Dockerfile.multistage deleted file mode 100644 index a3db543..0000000 --- a/Dockerfile.multistage +++ /dev/null @@ -1,30 +0,0 @@ -# Build stage -FROM alpine:3.20 AS build -ARG HUGO_VERSION="0.127.0" -ARG NODE_VERSION="22" - -RUN apk add --update --no-cache rsync unzip openssh libssl3 openssl-dev curl ninja pkgconf icu-dev git linux-headers libc6-compat make g++ gcc libgcc libstdc++ python3 py3-pip - -WORKDIR /tmp - -RUN curl -sL -o hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz && \ - tar -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" && \ - cp ./hugo /usr/bin/hugo && \ - hugo version - -RUN curl -sL -o node-${NODE_VERSION}.x.zip "https://github.com/nodejs/node/archive/refs/heads/v${NODE_VERSION}.x.zip" && unzip "node-${NODE_VERSION}.x.zip" &&\ - cd node-${NODE_VERSION}.x && \ - ./configure --with-intl=system-icu --ninja --shared-openssl --shared && \ - make && \ - make install - -# Final stage -FROM alpine:3.20 - -RUN apk add --update --no-cache rsync openssh libssl3 openssl-dev libgcc libstdc++ libc6-compat - -COPY --from=build /usr/bin/hugo /usr/bin/hugo -RUN mkdir /home/app -WORKDIR /home/app - -ENTRYPOINT [ "/bin/sh" ] \ No newline at end of file diff --git a/README.md b/README.md index dffac67..3072b20 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Based on golang:`go version`-alpine -Contains nodejs, yarn, pnpm, npm +Contains nodejs, hugo, npm, rsync Specific tag versions follow this definition: extended-`hugo version`-`node vesion`-`go vesion`