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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.jj
.idea
**/target
57 changes: 0 additions & 57 deletions .github/workflows/docker-publish-manual.yml

This file was deleted.

134 changes: 66 additions & 68 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,84 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [ "master" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


branches: [master]
pull_request:
workflow_dispatch:
schedule:
# Rebuild pinned inputs; updates are explicit reviewed changes.
- cron: '17 4 1 * *'
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
test:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
arch: amd64
- runner: ubuntu-24.04-arm
arch: arm64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
- name: Build image on native host
run: |
mkdir -p "$RUNNER_TEMP/evidence"
docker build --progress plain -t rustxc:test . > "$RUNNER_TEMP/evidence/image.log" 2>&1
docker image inspect rustxc:test > "$RUNNER_TEMP/evidence/image.json"
- name: Native C, C++, assembly, discovery and Rust smoke
run: |
docker run --rm -v "$PWD/tests:/tests:ro" -v "$RUNNER_TEMP/evidence:/evidence" \
-v rustxc-ci-xwin:/opt/xwin -e RUSTXC_EVIDENCE_DIR=/evidence rustxc:test /opt/rustxc/smoke \
aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu powerpc64le-unknown-linux-gnu \
aarch64-apple-darwin x86_64-apple-darwin \
x86_64-pc-windows-msvc aarch64-pc-windows-msvc \
> "$RUNNER_TEMP/evidence/smoke.log" 2>&1
- name: Alternate pinned Rust toolchain
run: |
docker run --rm -v "$PWD/tests:/tests:ro" -v "$RUNNER_TEMP/evidence:/evidence" \
-e RUSTUP_TOOLCHAIN=1.96.0 -e RUSTXC_EVIDENCE_DIR=/evidence/rust196 \
rustxc:test /opt/rustxc/smoke x86_64-unknown-linux-gnu \
> "$RUNNER_TEMP/evidence/rust196.log" 2>&1
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
if: always()
with:
name: smoke-${{ matrix.arch }}
path: |
${{ runner.temp }}/evidence/*.log
${{ runner.temp }}/evidence/*.json
${{ runner.temp }}/evidence/*.txt
publish:
needs: test
if: github.event_name != 'pull_request'
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: 'v2.2.4'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8
id: image
with:
platforms: linux/amd64,linux/arm64
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
push: true
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
- uses: sigstore/cosign-installer@ba7bc0a3fef59531c69a25acd34668d6d3fe6f22
- name: Sign image index
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
IMAGE: ghcr.io/${{ github.repository }}
DIGEST: ${{ steps.image.outputs.digest }}
run: cosign sign --yes "${IMAGE}@${DIGEST}"
115 changes: 49 additions & 66 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,50 @@
# Build the Mac OS X toolchain
FROM rust:latest AS osxcross

ARG MACOS_X_SDK_VERSION=26.1
RUN <<END
apt update
DEBIAN_FRONTEND=noninteractive apt install -yq \
curl \
clang \
git \
wget \
make \
cmake \
libssl-dev \
zlib1g-dev \
xz-utils
git clone https://github.com/tpoechtrager/osxcross
wget -nc "https://github.com/joseluisq/macosx-sdks/releases/download/$MACOS_X_SDK_VERSION/MacOSX$MACOS_X_SDK_VERSION.sdk.tar.xz" -O "osxcross/tarballs/MacOSX$MACOS_X_SDK_VERSION.sdk.tar.xz"
UNATTENDED=1 TARGET_DIR=/toolchain/macos bash osxcross/build.sh
END

# Install toolchains for linux on various CPUs
FROM rust:latest

RUN <<END
apt update
apt install -yq \
clang \
make \
gcc-aarch64-linux-gnu \
gcc-x86-64-linux-gnu \
gcc-powerpc64le-linux-gnu
apt clean
END
COPY --from=osxcross /toolchain /toolchain

RUN <<END
rustup target add \
aarch64-unknown-linux-gnu \
x86_64-unknown-linux-gnu \
powerpc64le-unknown-linux-gnu \
aarch64-apple-darwin \
x86_64-apple-darwin
END

RUN <<EOF
mkdir /.cargo
cat > /.cargo/config.toml <<- CARGO
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[target.x86_64-unknown-linux-gnu]
linker = "x86_64-linux-gnu-gcc"

[target.powerpc64le-unknown-linux-gnu]
linker = "powerpc64le-linux-gnu-gcc"

[target.x86_64-apple-darwin]
linker = "$(basename $(find /toolchain -name 'x86_64-apple-darwin*-clang'))"

[target.aarch64-apple-darwin]
linker = "$(basename $(find /toolchain -name 'aarch64-apple-darwin*-clang'))"
CARGO
EOF

ENV PATH="$PATH:/toolchain/macos/bin"
# syntax=docker/dockerfile:1.7@sha256:a57df69d0ea827fb7266491f2813635de6f17269be881f696fbfdf2d83dda33e
# Multi-architecture index, not an architecture-specific manifest.
ARG RUST_IMAGE=rust:1.97.1-bookworm@sha256:0e2bcaef56d041a486784e54104a81aebe0da44bd03019bd70bc0401e42e4a97
FROM ${RUST_IMAGE} AS base
ARG DEBIAN_SNAPSHOT=20260811T000000Z
RUN rm -f /etc/apt/sources.list /etc/apt/sources.list.d/* && \
printf 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/%s bookworm main\n' "$DEBIAN_SNAPSHOT" > /etc/apt/sources.list

# Download foreign packages rather than executing foreign binaries. These stages
# run natively on either build host. Each dependency closure has its own root.
FROM base AS sysroots
RUN apt-get update && apt-get install -y --no-install-recommends python3 ca-certificates
COPY scripts/make-sysroots /usr/local/bin/
RUN make-sysroots

FROM base AS tools
RUN apt-get update && apt-get install -y --no-install-recommends \
clang-19 lld-19 llvm-19 llvm-19-tools libclang-rt-19-dev \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
gcc-x86-64-linux-gnu g++-x86-64-linux-gnu \
gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
cmake ninja-build make pkg-config nasm python3 file ca-certificates curl xz-utils \
&& rm -rf /var/lib/apt/lists/*
ARG CARGO_XWIN_VERSION=0.23.1
RUN cargo install --locked cargo-xwin --version "$CARGO_XWIN_VERSION" && \
rm -rf /usr/local/cargo/registry /usr/local/cargo/git
# LLVM's integrated assembler and ld64.lld support both Darwin architectures.
# SDK is checksum-verified. See README licensing requirements before distribution.
ARG MACOS_SDK_VERSION=14.5
ARG MACOS_SDK_SHA256=6e146275d19f027faa2e8354da5e0267513abf013b8f16ad65a231653a2b1c5d
RUN curl -fL --retry 5 "https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK_VERSION}/MacOSX${MACOS_SDK_VERSION}.sdk.tar.xz" -o /tmp/macos.tar.xz && \
echo "$MACOS_SDK_SHA256 /tmp/macos.tar.xz" | sha256sum -c - && \
mkdir -p /opt/sdk && tar -xJf /tmp/macos.tar.xz -C /opt/sdk && \
mv "/opt/sdk/MacOSX${MACOS_SDK_VERSION}.sdk" /opt/sdk/macos && rm /tmp/macos.tar.xz
RUN rustup target add --toolchain 1.97.1 \
aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu powerpc64le-unknown-linux-gnu \
aarch64-apple-darwin x86_64-apple-darwin \
x86_64-pc-windows-msvc aarch64-pc-windows-msvc && \
rustup component add --toolchain 1.97.1 rustfmt clippy && \
dpkg-query -W > /opt/rustxc-packages.txt
COPY --from=sysroots /opt/sysroots /opt/sysroots
COPY scripts/ /opt/rustxc/
RUN /opt/rustxc/configure && mv /opt/rustxc-packages.txt /opt/rustxc/packages.txt
ENV PATH="/opt/rustxc/bin:/usr/lib/llvm-19/bin:${PATH}" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
XWIN_CACHE_DIR=/opt/xwin XWIN_ARCH=x86_64,aarch64 \
XWIN_VERSION=17 XWIN_SDK_VERSION=10.0.26100 XWIN_CRT_VERSION=14.44.17.14
WORKDIR /mnt
ENTRYPOINT ["/opt/rustxc/entrypoint"]
CMD ["bash"]
Loading
Loading