From 4afea4d4ac5a6d65437d0da185b17110968859e2 Mon Sep 17 00:00:00 2001 From: "Victor M." Date: Thu, 3 Oct 2024 17:01:24 +0200 Subject: [PATCH] provide UBI Dockerfile template --- 2.8/ubi/Dockerfile | 2 +- Dockerfile.ubi.tmpl | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.ubi.tmpl diff --git a/2.8/ubi/Dockerfile b/2.8/ubi/Dockerfile index 619c0f0..82d46ac 100644 --- a/2.8/ubi/Dockerfile +++ b/2.8/ubi/Dockerfile @@ -31,7 +31,7 @@ RUN set -eux; \ ppc64el|ppc64le) binArch='ppc64le'; checksum='90c4a779f52b86d4b615a15acdec01db986a88fb606ca11145c21cfc4e64b417296fe0a54416f2c295600f8a2994a073a40028b1b1583403b416464bf39de173' ;; \ riscv64) binArch='riscv64'; checksum='67ce559ca785f05b54b587f91f12f8c4c46a7d14e3f72772f14922b672417473b4e76ab61dd939b9b710889ca3a0604cd7f4c78ccba8e6dbfd5fd5193d9bf719' ;; \ s390x) binArch='s390x'; checksum='ed67cecdb9f50379d75805ebeb687183f096d3206cef053b768e87eceb4472fd568f47ef8fe0939f019f38e298a3a41243ba9caa193f57e7b29e4daa700898bc' ;; \ - *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ + *) echo >&2 "error: unsupported architecture ($arch)"; exit 1 ;;\ esac; \ curl -SLf -o /tmp/caddy.tar.gz "https://github.com/caddyserver/caddy/releases/download/v2.8.4/caddy_2.8.4_linux_${binArch}.tar.gz"; \ echo "$checksum /tmp/caddy.tar.gz" | sha512sum -c; \ diff --git a/Dockerfile.ubi.tmpl b/Dockerfile.ubi.tmpl new file mode 100644 index 0000000..d70234a --- /dev/null +++ b/Dockerfile.ubi.tmpl @@ -0,0 +1,64 @@ +{{ .base | strings.TrimSpace }} + +RUN microdnf install -y \ + ca-certificates \ + libcap \ + mailcap \ + tar \ + gzip \ + && microdnf clean all + +RUN set -eux; \ + mkdir -p \ + /config/caddy \ + /data/caddy \ + /etc/caddy \ + /usr/share/caddy \ + ; \ + curl -SLf -o /etc/caddy/Caddyfile "https://github.com/caddyserver/dist/raw/{{ .config.dist_commit }}/config/Caddyfile"; \ + curl -SLf -o /usr/share/caddy/index.html "https://github.com/caddyserver/dist/raw/{{ .config.dist_commit }}/welcome/index.html" + +# https://github.com/caddyserver/caddy/releases +ENV CADDY_VERSION v{{ .config.caddy_version }} + +RUN set -eux; \ + arch="$(uname -m)"; \ + case "$arch" in \ + x86_64) binArch='amd64'; checksum='{{ .checksums.amd64 }}' ;; \ + armhf) binArch='armv6'; checksum='{{ .checksums.arm32v6 }}' ;; \ + armv7) binArch='armv7'; checksum='{{ .checksums.arm32v7 }}' ;; \ + aarch64) binArch='arm64'; checksum='{{ .checksums.arm64v8 }}' ;; \ + ppc64el|ppc64le) binArch='ppc64le'; checksum='{{ .checksums.ppc64le }}' ;; \ + riscv64) binArch='riscv64'; checksum='{{ .checksums.riscv64 }}' ;; \ + s390x) binArch='s390x'; checksum='{{ .checksums.s390x }}' ;; \ + *) echo >&2 "error: unsupported architecture ($arch)"; exit 1 ;;\ + esac; \ + curl -SLf -o /tmp/caddy.tar.gz "https://github.com/caddyserver/caddy/releases/download/v{{ .config.caddy_version }}/caddy_{{ .config.caddy_version }}_linux_${binArch}.tar.gz"; \ + echo "$checksum /tmp/caddy.tar.gz" | sha512sum -c; \ + tar x -z -f /tmp/caddy.tar.gz -C /usr/bin caddy; \ + rm -f /tmp/caddy.tar.gz; \ + setcap cap_net_bind_service=+ep /usr/bin/caddy; \ + chmod +x /usr/bin/caddy; \ + caddy version + +# See https://caddyserver.com/docs/conventions#file-locations for details +ENV XDG_CONFIG_HOME /config +ENV XDG_DATA_HOME /data + +LABEL org.opencontainers.image.version=v{{ .config.caddy_version }} +LABEL org.opencontainers.image.title=Caddy +LABEL org.opencontainers.image.description="a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go" +LABEL org.opencontainers.image.url=https://caddyserver.com +LABEL org.opencontainers.image.documentation=https://caddyserver.com/docs +LABEL org.opencontainers.image.vendor="Light Code Labs" +LABEL org.opencontainers.image.licenses=Apache-2.0 +LABEL org.opencontainers.image.source="https://github.com/caddyserver/caddy-docker" + +EXPOSE 80 +EXPOSE 443 +EXPOSE 443/udp +EXPOSE 2019 + +WORKDIR /srv + +CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]