Skip to content

Commit a54194c

Browse files
Fix docker build and set MSRV to 1.78 (#158)
1 parent 34f4030 commit a54194c

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

.github/workflows/docker.yaml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
tags: ["v*"]
88
branches: [ main ]
99
workflow_dispatch:
10+
# Run on pull requests to test docker build.
11+
# We explicitly do not push on pull requests (the job below is ended early).
12+
#
13+
# note: secrets will not be populated on pull requests from external authors.
14+
pull_request:
1015

1116
permissions:
1217
contents: read
@@ -19,19 +24,6 @@ jobs:
1924
- name: Set up Docker Buildx
2025
uses: docker/setup-buildx-action@v2
2126

22-
- name: Log in to DockerHub
23-
uses: docker/login-action@v2
24-
with:
25-
username: ${{ secrets.DOCKER_HUB_USERNAME }}
26-
password: ${{ secrets.DOCKER_HUB_TOKEN }}
27-
28-
- name: Log in to GHCR
29-
uses: docker/login-action@v2
30-
with:
31-
registry: ghcr.io
32-
username: ${{ github.repository_owner }}
33-
password: ${{ secrets.GITHUB_TOKEN }}
34-
3527
- name: Calculate docker image tag
3628
id: set-tag
3729
uses: docker/metadata-action@master
@@ -46,6 +38,25 @@ jobs:
4638
type=sha,prefix=,format=long
4739
type=semver,pattern=v{{version}}
4840
type=semver,pattern=v{{major}}.{{minor}}
41+
42+
- name: Don't push to registry if this is a PR
43+
if: "${{ github.event_name }}" = "pull_request"
44+
run: |
45+
echo "Not pushing the image to any container registry as this workflow is running on a pull request"
46+
exit 0
47+
48+
- name: Log in to DockerHub
49+
uses: docker/login-action@v2
50+
with:
51+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
52+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
53+
54+
- name: Log in to GHCR
55+
uses: docker/login-action@v2
56+
with:
57+
registry: ghcr.io
58+
username: ${{ github.repository_owner }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
4960

5061
- name: Build and push all platforms
5162
uses: docker/build-push-action@v4

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ tikv-jemallocator = "0.6.0"
3131
[package]
3232
name = "synapse_compress_state"
3333
description = "A tool to compress some state in a Synapse instance's database"
34+
rust-version = "1.78"
3435
authors = ["Erik Johnston"]
3536
version.workspace = true
3637
edition.workspace = true

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# second stage only copies the binaries for the target architecture.
44
# We leverage Zig and cargo-zigbuild for providing a cross-compilation-capable C compiler and linker.
55

6-
ARG RUSTC_VERSION=1.72.0
7-
ARG ZIG_VERSION=0.11.0
8-
ARG CARGO_ZIGBUILD_VERSION=0.17.1
6+
ARG RUSTC_VERSION=1.78.0
7+
ARG ZIG_VERSION=0.14.1
8+
ARG CARGO_ZIGBUILD_VERSION=0.20.1
99

1010
FROM --platform=${BUILDPLATFORM} docker.io/rust:${RUSTC_VERSION} AS builder
1111

@@ -15,8 +15,8 @@ RUN cargo install --locked cargo-zigbuild@=${CARGO_ZIGBUILD_VERSION}
1515

1616
# Download zig compiler for cross-compilation
1717
ARG ZIG_VERSION
18-
RUN curl -L "https://ziglang.org/download/${ZIG_VERSION}/zig-linux-$(uname -m)-${ZIG_VERSION}.tar.xz" | tar -J -x -C /usr/local && \
19-
ln -s "/usr/local/zig-linux-$(uname -m)-${ZIG_VERSION}/zig" /usr/local/bin/zig
18+
RUN curl -L "https://ziglang.org/download/${ZIG_VERSION}/zig-$(uname -m)-linux-${ZIG_VERSION}.tar.xz" | tar -J -x -C /usr/local && \
19+
ln -s "/usr/local/zig-$(uname -m)-linux-${ZIG_VERSION}/zig" /usr/local/bin/zig
2020

2121
# Install all cross-compilation targets
2222
ARG RUSTC_VERSION

0 commit comments

Comments
 (0)