-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yangby-cryptape/pr/upgrade-rust-toolchain
chore: bump rust toolchain from 1.38.0 to 1.41.0
- Loading branch information
Showing
8 changed files
with
192 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from urllib import request | ||
|
||
RUST_VERSION = '1.41.0' | ||
RUSTUP_VERSION = '1.21.1' | ||
|
||
RUST_ARCH = 'x86_64-unknown-linux-gnu' | ||
|
||
DISTRIBUTIONS = [ | ||
# Ubuntu | ||
'xenial', 'bionic', | ||
# CentOS | ||
'centos-7', | ||
] | ||
|
||
|
||
def fetch_rustup_hash(): | ||
url = f'https://static.rust-lang.org/rustup/archive/{RUSTUP_VERSION}/{RUST_ARCH}/rustup-init.sha256' | ||
with request.urlopen(url) as f: | ||
return f.read().decode('utf-8').split()[0] | ||
|
||
|
||
def load_template(dist): | ||
with open(f'templates/{dist}.Dockerfile', 'r') as f: | ||
return f.read() | ||
|
||
def save_dockerfile(dist, contents): | ||
filepath = f'{dist}/Dockerfile' | ||
filedir = os.path.dirname(filepath) | ||
if filedir and not os.path.exists(filedir): | ||
os.makedirs(filedir) | ||
with open(filepath, 'w') as f: | ||
f.write(contents) | ||
|
||
|
||
def generate_dockerfile(dist, rustup_sha256): | ||
template = load_template(dist) | ||
rendered = template \ | ||
.replace('%%RUST_VERSION%%', RUST_VERSION) \ | ||
.replace('%%RUSTUP_VERSION%%', RUSTUP_VERSION) \ | ||
.replace('%%RUSTUP_SHA256%%', rustup_sha256) \ | ||
.replace('%%RUST_ARCH%%', RUST_ARCH) | ||
save_dockerfile(dist, rendered) | ||
|
||
|
||
def main(): | ||
rustup_sha256 = fetch_rustup_hash() | ||
for dist in DISTRIBUTIONS: | ||
generate_dockerfile(dist, rustup_sha256) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM ubuntu:bionic | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
gcc \ | ||
libc6-dev \ | ||
wget \ | ||
libssl-dev \ | ||
git \ | ||
pkg-config \ | ||
libclang-dev clang; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV RUSTUP_HOME=/usr/local/rustup \ | ||
CARGO_HOME=/usr/local/cargo \ | ||
PATH=/usr/local/cargo/bin:$PATH \ | ||
RUSTUP_VERSION=%%RUSTUP_VERSION%% \ | ||
RUSTUP_SHA256=%%RUSTUP_SHA256%% \ | ||
RUST_ARCH=%%RUST_ARCH%% | ||
|
||
RUN set -eux; \ | ||
url="https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${RUST_ARCH}/rustup-init"; \ | ||
wget "$url"; \ | ||
echo "${RUSTUP_SHA256} *rustup-init" | sha256sum -c -; \ | ||
chmod +x rustup-init | ||
|
||
ENV RUST_VERSION=%%RUST_VERSION%% | ||
|
||
RUN set -eux; \ | ||
./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION; \ | ||
rm rustup-init; \ | ||
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ | ||
rustup --version; \ | ||
cargo --version; \ | ||
rustc --version; \ | ||
openssl version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM centos:7 | ||
|
||
ENV PATH=/root/.cargo/bin:$PATH | ||
|
||
RUN set -eux; \ | ||
yum install -y centos-release-scl; \ | ||
yum install -y git curl make gcc-c++ openssl-devel llvm-toolset-7; \ | ||
yum clean all; \ | ||
rm -rf /var/cache/yum | ||
|
||
ENV RUSTUP_HOME=/usr/local/rustup \ | ||
CARGO_HOME=/usr/local/cargo \ | ||
PATH=/usr/local/cargo/bin:$PATH \ | ||
RUSTUP_VERSION=%%RUSTUP_VERSION%% \ | ||
RUSTUP_SHA256=%%RUSTUP_SHA256%% \ | ||
RUST_ARCH=%%RUST_ARCH%% | ||
|
||
RUN set -eux; \ | ||
url="https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${RUST_ARCH}/rustup-init"; \ | ||
curl -LO "$url"; \ | ||
echo "${RUSTUP_SHA256} *rustup-init" | sha256sum -c -; \ | ||
chmod +x rustup-init | ||
|
||
ENV RUST_VERSION=%%RUST_VERSION%% | ||
|
||
RUN set -eux; \ | ||
./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION; \ | ||
rm rustup-init; \ | ||
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ | ||
rustup --version; \ | ||
cargo --version; \ | ||
rustc --version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM ubuntu:xenial | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
gcc \ | ||
libc6-dev \ | ||
wget \ | ||
git \ | ||
pkg-config \ | ||
libclang-dev clang; \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV OPENSSL_VERSION=1.1.1c \ | ||
OPENSSL_SHA256=f6fb3079ad15076154eda9413fed42877d668e7069d9b87396d0804fdb3f4c90 | ||
|
||
RUN set -eux; \ | ||
url="https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"; \ | ||
wget "$url"; \ | ||
echo "${OPENSSL_SHA256} *openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c -; \ | ||
tar -xzf "openssl-${OPENSSL_VERSION}.tar.gz"; \ | ||
cd openssl-${OPENSSL_VERSION}; \ | ||
./config no-shared no-zlib -fPIC -DOPENSSL_NO_SECURE_MEMORY; \ | ||
make; \ | ||
make install; \ | ||
cd ..; \ | ||
rm -rf openssl-${OPENSSL_VERSION} openssl-${OPENSSL_VERSION}.tar.gz | ||
|
||
ENV RUSTUP_HOME=/usr/local/rustup \ | ||
CARGO_HOME=/usr/local/cargo \ | ||
PATH=/usr/local/cargo/bin:$PATH \ | ||
RUSTUP_VERSION=%%RUSTUP_VERSION%% \ | ||
RUSTUP_SHA256=%%RUSTUP_SHA256%% \ | ||
RUST_ARCH=%%RUST_ARCH%% | ||
|
||
RUN set -eux; \ | ||
url="https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${RUST_ARCH}/rustup-init"; \ | ||
wget "$url"; \ | ||
echo "${RUSTUP_SHA256} *rustup-init" | sha256sum -c -; \ | ||
chmod +x rustup-init | ||
|
||
ENV RUST_VERSION=%%RUST_VERSION%% | ||
|
||
RUN set -eux; \ | ||
./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION; \ | ||
rm rustup-init; \ | ||
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ | ||
rustup --version; \ | ||
cargo --version; \ | ||
rustc --version; \ | ||
openssl version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters