Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add aarch64 #18

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,33 @@ bionic/Dockerfile: gen-dockerfiles templates/bionic.Dockerfile
centos-7/Dockerfile: gen-dockerfiles templates/centos-7.Dockerfile
python3 gen-dockerfiles

build-all: build-bionic build-centos-7
aarch64/Dockerfile: gen-dockerfiles templates/aarch64.Dockerfile
python3 gen-dockerfiles

build-all: build-bionic build-centos-7 build-aarch64

build-bionic: bionic/Dockerfile
docker build -f bionic/Dockerfile --tag ${DOCKERHUB_REPO}:bionic-${IMAGE_VERSION} .

build-centos-7: centos-7/Dockerfile
docker build -f centos-7/Dockerfile --tag ${DOCKERHUB_REPO}:centos-7-${IMAGE_VERSION} .

.PHONY: build-all build-bionic build-centos-7
build-aarch64: aarch64/Dockerfile
docker build -f aarch64/Dockerfile --tag ${DOCKERHUB_REPO}:aarch64-${IMAGE_VERSION} .

push-all: push-bionic push-centos-7
.PHONY: build-all build-bionic build-centos-7 build-aarch64
push-all: push-bionic push-centos-7 push-aarch64

push-bionic: build-bionic
docker push ${DOCKERHUB_REPO}:bionic-${IMAGE_VERSION}

push-centos-7: build-centos-7
docker push ${DOCKERHUB_REPO}:centos-7-${IMAGE_VERSION}

.PHONY: push-all push-bionic push-centos-7
push-aarch64: build-aarch64
docker push ${DOCKERHUB_REPO}:aarch64-${IMAGE_VERSION}

.PHONY: push-all push-bionic push-centos-7 push-aarch64

test-all: test-bionic test-centos-7

Expand Down
57 changes: 57 additions & 0 deletions aarch64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM arm64v8/ubuntu

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
gcc \
g++ \
libc6-dev \
wget \
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=1.26.0 \
RUSTUP_SHA256=673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800 \
RUST_ARCH=aarch64-unknown-linux-gnu \
OPENSSL_VERSION=3.1.3 \
OPENSSL_SHA256=f0316a2ebd89e7f2352976445458689f80302093788c466692fb2a188b2eacf6

RUN set -eux; \
url="https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"; \
wget --no-check-certificate "$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


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=1.71.1

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;

RUN git config --global --add safe.directory /ckb
24 changes: 11 additions & 13 deletions gen-dockerfiles
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ RUST_VERSION = '1.71.1'
RUSTUP_VERSION = '1.26.0'
OPENSSL_VERSION = '3.1.3'

RUST_ARCH = 'x86_64-unknown-linux-gnu'

DISTRIBUTIONS = [
DISTRIBUTIONS = {
# Ubuntu
'bionic',
'bionic': 'x86_64-unknown-linux-gnu',
# CentOS
'centos-7',
]
'centos-7': 'x86_64-unknown-linux-gnu',
# Arch64
'aarch64': 'aarch64-unknown-linux-gnu',
}


def fetch_rustup_hash():
def fetch_rustup_hash(RUST_ARCH):
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]
Expand All @@ -27,7 +27,6 @@ def fetch_openssl_hash():
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()
Expand All @@ -40,8 +39,7 @@ def save_dockerfile(dist, contents):
with open(filepath, 'w') as f:
f.write(contents)


def generate_dockerfile(dist, rustup_sha256, openssl_sha256):
def generate_dockerfile(dist, rustup_sha256, openssl_sha256, RUST_ARCH):
template = load_template(dist)
rendered = template \
.replace('%%RUST_VERSION%%', RUST_VERSION) \
Expand All @@ -54,10 +52,10 @@ def generate_dockerfile(dist, rustup_sha256, openssl_sha256):


def main():
rustup_sha256 = fetch_rustup_hash()
openssl_sha256 = fetch_openssl_hash()
for dist in DISTRIBUTIONS:
generate_dockerfile(dist, rustup_sha256, openssl_sha256)
for dist, arch in DISTRIBUTIONS.items():
rustup_sha256 = fetch_rustup_hash(arch)
generate_dockerfile(dist, rustup_sha256, openssl_sha256, arch)


if __name__ == '__main__':
Expand Down
57 changes: 57 additions & 0 deletions templates/aarch64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM arm64v8/ubuntu

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
gcc \
g++ \
libc6-dev \
wget \
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%% \
OPENSSL_VERSION=%%OPENSSL_VERSION%% \
OPENSSL_SHA256=%%OPENSSL_SHA256%%

RUN set -eux; \
url="https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"; \
wget --no-check-certificate "$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


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;

RUN git config --global --add safe.directory /ckb
Loading