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
52 changes: 47 additions & 5 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ on:
pull_request:
branches:
- master
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
- cron: '0 6 * * *'

jobs:
build:
Expand Down Expand Up @@ -80,33 +81,74 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master'
with:
registry: ghcr.io
username: rust-lang
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master'
with:
username: rustopsbot
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Compute nightly date
id: date
env:
EVENT_NAME: ${{ github.event_name }}
run: |
set -euo pipefail
DATE=$(date -u +%Y-%m-%d)
URL="https://static.rust-lang.org/dist/${DATE}/channel-rust-nightly.toml"
if ! curl -fsI -o /dev/null "$URL"; then
case "${EVENT_NAME}" in
push|pull_request)
echo "Today's nightly manifest is not yet published; falling back to yesterday." >&2
DATE=$(date -u -d 'yesterday' +%Y-%m-%d)
;;
*)
echo "Today's nightly manifest is not yet published; refusing to publish a stale nightly." >&2
exit 1
;;
esac
fi
echo "date=${DATE}" >> "$GITHUB_OUTPUT"

- name: Build dated tag list
id: dated_tags
env:
BASE_TAGS: ${{ matrix.tags }}
DATE: ${{ steps.date.outputs.date }}
run: |
{
echo "tags<<EOF"
while IFS= read -r tag; do
[ -z "$tag" ] && continue
echo "type=raw,value=${tag}-${DATE}"
done <<< "$BASE_TAGS"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
rustlang/rust
ghcr.io/rust-lang/rust
tags: ${{ matrix.tags }}
tags: |
${{ matrix.tags }}
${{ steps.dated_tags.outputs.tags }}

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
platforms: ${{ matrix.platforms }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
RUST_VERSION=nightly-${{ steps.date.outputs.date }}
push: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 2 additions & 1 deletion Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RUN apk add --no-cache \
musl-dev \
gcc

%%RUST-VERSION-ARG%%
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=%%RUST-VERSION%%
RUST_VERSION=%%RUST-VERSION-VALUE%%

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile-debian.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM buildpack-deps:%%TAG%%

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

%%RUST-VERSION-ARG%%
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=%%RUST-VERSION%%
RUST_VERSION=%%RUST-VERSION-VALUE%%

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile-slim.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM debian:%%TAG%%-slim

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

%%RUST-VERSION-ARG%%
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=%%RUST-VERSION%%
RUST_VERSION=%%RUST-VERSION-VALUE%%

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/alpine3.21/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RUN apk add --no-cache \
musl-dev \
gcc

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/alpine3.22/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RUN apk add --no-cache \
musl-dev \
gcc

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/alpine3.23/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RUN apk add --no-cache \
musl-dev \
gcc

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/bookworm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM buildpack-deps:bookworm

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/bookworm/slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM debian:bookworm-slim

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM buildpack-deps:bullseye

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/bullseye/slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM debian:bullseye-slim

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/trixie/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM buildpack-deps:trixie

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
3 changes: 2 additions & 1 deletion nightly/trixie/slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM debian:trixie-slim

LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust

ARG RUST_VERSION=nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUST_VERSION=${RUST_VERSION}

RUN set -eux; \
\
Expand Down
19 changes: 15 additions & 4 deletions x.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,23 @@ def render_template(
arch_cases,
rendered_path
):
if rust_version == "nightly":
rust_version_arg = "ARG RUST_VERSION=nightly\n"
rust_version_value = "${RUST_VERSION}"
else:
rust_version_arg = ""
rust_version_value = rust_version

template = read_file(template_path)
rendered = template \
.replace("%%TAG%%", docker_tag) \
.replace("%%RUST-VERSION%%", rust_version) \
.replace("%%RUSTUP-VERSION%%", rustup_version) \
rendered = (
template
.replace("%%TAG%%", docker_tag)
# We match with `\n` here so that the line is removed entirely if the argument is not needed
.replace("%%RUST-VERSION-ARG%%\n", rust_version_arg)
.replace("%%RUST-VERSION-VALUE%%", rust_version_value)
.replace("%%RUSTUP-VERSION%%", rustup_version)
.replace("%%ARCH-CASE%%", arch_cases)
)
write_file(rendered_path, rendered)

def update_ci():
Expand Down
Loading