diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml index ebeec1d19..ee7ca34de 100644 --- a/.github/goreleaser.yml +++ b/.github/goreleaser.yml @@ -46,6 +46,7 @@ dockers: - "--label=org.opencontainers.image.revision={{ .FullCommit }}" extra_files: - dockerscripts/docker-entrypoint.sh + - dockerscripts/download-static-curl.sh - LICENSE - CREDITS @@ -66,6 +67,7 @@ dockers: - "--label=org.opencontainers.image.revision={{ .FullCommit }}" extra_files: - dockerscripts/docker-entrypoint.sh + - dockerscripts/download-static-curl.sh - LICENSE - CREDITS diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd6c5eea6..7554b9369 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,11 @@ on: push: tags: - "RELEASE.*" + workflow_dispatch: + inputs: + tag: + description: "Release tag (e.g. RELEASE.2026-03-24T12-00-00Z)" + required: true permissions: contents: write @@ -27,7 +32,7 @@ jobs: - name: Compute release variables run: | set -euo pipefail - TAG="${GITHUB_REF_NAME}" + TAG="${{ github.event.inputs.tag || github.ref_name }}" VERSION_HYPHEN="${TAG#RELEASE.}" PKG_VERSION="$(echo "${VERSION_HYPHEN}" | sed -E 's/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2})-([0-9]{2})-([0-9]{2})Z$/\1\2\3\4\5\6.0.0/')" if [ "${PKG_VERSION}" = "${VERSION_HYPHEN}" ]; then diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser index 4273b1189..89f609908 100644 --- a/Dockerfile.goreleaser +++ b/Dockerfile.goreleaser @@ -1,3 +1,62 @@ +FROM golang:1.26.1-alpine AS build + +ARG TARGETARCH + +ENV GOPATH=/go +ENV CGO_ENABLED=0 + +ARG MC_REPO=pgsty/mc +ARG MC_VERSION=latest + +RUN apk add -U --no-cache \ + ca-certificates \ + bash \ + curl \ + jq && \ + case "${TARGETARCH}" in \ + amd64) MC_ARCH=amd64 ;; \ + arm64) MC_ARCH=arm64 ;; \ + *) echo "Unsupported TARGETARCH=${TARGETARCH}"; exit 1 ;; \ + esac && \ + if [ "${MC_VERSION}" = "latest" ]; then \ + MC_RELEASE_URL="https://api.github.com/repos/${MC_REPO}/releases/latest"; \ + else \ + MC_RELEASE_URL="https://api.github.com/repos/${MC_REPO}/releases/tags/${MC_VERSION}"; \ + fi && \ + curl -fsSL "${MC_RELEASE_URL}" -o /tmp/mc-release.json && \ + MC_ARCHIVE_URL=$(jq -r --arg arch "${MC_ARCH}" \ + '.assets[] | select(.name | endswith("_linux_" + $arch + ".tar.gz")) | .browser_download_url' \ + /tmp/mc-release.json | head -n 1) && \ + MC_CHECKSUM_URL=$(jq -r \ + '.assets[] | select(.name | endswith("_checksums.txt")) | .browser_download_url' \ + /tmp/mc-release.json | head -n 1) && \ + [ -n "${MC_ARCHIVE_URL}" ] || { echo "Cannot find mcli archive for linux/${MC_ARCH}"; exit 1; } && \ + [ -n "${MC_CHECKSUM_URL}" ] || { echo "Cannot find mcli checksums file"; exit 1; } && \ + ARCHIVE_NAME=$(basename "${MC_ARCHIVE_URL}") && \ + echo "Downloading ${ARCHIVE_NAME} ..." && \ + curl -fsSL "${MC_ARCHIVE_URL}" -o /tmp/mcli.tar.gz && \ + curl -fsSL "${MC_CHECKSUM_URL}" -o /tmp/mcli_checksums.txt && \ + EXPECTED=$(grep " ${ARCHIVE_NAME}$" /tmp/mcli_checksums.txt | awk '{print $1}') && \ + ACTUAL=$(sha256sum /tmp/mcli.tar.gz | awk '{print $1}') && \ + [ -n "${EXPECTED}" ] || { echo "Checksum entry not found for ${ARCHIVE_NAME}"; exit 1; } && \ + [ "${EXPECTED}" = "${ACTUAL}" ] || { echo "Checksum mismatch: expected ${EXPECTED}, got ${ACTUAL}"; exit 1; } && \ + echo "Checksum OK: ${ACTUAL}" && \ + mkdir -p /tmp/mcli-extract && \ + tar -xzf /tmp/mcli.tar.gz -C /tmp/mcli-extract/ && \ + if [ -f /tmp/mcli-extract/mcli ]; then \ + cp /tmp/mcli-extract/mcli /go/bin/mcli; \ + elif [ -f /tmp/mcli-extract/mc ]; then \ + cp /tmp/mcli-extract/mc /go/bin/mcli; \ + else \ + echo "No mc or mcli binary found in archive:"; ls -la /tmp/mcli-extract/; exit 1; \ + fi && \ + chmod +x /go/bin/mcli && \ + ln -sf mcli /go/bin/mc + +COPY dockerscripts/download-static-curl.sh /build/download-static-curl +RUN chmod +x /build/download-static-curl && \ + /build/download-static-curl + FROM registry.access.redhat.com/ubi9/ubi:latest AS certs RUN dnf -y install ca-certificates && \ update-ca-trust && \ @@ -21,11 +80,14 @@ ENV MINIO_ACCESS_KEY_FILE=access_key \ COPY --from=certs /tmp/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY minio /usr/bin/minio +COPY --from=build /go/bin/mcli /usr/bin/mcli +COPY --from=build /go/bin/curl* /usr/bin/ COPY dockerscripts/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh COPY LICENSE /licenses/LICENSE COPY CREDITS /licenses/CREDITS -RUN chmod +x /usr/bin/minio /usr/bin/docker-entrypoint.sh +RUN chmod +x /usr/bin/minio /usr/bin/mcli /usr/bin/docker-entrypoint.sh && \ + ln -sf mcli /usr/bin/mc EXPOSE 9000 VOLUME ["/data"]