From 76dbd843f4b3360821153df1685914ba08682e07 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 18 Dec 2024 00:21:50 -0800 Subject: [PATCH] Fix nightly docker image (#1590) * Fix nightly docker image * fix path to release binary * Update Dockerfile to support both latest and nightly Also supports dedicated release names like `lychee-v0.17.0` now. It can be built locally with ``` docker build --build-arg LYCHEE_VERSION=latest -f Dockerfile-CI.Dockerfile . ``` --------- Co-authored-by: Matthias --- .github/workflows/docker.yml | 4 ++++ Dockerfile-CI.Dockerfile | 30 +++++++++++++++++------------- Dockerfile-CI.alpine.Dockerfile | 23 +++++++++++++---------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7370478..ae2c1fb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -99,6 +99,8 @@ jobs: startsWith(github.ref, 'lychee-v') }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + "LYCHEE_VERSION=${{ github.ref == 'refs/heads/master' && 'nightly' || 'latest' }}" - name: Push Image (alpine) uses: docker/build-push-action@v6 @@ -111,6 +113,8 @@ jobs: startsWith(github.ref, 'lychee-v') }} tags: ${{ steps.meta-alpine.outputs.tags }} labels: ${{ steps.meta-alpine.outputs.labels }} + build-args: | + "LYCHEE_VERSION=${{ github.ref == 'refs/heads/master' && 'nightly' || 'latest' }}" - name: Update DockerHub description uses: peter-evans/dockerhub-description@v4 diff --git a/Dockerfile-CI.Dockerfile b/Dockerfile-CI.Dockerfile index 5d85767..be05490 100644 --- a/Dockerfile-CI.Dockerfile +++ b/Dockerfile-CI.Dockerfile @@ -1,20 +1,24 @@ FROM debian:bookworm-slim AS builder WORKDIR /builder +ARG LYCHEE_VERSION="latest" + RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - --no-install-recommends \ - ca-certificates \ - jq \ - wget \ - && case $(dpkg --print-architecture) in \ - "amd64") \ - wget -q -O - https://github.com/lycheeverse/lychee/releases/latest/download/lychee-x86_64-unknown-linux-gnu.tar.gz | tar -xz lychee \ - ;; \ - "arm64") \ - wget -q -O - https://github.com/lycheeverse/lychee/releases/latest/download/lychee-aarch64-unknown-linux-gnu.tar.gz | tar -xz lychee \ - ;; \ - esac \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates \ + jq \ + wget \ + && rm -rf /var/lib/apt/lists/* \ + && ARCH=$(case $(dpkg --print-architecture) in \ + "amd64") echo "x86_64";; \ + "arm64") echo "aarch64";; \ + *) echo "Unsupported architecture" && exit 1;; \ + esac) \ + && BASE_URL=$(case $LYCHEE_VERSION in \ + "latest") echo "https://github.com/lycheeverse/lychee/releases/latest/download";; \ + *) echo "https://github.com/lycheeverse/lychee/releases/download/$LYCHEE_VERSION";; \ + esac) \ + && wget -q -O - "$BASE_URL/lychee-$ARCH-unknown-linux-gnu.tar.gz" | tar -xz lychee \ && chmod +x lychee FROM debian:bookworm-slim diff --git a/Dockerfile-CI.alpine.Dockerfile b/Dockerfile-CI.alpine.Dockerfile index c82db4b..9c12df3 100644 --- a/Dockerfile-CI.alpine.Dockerfile +++ b/Dockerfile-CI.alpine.Dockerfile @@ -1,16 +1,19 @@ FROM alpine:latest AS builder WORKDIR /builder -RUN apk update \ - && apk add --no-cache ca-certificates jq wget \ - && case $(arch) in \ - "x86_64") \ - wget -4 -q -O - https://github.com/lycheeverse/lychee/releases/latest/download/lychee-x86_64-unknown-linux-musl.tar.gz | tar -xz lychee \ - ;; \ - "aarch64") \ - wget -4 -q -O - https://github.com/lycheeverse/lychee/releases/latest/download/lychee-arm-unknown-linux-musleabihf.tar.gz | tar -xz lychee \ - ;; \ - esac \ +ARG LYCHEE_VERSION="latest" + +RUN apk add --no-cache ca-certificates jq wget \ + && ARCH=$(case $(arch) in \ + "x86_64") echo "x86_64-unknown-linux-musl";; \ + "aarch64") echo "arm-unknown-linux-musleabihf";; \ + *) echo "Unsupported architecture" && exit 1;; \ + esac) \ + && BASE_URL=$(case $LYCHEE_VERSION in \ + "latest") echo "https://github.com/lycheeverse/lychee/releases/latest/download";; \ + *) echo "https://github.com/lycheeverse/lychee/releases/download/$LYCHEE_VERSION";; \ + esac) \ + && wget -4 -q -O - "$BASE_URL/lychee-$ARCH.tar.gz" | tar -xz lychee \ && chmod +x lychee FROM alpine:latest