Migrate kiwix-serve container from Dockerfile to native Dagger build
Replaces the hand-written Dockerfile with container.py using the shared alpine_runtime helper, which bumps the base image from Alpine 3.22 to 3.23. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fd9e1ac93b
commit
5f38779d52
4 changed files with 55 additions and 56 deletions
|
|
@ -1,55 +0,0 @@
|
|||
# kiwix-serve container
|
||||
# Downloads pre-built binary from kiwix mirror
|
||||
|
||||
ARG CONTAINER_APP_VERSION=3.8.2
|
||||
|
||||
FROM alpine:3.22
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG CONTAINER_APP_VERSION
|
||||
ARG KIWIX_VERSION=${CONTAINER_APP_VERSION}
|
||||
|
||||
RUN set -e && \
|
||||
apk --no-cache add dumb-init curl && \
|
||||
# Detect architecture - use TARGETPLATFORM if set, otherwise detect from uname
|
||||
if [ -n "$TARGETPLATFORM" ]; then \
|
||||
echo "TARGETPLATFORM: $TARGETPLATFORM"; \
|
||||
case "$TARGETPLATFORM" in \
|
||||
linux/arm64*) ARCH="aarch64" ;; \
|
||||
linux/amd64*) ARCH="x86_64" ;; \
|
||||
*) ARCH="" ;; \
|
||||
esac; \
|
||||
else \
|
||||
echo "TARGETPLATFORM not set, detecting from uname..."; \
|
||||
UNAME_ARCH=$(uname -m); \
|
||||
echo "uname -m: $UNAME_ARCH"; \
|
||||
case "$UNAME_ARCH" in \
|
||||
aarch64|arm64) ARCH="aarch64" ;; \
|
||||
x86_64) ARCH="x86_64" ;; \
|
||||
*) ARCH="" ;; \
|
||||
esac; \
|
||||
fi && \
|
||||
if [ -z "$ARCH" ]; then \
|
||||
echo "ERROR: Unsupported architecture"; \
|
||||
exit 1; \
|
||||
fi && \
|
||||
url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$ARCH-$KIWIX_VERSION.tar.gz" && \
|
||||
echo "URL: $url" && \
|
||||
curl -k -L $url | tar -xz -C /usr/local/bin/ --strip-components 1 && \
|
||||
apk del curl
|
||||
|
||||
ARG CONTAINER_APP_VERSION
|
||||
LABEL org.opencontainers.image.title="kiwix-serve"
|
||||
LABEL org.opencontainers.image.description="Kiwix content server for offline ZIM files"
|
||||
LABEL org.opencontainers.image.version="${CONTAINER_APP_VERSION}"
|
||||
LABEL org.opencontainers.image.source="https://forge.eblu.me/eblume/blumeops"
|
||||
LABEL org.opencontainers.image.vendor="blumeops"
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# Run as non-root
|
||||
RUN adduser -D -u 1000 kiwix
|
||||
USER kiwix
|
||||
|
||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||
CMD ["/bin/sh", "-c", "echo 'Use: kiwix-serve [options] <zim-files>' && kiwix-serve --help"]
|
||||
53
containers/kiwix-serve/container.py
Normal file
53
containers/kiwix-serve/container.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"""Kiwix content server — native Dagger build.
|
||||
|
||||
Downloads pre-built kiwix-tools binary from the Kiwix mirror.
|
||||
Multi-arch support (aarch64, x86_64) via platform detection.
|
||||
"""
|
||||
|
||||
import dagger
|
||||
|
||||
from blumeops.containers import alpine_runtime, oci_labels
|
||||
|
||||
VERSION = "3.8.2"
|
||||
|
||||
MIRROR = "http://mirror.download.kiwix.org/release/kiwix-tools"
|
||||
|
||||
|
||||
async def build(src: dagger.Directory) -> dagger.Container:
|
||||
runtime = alpine_runtime(
|
||||
extra_apk=["dumb-init", "curl"],
|
||||
uid=1000,
|
||||
gid=1000,
|
||||
username="kiwix",
|
||||
)
|
||||
|
||||
# Download and install the pre-built binary for the target platform
|
||||
runtime = runtime.with_exec(
|
||||
[
|
||||
"sh",
|
||||
"-c",
|
||||
f"ARCH=$(uname -m) && "
|
||||
f'case "$ARCH" in aarch64|arm64) ARCH=aarch64;; x86_64) ARCH=x86_64;; *) echo "Unsupported: $ARCH"; exit 1;; esac && '
|
||||
f'curl -fsSL "{MIRROR}/kiwix-tools_linux-$ARCH-{VERSION}.tar.gz" | tar -xz -C /usr/local/bin/ --strip-components 1',
|
||||
]
|
||||
).with_exec(["apk", "del", "curl"])
|
||||
|
||||
runtime = oci_labels(
|
||||
runtime,
|
||||
title="kiwix-serve",
|
||||
description="Kiwix content server for offline ZIM files",
|
||||
version=VERSION,
|
||||
)
|
||||
|
||||
return (
|
||||
runtime.with_exposed_port(80)
|
||||
.with_user("1000")
|
||||
.with_entrypoint(["/usr/bin/dumb-init", "--"])
|
||||
.with_default_args(
|
||||
args=[
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"echo 'Use: kiwix-serve [options] <zim-files>' && kiwix-serve --help",
|
||||
]
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue