This commit is contained in:
@@ -36,7 +36,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
builder: multiplatform-builder
|
builder: multiplatform-builder
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
pull: true
|
pull: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
|||||||
+22
-11
@@ -1,29 +1,40 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM rust:1-slim AS builder
|
FROM --platform=$BUILDPLATFORM rust:1-slim AS builder
|
||||||
|
|
||||||
ARG RUST_TARGET=x86_64-unknown-linux-musl
|
ARG TARGETARCH
|
||||||
|
|
||||||
RUN sed -i 's|http://deb.debian.org|https://deb.debian.org|g' \
|
RUN set -eu; \
|
||||||
/etc/apt/sources.list.d/debian.sources 2>/dev/null || true \
|
case "${TARGETARCH}" in \
|
||||||
&& apt-get update \
|
amd64) rust_target=x86_64-unknown-linux-musl; cross_packages="" ;; \
|
||||||
&& apt-get install -y --no-install-recommends musl-tools ca-certificates \
|
arm64) rust_target=aarch64-unknown-linux-musl; cross_packages="gcc-aarch64-linux-gnu" ;; \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
*) echo "unsupported target architecture: ${TARGETARCH}" >&2; exit 1 ;; \
|
||||||
&& rustup target add "${RUST_TARGET}"
|
esac; \
|
||||||
|
printf '%s\n' "${rust_target}" > /tmp/rust-target; \
|
||||||
|
sed -i 's|http://deb.debian.org|https://deb.debian.org|g' \
|
||||||
|
/etc/apt/sources.list.d/debian.sources 2>/dev/null || true; \
|
||||||
|
apt-get update; \
|
||||||
|
apt-get install -y --no-install-recommends musl-tools ca-certificates ${cross_packages}; \
|
||||||
|
rm -rf /var/lib/apt/lists/*; \
|
||||||
|
rustup target add "${rust_target}"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
mkdir -p src \
|
mkdir -p src \
|
||||||
&& printf 'fn main() {}' > src/main.rs \
|
&& printf 'fn main() {}' > src/main.rs \
|
||||||
&& cargo fetch --locked --target "${RUST_TARGET}"
|
&& cargo fetch --locked --target "$(cat /tmp/rust-target)"
|
||||||
|
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=/app/target \
|
--mount=type=cache,target=/app/target \
|
||||||
cargo build --release --locked --target "${RUST_TARGET}" \
|
if [ "${TARGETARCH}" = "arm64" ]; then \
|
||||||
|
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc; \
|
||||||
|
fi \
|
||||||
|
&& rust_target="$(cat /tmp/rust-target)" \
|
||||||
|
&& cargo build --release --locked --target "${rust_target}" \
|
||||||
&& mkdir -p /out \
|
&& mkdir -p /out \
|
||||||
&& cp "/app/target/${RUST_TARGET}/release/hermes" /out/hermes
|
&& cp "/app/target/${rust_target}/release/hermes" /out/hermes
|
||||||
|
|
||||||
FROM scratch AS runtime
|
FROM scratch AS runtime
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ The `scratch` runtime contains no shell or healthcheck utility. Use `docker run
|
|||||||
|
|
||||||
### Publishing
|
### Publishing
|
||||||
|
|
||||||
The Gitea workflow in `.gitea/workflows/build.yaml` builds and publishes `linux/amd64` images to `gitea.woggioni.net/woggioni/hermes` when a tag matching `release/*` is pushed. For example, `release/v0.2.0` publishes `v0.2.0` and `latest` tags. The repository must define the `PUBLISHER_TOKEN` secret used for registry authentication.
|
The Gitea workflow in `.gitea/workflows/build.yaml` builds and publishes multi-architecture `linux/amd64` and `linux/arm64` images to `gitea.woggioni.net/woggioni/hermes` when a tag matching `release/*` is pushed. The ARM64 binary is cross-compiled on the AMD64 builder without emulation. For example, `release/v0.2.0` publishes `v0.2.0` and `latest` tags containing both architectures. The repository must define the `PUBLISHER_TOKEN` secret used for registry authentication.
|
||||||
|
|
||||||
## YAML configuration
|
## YAML configuration
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user