Skip to content

Commit 91cbba1

Browse files
committed
ci: Switch CI to GitHub & update deps
Docker Hub now costs $5/month to build open source projects, and it's always been a clunky and slow builder. So let's switch everything to GitHub CI. We also add a note encouraging as many users as possible to replace OpenSSL with `rustls` and switch to `cross`.
1 parent b38371c commit 91cbba1

File tree

12 files changed

+884
-737
lines changed

12 files changed

+884
-737
lines changed

.github/workflows/ci.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Test and publish image
2+
3+
on:
4+
schedule:
5+
# Rust tends to make stable releases every six weeks on Thursday 10am
6+
# Pacific Time. Force a build a few hours later than that (every week) to
7+
# scoop up the newest stable and beta (including patch releases).
8+
#
9+
# This way, even if we don't update the matrix below we should still have
10+
# images.
11+
- cron: '0 21 * * THU'
12+
push:
13+
branches:
14+
- main
15+
pull_request:
16+
branches:
17+
- main
18+
19+
# See https://docs.github.com/en/actions/guides/publishing-docker-images for the
20+
# theory, but we do some things differently.
21+
22+
jobs:
23+
test_image:
24+
name: Test static linking (using stable Rust)
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Check out the repo
29+
uses: actions/checkout@v2
30+
31+
# Run some fairly extensive tests to make sure that we actually produce
32+
# static, working programs.
33+
- name: Test image
34+
run: ./test-image
35+
36+
build_and_push:
37+
name: Build image & push
38+
runs-on: ubuntu-latest
39+
40+
needs:
41+
- test_image
42+
43+
strategy:
44+
matrix:
45+
# We build multiple versions of the image from the same Dockerfile each
46+
# time we push. This is different that the standard strategy for
47+
# maintaining images using GitHub actions, which involves a lot of tags
48+
# and branches. But since there are new Rust releases far more often
49+
# than we change this project, it works.
50+
toolchain:
51+
- "stable"
52+
- "beta"
53+
- "1.57.0"
54+
55+
# We never built these, so include them until they get built and released once.
56+
- 1.56.1
57+
- 1.55.0
58+
- 1.54.0
59+
- 1.53.0
60+
- 1.52.1
61+
62+
# See https://rust-lang.github.io/rustup-components-history/ and choose
63+
# the newest nightly build that has all the components (except RLS,
64+
# which is obsolete).
65+
- "nightly-2021-12-23"
66+
67+
steps:
68+
- name: Check out the repo
69+
uses: actions/checkout@v2
70+
71+
- name: Login to GitHub Container Registry
72+
if: ${{ github.event_name != 'pull_request' }}
73+
uses: docker/login-action@v1
74+
with:
75+
registry: ghcr.io
76+
username: ${{ github.actor }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Log in to Docker Hub
80+
if: ${{ github.event_name != 'pull_request' }}
81+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
82+
with:
83+
username: ${{ secrets.DOCKER_USERNAME }}
84+
password: ${{ secrets.DOCKER_PASSWORD }}
85+
86+
- name: Build release image
87+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
88+
with:
89+
context: .
90+
push: ${{ github.event_name != 'pull_request' }}
91+
build-args: |
92+
TOOLCHAIN=${{ matrix.toolchain }}
93+
# Use some slightly funky substituations to tag only `stable` as `latest`.
94+
tags: |
95+
ghcr.io/emk/rust-musl-builder:${{ matrix.toolchain }}
96+
ekidd/rust-musl-builder:${{ matrix.toolchain }}
97+
${{ matrix.toolchain == 'stable' && 'ghcr.io/emk/rust-musl-builder:latest' || '' }}
98+
${{ matrix.toolchain == 'stable' && 'ekidd/rust-musl-builder:latest' || '' }}
99+
labels: |
100+
org.opencontainers.image.title=rust-musl-builder
101+
org.opencontainers.image.description=Tools for statically linked Rust programs using musl-libc
102+
org.opencontainers.image.url=https://github.com/emk/rust-musl-builder
103+
org.opencontainers.image.source=https://github.com/emk/rust-musl-builder
104+
net.randomhacks.rust-musl-builder.toolchain=${{ matrix.toolchain }}

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). We do not use Semantic Versioning, because our images are tagged based on Rust releases. However, we try to maintain as much backwards compatibility as possible.
66

