-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrustc.def
More file actions
48 lines (37 loc) · 1.76 KB
/
rustc.def
File metadata and controls
48 lines (37 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# The trick for getting Rust binaries to run on a wide variety of linux distros is not static linking libc,
# like I previously thought, but rather to dynamically link a very old version of GNU libc.
# So this container sets up a build environment for Rust using CentOS 7
# which uses a very old GNU libc: v2.17 (from 2012!)
# Probably no one's using anything in production older than that, eh?
Bootstrap: docker
#From: centos:7
# UPDATE: RedHat has taken the old Centos 7 repositories offline,
# so we can't install OS packages anymore. =(
# So use a pre-built rust compiling container instead from cross-rs.
# see here for supported targets:
# https://github.com/cross-rs/cross?tab=readme-ov-file#supported-targets
# and here's where they store all the container images, on GitHub's container repository:
# https://github.com/orgs/cross-rs/packages
# we'll use the `x86_64-unknown-linux-gnu` target
# which has multiple versions:
# https://github.com/cross-rs/cross/pkgs/container/x86_64-unknown-linux-gnu/versions?filters%5Bversion_type%5D=tagged
# container version 0.2.5-centos is Centos 7.9.2009 has glibc v2.17 (from 2012)
From: ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.5-centos
IncludeCmd: no
%environment
# these are only set at continer runtime
export RUSTUP_HOME=/usr/local/rustup
export CARGO_HOME=/usr/local/cargo
export PATH=$CARGO_HOME/bin:$PATH
%post
# need to set envvars at build time too
export RUSTUP_HOME=/usr/local/rustup
export CARGO_HOME=/usr/local/cargo
# install latest version of rustc
mkdir -p "$CARGO_HOME"
mkdir -p "$RUSTUP_HOME"
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
# make a place to download crates
registry_dir=$CARGO_HOME/registry
mkdir -p "$registry_dir"
chmod -R a=rwX "$registry_dir"