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
Some checks failed
Build And Publish Docker / build (push) Failing after -1s
Build And Publish Docker / strategy (push) Failing after 1m39s

This commit is contained in:
brooke 2024-06-07 17:25:46 -04:00
parent ca6261ae29
commit f8c661229f
4 changed files with 43 additions and 49 deletions

View file

@ -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:

View file

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

View file

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

View file

@ -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`