7-
For maximum stablity, use images with tags like `ekidd/rust-musl-builder:1.46.0` or `ekidd/rust-musl-builder:nightly-2020-08-26`. These may occasionally be rebuilt, but only while they're "current", or possibly if they're recent and serious security are discovered in a library.
7+
For maximum stablity, use images with tags like `ekidd/rust-musl-builder:1.46.0` or `ekidd/rust-musl-builder:nightly-2020-08-26`. These may occasionally be rebuilt, but only while they're "current", or possibly if they're recent and serious security issues are discovered in a library.
8+
9+
## 2021-12-23
10+
11+
### Added
12+
13+
- Set up weekly cron builds every Thursday, a few hours after Rust releases often happen. This should keep `stable` and `beta` more-or-less up-to-date. (Tagged releases like `1.57.0` will still need to be made manually.)
14+
15+
### Changed
16+
17+
- **Moved release builds from Docker Hub to GitHub!** This allows us to once again start building images without paying Docker Hub for slow, frustrating builders.
18+
- Moved PR tests from Travis CI to GitHub.
19+
- Updated `examples/` to use newer dependencies.
20+
- Updated to OpenSSL 1.1.1m.
21+
- Updated to mdbook 0.4.14.
22+
- Updated to mbbook-graphviz 0.1.3 (now using upstream binaries).
23+
- Updated to cargo-about 0.4.4.
24+
- Updated to cargo-audit 0.16.0 (now using upstream binaries).
25+
- Updated to PostgreSQL 11.14. Still no PostgreSQL 12 unless someone wants to look into diesel and static linking.
826

927
## 2021-02-13
1028

Dockerfile

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,35 @@ ARG TOOLCHAIN=stable
99
# - https://www.openssl.org/source/
1010
#
1111
# ALSO UPDATE hooks/build!
12-
ARG OPENSSL_VERSION=1.1.1i
12+
ARG OPENSSL_VERSION=1.1.1m
1313

1414
# Versions for other dependencies. Here are the places to check for new
1515
# releases:
1616
#
1717
# - https://github.com/rust-lang/mdBook/releases
18+
# - https://github.com/dylanowen/mdbook-graphviz/releases
1819
# - https://github.com/EmbarkStudios/cargo-about/releases
20+
# - https://github.com/rustsec/rustsec/releases
1921
# - https://github.com/EmbarkStudios/cargo-deny/releases
2022
# - http://zlib.net/
2123
# - https://ftp.postgresql.org/pub/source/
2224
#
2325
# We're stuck on PostgreSQL 11 until we figure out
2426
# https://github.com/emk/rust-musl-builder/issues.
25-
ARG MDBOOK_VERSION=0.4.6
26-
ARG CARGO_ABOUT_VERSION=0.2.3
27-
ARG CARGO_DENY_VERSION=0.8.5
27+
ARG MDBOOK_VERSION=0.4.14
28+
ARG MDBOOK_GRAPHVIZ_VERSION=0.1.3
29+
ARG CARGO_ABOUT_VERSION=0.4.4
30+
ARG CARGO_AUDIT_VERSION=0.16.0
31+
ARG CARGO_DENY_VERSION=0.11.0
2832
ARG ZLIB_VERSION=1.2.11
29-
ARG POSTGRESQL_VERSION=11.11
33+
ARG POSTGRESQL_VERSION=11.14
3034

