Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.dockerignore
.git*
Containerfile
Dockerfile

# From .gitignore
Expand Down
65 changes: 48 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,23 @@ jobs:
files: artifacts/*

Release-Container-Image:
needs: [Release]
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
arch: amd64
- platform: linux/arm64
runner: ubuntu-22.04-arm
arch: arm64
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf

- name: Setup Docker buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db

Expand All @@ -157,21 +162,47 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
- name: Build and push distroless (${{ matrix.platform }})
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=false
context: .
push: true
target: distroless
platforms: ${{ matrix.platform }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:distroless-${{ matrix.arch }}

- name: Build and push Docker image
- name: Build and push alpine (${{ matrix.platform }})
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
build-args: |
USE_GH_RELEASE=true
ZOLA_RELEASE_VERSION=${{ github.ref_name }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: alpine
platforms: ${{ matrix.platform }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-${{ matrix.arch }}

Create-Manifest:
needs: [Release-Container-Image]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create distroless multi-arch manifest
run: |
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:distroless-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:distroless-arm64

- name: Create alpine multi-arch manifest
run: |
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-alpine \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-arm64
51 changes: 51 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM docker.io/rust:alpine AS builder

RUN apk add --no-cache \
pkgconfig \
make \
g++ \
openssl-dev \
musl-dev

WORKDIR /app
COPY . .

RUN cargo build --release && \
cp target/release/zola zola && \
./zola --version

FROM docker.io/alpine:3.21 AS musl-libs
RUN mkdir -p /out && \
cp /lib/ld-musl-$(uname -m).so.1 /out/ && \
cp /lib/libc.musl-$(uname -m).so.1 /out/

FROM docker.io/alpine:3.23 AS alpine
COPY --from=builder /app/zola /bin/zola
ENTRYPOINT ["/bin/zola"]

FROM scratch AS distroless
COPY --from=builder /app/zola /zola
COPY --from=musl-libs /out/ /lib/
ENTRYPOINT ["/zola"]

FROM docker.io/rust:slim-bookworm AS builder-gh

RUN apt-get update -y && \
apt-get install -y curl jq tar gzip

WORKDIR /app

ARG ZOLA_RELEASE_VERSION=latest
RUN if [ "${ZOLA_RELEASE_VERSION}" = "latest" ]; then \
export ZOLA_VERSION=$(curl -sL https://api.github.com/repos/getzola/zola/releases/latest | jq -r .name); \
else \
export ZOLA_VERSION="${ZOLA_RELEASE_VERSION}"; \
fi && \
curl -sL --fail --output zola.tar.gz https://github.com/getzola/zola/releases/download/${ZOLA_VERSION}/zola-${ZOLA_VERSION}-$(uname -m)-unknown-linux-gnu.tar.gz && \
tar -xzvf zola.tar.gz && \
./zola --version

FROM gcr.io/distroless/cc-debian12 AS gh-release
ARG ZOLA_RELEASE_VERSION=latest
COPY --from=builder-gh /app/zola /bin/zola
ENTRYPOINT ["/bin/zola"]
26 changes: 0 additions & 26 deletions Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions Dockerfile
Loading