Skip to content

Commit 5bcdde7

Browse files
authored
Speed up Docker container preparation (#107)
* Use a Dockerfile so CentOS configuration is cachable * Use docker/build-push-action for caching
1 parent 3298eba commit 5bcdde7

File tree

4 files changed

+64
-79
lines changed

4 files changed

+64
-79
lines changed

.github/actions/binary-compatible-builds/action.yml

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,54 @@ name: 'Set up a CentOS 6 container to build releases in'
22
description: 'Set up a CentOS 6 container to build releases in'
33

44
runs:
5-
using: node12
6-
main: 'main.js'
5+
using: "composite"
6+
steps:
7+
# On OSX all we need to do is configure our deployment target as old as
8+
# possible. For now 10.9 is the limit.
9+
- if: runner.os == 'macOS'
10+
shell: bash
11+
run: |
12+
cat >> $GITHUB_ENV <<EOF
13+
MACOSX_DEPLOYMENT_TARGET=10.9
14+
python=python3
15+
EOF
16+
17+
# On Windows we build against the static CRT to reduce dll dependencies
18+
- if: runner.os == 'Windows'
19+
shell: bash
20+
run: |
21+
cat >> $GITHUB_ENV <<EOF
22+
RUSTFLAGS=-Ctarget-feature=+crt-static
23+
python=python
24+
EOF
25+
26+
# ... and on Linux we do fancy things with containers. We'll spawn an old
27+
# CentOS container in the background with a super old glibc, and then we'll run
28+
# commands in there with the `$CENTOS` env var.
29+
- name: Set up Docker Buildx
30+
if: runner.os == 'Linux'
31+
uses: docker/setup-buildx-action@v2
32+
33+
- name: Build old Linux container
34+
if: runner.os == 'Linux'
35+
uses: docker/build-push-action@v3
36+
with:
37+
context: ${{ github.action_path }}/docker
38+
load: true
39+
tags: binary-compatible-builds
40+
cache-from: type=gha
41+
cache-to: type=gha,mode=max
42+
43+
- if: runner.os == 'Linux'
44+
shell: bash
45+
run: |
46+
# FIXME(rust-lang/rust#80703) LD_LIBRARY_PATH shouldn't be necessary
47+
docker run -di --name centos -v $PWD:$PWD -v $(rustc --print sysroot):/rust:ro \
48+
--env LD_LIBRARY_PATH=/rust/lib \
49+
--env PATH="/opt/rh/devtoolset-8/root/usr/bin:$PATH:/rust/bin" \
50+
binary-compatible-builds
51+
52+
cat >> $GITHUB_ENV <<EOF
53+
CENTOS=$GITHUB_ACTION_PATH/run-linux
54+
python=python3
55+
EOF
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM centos:7
2+
3+
# See https://edwards.sdsu.edu/research/c11-on-centos-6/ for where these
4+
RUN yum install -y centos-release-scl cmake xz epel-release python3 unzip git
5+
RUN yum install -y patchelf devtoolset-8-gcc devtoolset-8-binutils devtoolset-8-gcc-c++
6+
7+
# Delete `libstdc++.so` to force gcc to link against `libstdc++.a` instead.
8+
# This is a hack and not the right way to do this, but it ends up doing the
9+
# right thing for now.
10+
RUN rm -f /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so

.github/actions/binary-compatible-builds/main.js

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
exec docker exec --env PREBUILT_ENGINE=${PREBUILT_ENGINE:-} -w $PWD -i centos "$@"

0 commit comments

Comments
 (0)