3135
# Make sure we have basic dev tools for building C libraries. Our goal here is
3236
# to support the musl-libc builds and Cargo builds needed for a large selection
3337
# of the most popular crates.
3438
#
3539
# We also set up a `rust` user by default. This user has sudo privileges if you
3640
# need to install any more software.
37-
#
38-
# `mdbook` is the standard Rust tool for making searchable HTML manuals.
3941
RUN apt-get update && \
4042
export DEBIAN_FRONTEND=noninteractive && \
4143
apt-get install -yq \
@@ -53,18 +55,33 @@ RUN apt-get update && \
5355
linux-libc-dev \
5456
pkgconf \
5557
sudo \
58+
unzip \
5659
xutils-dev \
5760
&& \
5861
apt-get clean && rm -rf /var/lib/apt/lists/* && \
59-
useradd rust --user-group --create-home --shell /bin/bash --groups sudo && \
60-
curl -fLO https://github.com/rust-lang-nursery/mdBook/releases/download/v$MDBOOK_VERSION/mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
62+
useradd rust --user-group --create-home --shell /bin/bash --groups sudo
63+
64+
# - `mdbook` is the standard Rust tool for making searchable HTML manuals.
65+
# - `mdbook-graphviz` allows using inline GraphViz drawing commands to add illustrations.
66+
# - `cargo-about` generates a giant license file for all dependencies.
67+
# - `cargo-audit` checks for security vulnerabilities. We include it for backwards compat.
68+
# - `cargo-deny` does everything `cargo-audit` does, plus check licenses & many other things.
69+
RUN curl -fLO https://github.com/rust-lang-nursery/mdBook/releases/download/v$MDBOOK_VERSION/mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
6170
tar xf mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
6271
mv mdbook /usr/local/bin/ && \
6372
rm -f mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
73+
curl -fLO https://github.com/dylanowen/mdbook-graphviz/releases/download/v$MDBOOK_GRAPHVIZ_VERSION/mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
74+
unzip mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
75+
mv mdbook-graphviz /usr/local/bin/ && \
76+
rm -f mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
6477
curl -fLO https://github.com/EmbarkStudios/cargo-about/releases/download/$CARGO_ABOUT_VERSION/cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz && \
6578
tar xf cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz && \
6679
mv cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl/cargo-about /usr/local/bin/ && \
6780
rm -rf cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl && \
81+
curl -fLO https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv${CARGO_AUDIT_VERSION}/cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz && \
82+
tar xf cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz && \
83+
cp cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}/cargo-audit /usr/local/bin/ && \
84+
rm -rf cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION} && \
6885
curl -fLO https://github.com/EmbarkStudios/cargo-deny/releases/download/$CARGO_DENY_VERSION/cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl.tar.gz && \
6986
tar xf cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl.tar.gz && \
7087
mv cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl/cargo-deny /usr/local/bin/ && \
@@ -160,14 +177,12 @@ ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/musl/ \
160177
LIBZ_SYS_STATIC=1 \
161178
TARGET=musl
162179

163-
# Install some useful Rust tools from source. This will use the static linking
164-
# toolchain, but that should be OK.
180+
# Install some useful Rust tools from source (as few as we can, because these
181+
# slow down image builds). This will use the static linking toolchain, but that
182+
# should be OK.
165183
#
166-
# We include cargo-audit for compatibility with earlier versions of this image,
167-
# but cargo-deny provides a superset of cargo-audit's features.
168-
RUN env CARGO_HOME=/opt/rust/cargo cargo install -f cargo-audit && \
169-
env CARGO_HOME=/opt/rust/cargo cargo install -f cargo-deb && \
170-
env CARGO_HOME=/opt/rust/cargo cargo install -f mdbook-graphviz && \
184+
# - `cargo-deb` builds Debian packages.
185+
RUN env CARGO_HOME=/opt/rust/cargo cargo install -f cargo-deb && \
171186
rm -rf /opt/rust/cargo/registry/
172187

173188
# Allow sudo without a password.

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
- [Source on GitHub](https://github.com/emk/rust-musl-builder)
66
- [Changelog](https://github.com/emk/rust-musl-builder/blob/master/CHANGELOG.md)
77

8-
**UPDATED:** Major updates in this release which may break some builds. See [the CHANGELOG](https://github.com/emk/rust-musl-builder/blob/master/CHANGELOG.md) for details. If these updates break your build, you can update your `Dockerfile` to use `FROM ekidd/rust-musl-builder:1.48.0` to revert to the previous version.
8+
**UPDATED:** We are now running builds on GitHub, including scheduled builds of `stable` and `beta` every Thursday!
9+
10+
However, **[`rustls`](rustls) now works well** with most of the Rust ecosystem, including `reqwest`, `tokio`, `tokio-postgres`, `sqlx` and many others. The only major project which still requires `libpq` and OpenSSL is [Diesel](https://diesel.rs/). If you don't need `diesel` or `libpq`:
11+
12+
- See if you can switch away from OpenSSL, typically by using `features` in `Cargo.toml` to ask your dependencies to use [`rustls`](rustls) instead.
13+
- If you don't need OpenSSL, try [`cross build --target=x86_64-unknown-linux-musl --release`](https://github.com/rust-embedded/cross) to cross-compile your binaries for `libmusl`. This supports many more platforms, with less hassle!
14+
15+
[rustls]: https://github.com/rustls
916

1017
## What is this?
1118

@@ -186,18 +193,6 @@ If you're using Docker crates which require specific C libraries to be installed
186193

187194
If you need an especially common library, please feel free to submit a pull request adding it to the main `Dockerfile`! We'd like to support popular Rust crates out of the box.
188195

189-
## ARM support (experimental)
190-
191-
To target ARM hard float (Raspberry Pi):
192-
193-
```sh
194-
rust-musl-builder cargo build --target=armv7-unknown-linux-musleabihf --release
195-
```
196-
197-
Binaries will be written to `target/$TARGET_ARCHITECTURE/release`. By default it targets `x86_64-unknown-linux-musl` unless specified with `--target`.
198-
199-
This is missing many of the libraries used by the `x86_64` build, and it should probably be split out of the base image and given its own tags.
200-
201196
## Development notes
202197

203198
After modifying the image, run `./test-image` to make sure that everything works.

0 commit comments

Comments
 (0)