From 220913ca6b2efd6592f75cf9be02369335072a7a Mon Sep 17 00:00:00 2001 From: brooke Date: Tue, 4 Jun 2024 21:44:15 -0400 Subject: [PATCH 1/7] inital alpine setup --- .github/workflows/build.yml | 8 ++++---- Dockerfile | 18 ++++++++---------- README.md | 8 +++++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 042907f..fab8843 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build And Publish Docker on: push: branches: - - "master" + - "alpine" jobs: build: @@ -12,7 +12,7 @@ jobs: strategy: matrix: hugo-version: ["0.126.3"] - node-version: ["22"] + node-version: ["22.2.0"] go-version: ["1.22.3"] steps: @@ -50,5 +50,5 @@ jobs: NODE_VERSION=${{ matrix.node-version }} GO_VERSION=${{ matrix.go-version }} tags: | - git.myco.systems/mycosystems/hugo-ci:extended-${{ matrix.hugo-version }}-${{ matrix.node-version }}-${{ matrix.go-version }} - git.myco.systems/mycosystems/hugo-ci:extended-latest + git.myco.systems/mycosystems/hugo-ci:extended-alpine-${{ matrix.hugo-version }}-${{ matrix.node-version }}-${{ matrix.go-version }} + git.myco.systems/mycosystems/hugo-ci:extended-alpine-latest diff --git a/Dockerfile b/Dockerfile index dad14a0..a2f0ffa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,22 @@ ARG GO_VERSION="1.22.3" -FROM golang:${GO_VERSION}-bullseye +FROM golang:${GO_VERSION}-alpine3.20 ARG HUGO_VERSION="0.126.3" -ARG NODE_VERSION="22" +ARG NODE_VERSION="22.2.0" -RUN apt update -y -RUN apt install tar gzip build-essential ca-certificates curl gnupg -y -RUN mkdir -p /etc/apt/keyrings -RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg -RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list -RUN apt update -y && apt-get install -y nodejs -RUN npm i -g yarn pnpm +RUN apk update +RUN apk add tar gzip curl rsync RUN mkdir /tmp/temph RUN mkdir /home/app WORKDIR /tmp/temph +RUN wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz \ + && tar -xf node-v${NODE_VERSION}-linux-x64.tar.xz +RUN cp -R node-v${NODE_VERSION}-linux-x64/bin/* /usr/bin/ +RUN npm i -g yarn pnpm RUN wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" RUN tar xf "hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" RUN mv ./hugo /usr/bin/hugo WORKDIR /home/app -# Cleanup RUN rm -rfv /tmp/temph ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file diff --git a/README.md b/README.md index fb46cc0..af59cb3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Hugo Extended CI Container -Contains NodeJS, yarn, pnpm, npm +Based on golang:`go version`-alpine + +Contains nodejs, yarn, pnpm, npm Specific tag versions follow this definition: extended-`hugo version`-`node vesion`-`go vesion` @@ -10,7 +12,7 @@ eg. git.myco.systems/mycosystems/hugo-ci:extended-0.126.3-22-1.22.3 ``` -# To use +## To use Run the following in your hugo directory: ``` @@ -21,7 +23,7 @@ To also host locally: docker run -p 1313:1313 -v .:/home/app -ti --network=host git.myco.systems/mycosystems/hugo-ci:extended-latest ``` -# Links +## Links ~~[Docker](https://hub.docker.com/r/betterweb/hugo)~~ ~~[Github](https://github.com/BetterCorp/hugo)~~ -- 2.45.3 From 0b4585947d8b102f3861a8a9fedbc3897796544d Mon Sep 17 00:00:00 2001 From: brooke Date: Tue, 4 Jun 2024 21:59:21 -0400 Subject: [PATCH 2/7] swap entrypoint, swap runner container --- .github/workflows/build.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fab8843..2b00d30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-22.04 + runs-on: debian-bookworm strategy: matrix: diff --git a/Dockerfile b/Dockerfile index a2f0ffa..0e3d3ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,4 +19,4 @@ RUN mv ./hugo /usr/bin/hugo WORKDIR /home/app RUN rm -rfv /tmp/temph -ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file +ENTRYPOINT [ "/bin/sh" ] \ No newline at end of file -- 2.45.3 From 490ace62373839d3f676e218149737cab082a28b Mon Sep 17 00:00:00 2001 From: brooke Date: Tue, 4 Jun 2024 22:08:29 -0400 Subject: [PATCH 3/7] syntax fix --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0e3d3ba..127ddd4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,14 +9,13 @@ RUN apk add tar gzip curl rsync RUN mkdir /tmp/temph RUN mkdir /home/app WORKDIR /tmp/temph -RUN wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz \ - && tar -xf node-v${NODE_VERSION}-linux-x64.tar.xz +RUN wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz && tar -xf node-v${NODE_VERSION}-linux-x64.tar.xz RUN cp -R node-v${NODE_VERSION}-linux-x64/bin/* /usr/bin/ RUN npm i -g yarn pnpm RUN wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" -RUN tar xf "hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" +RUN tar -xf "hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" RUN mv ./hugo /usr/bin/hugo WORKDIR /home/app -RUN rm -rfv /tmp/temph +RUN rm -rfv /tmp/temph -ENTRYPOINT [ "/bin/sh" ] \ No newline at end of file +ENTRYPOINT [ "/bin/sh" ] -- 2.45.3 From 5211e564d502de3187fe1ead78c0c90d33809c85 Mon Sep 17 00:00:00 2001 From: brooke Date: Tue, 4 Jun 2024 23:36:18 -0400 Subject: [PATCH 4/7] update --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 127ddd4..ed5d1ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,8 @@ RUN apk add tar gzip curl rsync RUN mkdir /tmp/temph RUN mkdir /home/app WORKDIR /tmp/temph -RUN wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz && tar -xf node-v${NODE_VERSION}-linux-x64.tar.xz +RUN wget "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" +RUN tar -xf "node-v${NODE_VERSION}-linux-x64.tar.xz" RUN cp -R node-v${NODE_VERSION}-linux-x64/bin/* /usr/bin/ RUN npm i -g yarn pnpm RUN wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" -- 2.45.3 From 5233735c7120a6bc42f4a9d1a8cfc48f29a2c7ff Mon Sep 17 00:00:00 2001 From: brooke Date: Tue, 4 Jun 2024 23:53:11 -0400 Subject: [PATCH 5/7] fix tar error --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ed5d1ac..a35d556 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ARG HUGO_VERSION="0.126.3" ARG NODE_VERSION="22.2.0" RUN apk update -RUN apk add tar gzip curl rsync +RUN apk add tar gzip curl rsync bash xz RUN mkdir /tmp/temph RUN mkdir /home/app WORKDIR /tmp/temph @@ -19,4 +19,4 @@ RUN mv ./hugo /usr/bin/hugo WORKDIR /home/app RUN rm -rfv /tmp/temph -ENTRYPOINT [ "/bin/sh" ] +ENTRYPOINT [ "/bin/bash" ] -- 2.45.3 From ca6261ae29f9f621e7bc9dfbf3fb5e4a1e4e5d57 Mon Sep 17 00:00:00 2001 From: brooke Date: Fri, 7 Jun 2024 04:22:22 -0400 Subject: [PATCH 6/7] build both hugo and nodejs in an alpine container, bump hugo to 127, remove go, start work on building nodejs from scratch using optimized build options --- {.github => .forgejo}/workflows/build.yml | 11 +++--- Dockerfile | 46 ++++++++++++++--------- Dockerfile.multistage | 30 +++++++++++++++ README.md | 8 ++-- 4 files changed, 69 insertions(+), 26 deletions(-) rename {.github => .forgejo}/workflows/build.yml (90%) create mode 100644 Dockerfile.multistage diff --git a/.github/workflows/build.yml b/.forgejo/workflows/build.yml similarity index 90% rename from .github/workflows/build.yml rename to .forgejo/workflows/build.yml index 2b00d30..80cced9 100644 --- a/.github/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -3,17 +3,16 @@ name: Build And Publish Docker on: push: branches: - - "alpine" + - "master" jobs: build: runs-on: debian-bookworm - strategy: - matrix: - hugo-version: ["0.126.3"] - node-version: ["22.2.0"] - go-version: ["1.22.3"] + strategy: + matrix: + hugo-version: ["0.127.0", "0.126.0", "0.125.0"] + node-version: ["22"] steps: - uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index a35d556..db46ade 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,34 @@ -ARG GO_VERSION="1.22.3" -FROM golang:${GO_VERSION}-alpine3.20 +FROM alpine:3.20 +ARG HUGO_VERSION="0.127.0" +ARG NODE_VERSION="22" -ARG HUGO_VERSION="0.126.3" -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++ + +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 + +# 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 -RUN apk update -RUN apk add tar gzip curl rsync bash xz -RUN mkdir /tmp/temph RUN mkdir /home/app -WORKDIR /tmp/temph -RUN wget "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" -RUN tar -xf "node-v${NODE_VERSION}-linux-x64.tar.xz" -RUN cp -R node-v${NODE_VERSION}-linux-x64/bin/* /usr/bin/ -RUN npm i -g yarn pnpm -RUN wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" -RUN tar -xf "hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz" -RUN mv ./hugo /usr/bin/hugo WORKDIR /home/app -RUN rm -rfv /tmp/temph -ENTRYPOINT [ "/bin/bash" ] +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 new file mode 100644 index 0000000..a3db543 --- /dev/null +++ b/Dockerfile.multistage @@ -0,0 +1,30 @@ +# 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 af59cb3..dffac67 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ docker run -p 1313:1313 -v .:/home/app -ti --network=host git.myco.systems/mycos ## Links -~~[Docker](https://hub.docker.com/r/betterweb/hugo)~~ -~~[Github](https://github.com/BetterCorp/hugo)~~ -[MycoSystems Packages](https://git.myco.systems/mycosystems/-/packages/container/hugo-ci/versions) \ No newline at end of file +- ~~[BetterWeb Docker](https://hub.docker.com/r/betterweb/hugo)~~ + +- ~~[BeterCorp Github](https://github.com/BetterCorp/hugo)~~ + +- [MycoSystems Packages](https://git.myco.systems/mycosystems/-/packages/container/hugo-ci/versions) \ No newline at end of file -- 2.45.3 From f8c661229f23fb22796c9200480733355eb77263 Mon Sep 17 00:00:00 2001 From: brooke Date: Fri, 7 Jun 2024 17:25:46 -0400 Subject: [PATCH 7/7] 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` -- 2.45.3