Merge pull request #827 from internetarchive/docker-update

Build docker images regularly using github actions
This commit is contained in:
Alex Osborne authored and GitHub committed 2026-11-19 21:09:35 +09:00
commit 9aa8b0bc64
5 files changed
+165 -139

No files matched your search

+117 -9
View File
@@ -1,18 +1,126 @@
name: Docker Image CI
name: Docker images
# Builds and pushes iipc/heritrix images from the release dist tarballs:
# - when a release is published
# - daily, if the base image has changed since the latest release was pushed
# - on demand
on:
release:
types: [published]
schedule:
- cron: '23 3 * * *'
workflow_dispatch:
inputs:
version:
description: Heritrix version (default latest release)
required: false
permissions:
contents: read
on: workflow_dispatch
concurrency: docker-images
env:
IMAGE: iipc/heritrix
jobs:
build:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.vars.outputs.version }}
latest: ${{ steps.vars.outputs.latest }}
base: ${{ steps.vars.outputs.base }}
build: ${{ steps.vars.outputs.build }}
steps:
- uses: actions/checkout@v7
- name: Build the Docker image
run: docker build . --file Dockerfile --tag heritrix:$(date +%s)
working-directory: docker
- id: vars
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
INPUT_VERSION: ${{ inputs.version }}
run: |
latest_release=$(gh release view --json tagName --jq .tagName)
version=${RELEASE_TAG:-${INPUT_VERSION:-$latest_release}}
tag=$(sed -n 's/^ARG java=//p' docker/Dockerfile)
digest=sha256:$(skopeo inspect --raw "docker://docker.io/library/eclipse-temurin:$tag" | sha256sum | cut -d' ' -f1)
base=$tag@$digest
build=true
if [ "$GITHUB_EVENT_NAME" = schedule ]; then
published=$(skopeo inspect --override-os linux --override-arch amd64 "docker://docker.io/$IMAGE:$version" 2>/dev/null |
jq -r '.Labels["org.opencontainers.image.base.name"] // ""' || true)
if [ "$published" = "docker.io/library/eclipse-temurin:$base" ]; then build=false; fi
fi
echo "version $version, base $base, published base ${published:-n/a}, build $build"
{ echo "version=$version"
echo "latest=$([ "$version" = "$latest_release" ] && echo true || echo false)"
echo "base=$base"
echo "build=$build"; } >> "$GITHUB_OUTPUT"
- name: Wait for dist tarballs on the release
if: steps.vars.outputs.build == 'true'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.vars.outputs.version }}
run: |
for _ in $(seq 60); do
assets=$(gh release view "$VERSION" --json assets --jq '.assets[].name')
if grep -qx "heritrix-$VERSION-dist.tar.gz" <<< "$assets" &&
grep -qx "heritrix-contrib-$VERSION-dist.tar.gz" <<< "$assets"; then exit 0; fi
sleep 20
done
echo "dist tarballs not attached to release $VERSION" >&2
exit 1
build:
needs: prepare
if: needs.prepare.outputs.build == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: heritrix
suffix: ''
alias: latest
- target: contrib
suffix: -contrib
alias: contrib
steps:
- uses: actions/checkout@v7
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
- name: Build for smoke test
uses: docker/build-push-action@v7
with:
context: docker
target: ${{ matrix.target }}
build-args: |
version=${{ needs.prepare.outputs.version }}
java=${{ needs.prepare.outputs.base }}
load: true
tags: heritrix-test
- name: Smoke test
run: |
docker run -d --name heritrix -e USERNAME=admin -e PASSWORD=admin -p 8443:8443 heritrix-test
for _ in $(seq 60); do
if curl -sfk --digest -u admin:admin -o /dev/null https://localhost:8443/engine; then exit 0; fi
sleep 2
done
docker logs heritrix
exit 1
- uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: docker
target: ${{ matrix.target }}
build-args: |
version=${{ needs.prepare.outputs.version }}
java=${{ needs.prepare.outputs.base }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE }}:${{ needs.prepare.outputs.version }}${{ matrix.suffix }}
${{ needs.prepare.outputs.latest == 'true' && format('{0}:{1}', env.IMAGE, matrix.alias) || '' }}
+2 -9
View File
@@ -9,15 +9,8 @@
7. Copy release notes from [CHANGELOG.md](CHANGELOG.md) into [Github release](https://github.com/internetarchive/heritrix3/releases)
8. Attach {dist,contrib}/target/*-dist{.tar.gz,.zip} to Github release.
```bash
version=$(git describe --tags --abbrev=0)
version=$(git describe --tags --abbrev=0) &&
gh release upload $version target/checkout/dist/target/heritrix-$version-dist.zip target/checkout/dist/target/heritrix-$version-dist.tar.gz target/checkout/contrib/target/heritrix-contrib-$version-dist.tar.gz
```
9. Build docker images:
```bash
version=$(git describe --tags --abbrev=0)
podman manifest create iipc/heritrix:$version
podman build --build-arg version=$version --platform linux/amd64,linux/arm64 --manifest iipc/heritrix:$version docker
podman manifest push --all iipc/heritrix:$version
podman manifest push --all iipc/heritrix:$version iipc/heritrix:latest
```
9. Check the [Docker images workflow](https://github.com/internetarchive/heritrix3/actions/workflows/docker-image.yml) pushed the docker images. It runs when the release is published and waits for the dist tarballs from the previous step. If it failed, rerun it with `gh workflow run docker-image.yml -f version=$version`.
10. Announce in #heritrix (IIPC Slack)
+42 -48
View File
@@ -1,53 +1,47 @@
ARG java=25
ARG java=25-jre-noble
ARG version=3.19.0
FROM eclipse-temurin:${java}
FROM eclipse-temurin:${java} AS fetch-heritrix
ARG version
ADD https://github.com/internetarchive/heritrix3/releases/download/${version}/heritrix-${version}-dist.tar.gz /tmp/dist.tar.gz
RUN mkdir /opt/heritrix && tar -xzf /tmp/dist.tar.gz -C /opt/heritrix --strip-components=1
ARG version="3.16.0"
ARG user="heritrix"
FROM eclipse-temurin:${java} AS fetch-contrib
ARG version
ARG TARGETARCH
ADD https://github.com/internetarchive/heritrix3/releases/download/${version}/heritrix-contrib-${version}-dist.tar.gz /tmp/dist.tar.gz
RUN mkdir /opt/heritrix && tar -xzf /tmp/dist.tar.gz -C /opt/heritrix --strip-components=1
# yt-dlp for ExtractorYoutubeDL
ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux /tmp/yt-dlp-amd64
ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64 /tmp/yt-dlp-arm64
RUN mv /tmp/yt-dlp-${TARGETARCH} /yt-dlp
FROM eclipse-temurin:${java} AS base
ARG java
ARG version
ARG userid=1001
LABEL version=${version}
LABEL user=${user}/$userid
# create user
RUN \
groupadd -g $userid $user && \
useradd -r -u $userid -g $user $user
# Install dependencies
RUN \
apt-get update && \
apt-get install -y \
wget \
unzip && \
rm -rf /var/lib/apt/lists/*
WORKDIR /opt
# download latest version according to:
# https://github.com/internetarchive/heritrix3/releases/tag/3.10.0
RUN \
wget -O heritrix-${version}-dist.zip https://github.com/internetarchive/heritrix3/releases/download/${version}/heritrix-${version}-dist.zip && \
unzip heritrix-${version}-dist.zip && \
rm heritrix-${version}-dist.zip && \
mv heritrix-${version} heritrix && \
chmod u+x heritrix/bin/heritrix && \
chown -R $user:$user /opt/heritrix
COPY entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh && \
chown $user:$user /opt/entrypoint.sh
WORKDIR /opt/heritrix
USER $user
ENV HERITRIX_HOME /opt/heritrix
# let it run in the foreground, required for docker
ENV FOREGROUND true
# standard webport
# NOTE: that the webpage is via HTTPS only available!
LABEL org.opencontainers.image.title="Heritrix" \
org.opencontainers.image.version="${version}" \
org.opencontainers.image.source="https://github.com/internetarchive/heritrix3" \
org.opencontainers.image.base.name="docker.io/library/eclipse-temurin:${java}"
RUN groupadd --gid ${userid} heritrix && \
useradd --system --uid ${userid} --gid heritrix heritrix
COPY --chmod=755 entrypoint.sh /opt/entrypoint.sh
ENV HERITRIX_HOME=/opt/heritrix \
FOREGROUND=true
# workaround for CVE-2026-114938, remove once the base image has a fixed JDK
ENV JAVA_TOOL_OPTIONS="-XX:-UseBASE64Intrinsics"
# web UI (HTTPS only)
EXPOSE 8443
CMD ["/opt/entrypoint.sh"]
FROM base AS contrib
COPY --from=fetch-contrib /yt-dlp /usr/local/bin/yt-dlp
COPY --from=fetch-contrib --chown=heritrix:heritrix /opt/heritrix /opt/heritrix
WORKDIR /opt/heritrix
USER heritrix
FROM base AS heritrix
COPY --from=fetch-heritrix --chown=heritrix:heritrix /opt/heritrix /opt/heritrix
WORKDIR /opt/heritrix
USER heritrix
-54
View File
@@ -1,54 +0,0 @@
ARG java=25-jdk-slim
FROM openjdk:${java}
ARG version="3.9.0"
ARG user="heritrix"
ARG userid=1000
LABEL version=${version}
LABEL user=${user}/$userid
# create user
RUN \
groupadd -g $userid $user && \
useradd -r -u $userid -g $user $user
# install dependencies and other requirements (for contrib)
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
youtube-dl \
wget \
tar && \
rm -rf /var/lib/apt/lists/*
WORKDIR /opt
# download latest version according to:
# https://repo1.maven.org/maven2/org/archive/heritrix/heritrix-contrib
RUN \
wget -O heritrix-contrib-${version}-dist.tar.gz https://repo1.maven.org/maven2/org/archive/heritrix/heritrix-contrib/${version}/heritrix-contrib-${version}-dist.tar.gz && \
tar xvfz heritrix-contrib-${version}-dist.tar.gz && \
rm heritrix-contrib-${version}-dist.tar.gz && \
mv heritrix-contrib-${version} heritrix && \
chmod u+x heritrix/bin/heritrix && \
chown -R $user:$user /opt/heritrix
ADD entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh && \
chown $user:$user /opt/entrypoint.sh
WORKDIR /opt/heritrix
USER $user
ENV HERITRIX_HOME /opt/heritrix
# let it run in the foreground, required for docker
ENV FOREGROUND true
# standard webport
# NOTE: that the webpage is via HTTPS only available!
EXPOSE 8443
CMD ["/opt/entrypoint.sh"]
+4 -19
View File
@@ -1,10 +1,10 @@
# makefile to build and publish images
# You can override version and repo
# make image version=3.4.0-20210923 repo=iipc/
# make image version=3.19.0 repo=iipc/
.PHONY: all image-all-version run run-contrib image-all image image-contrib publish-all publish publish-contrib clean-all clean clean-contrib
.PHONY: all run run-contrib image-all image image-contrib publish-all publish publish-contrib clean-all clean clean-contrib
version ?= 3.4.0-20210923
version ?= 3.19.0
repo =
#pwd ?= $(shell pwd)
@@ -23,7 +23,7 @@ image:
docker tag heritrix:$(version) $(repo)heritrix:$(version)-jre
image-contrib:
docker build --build-arg version=$(version) --build-arg java=8-jre -t heritrix:$(version)-contrib -f Dockerfile.contrib .
docker build --build-arg version=$(version) --target contrib -t heritrix:$(version)-contrib .
docker tag heritrix:$(version)-contrib $(repo)heritrix:contrib
docker tag heritrix:$(version)-contrib $(repo)heritrix:$(version)-contrib
docker tag heritrix:$(version)-contrib $(repo)heritrix:$(version)-contrib-jre
@@ -56,21 +56,6 @@ clean-contrib:
# ------------------------------------
image-all-version:
@echo "following (lower) version do not support the -r switch"
$(MAKE) image version=3.4.0-20200518 repo=$(repo)
$(MAKE) image version=3.4.0-20210527 repo=$(repo)
$(MAKE) image version=3.4.0-20210617 repo=$(repo)
$(MAKE) image version=3.4.0-20210618 repo=$(repo)
$(MAKE) image version=3.4.0-20210621 repo=$(repo)
@echo "following ones support the -r switch (run single job cli option)"
$(MAKE) image version=3.4.0-20210803 repo=$(repo)
# current ones
$(MAKE) image-contrib version=3.4.0-20210923 repo=$(repo)
$(MAKE) image version=3.4.0-20210923 repo=$(repo)
# ------------------------------------
run:
[ -d jobs ] || mkdir jobs
docker run --rm -it --name heritrix_container -p 8443:8443 -e "USERNAME=admin" -e "PASSWORD=admin" -v $$(pwd)/jobs:/opt/heritrix/jobs $(repo)heritrix:$(version)