Skip to content

Commit

Permalink
Add CI docker image for ohos
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jan 8, 2025
1 parent f0e3898 commit 172fd58
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/docker_images/ohos-5.0.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:24.04

SHELL ["/bin/bash", "-c"]
VOLUME ["/aws_lc_rs"]

WORKDIR /

RUN apt-get update && \
apt-get install -y ca-certificates build-essential cmake git wget curl jq unzip clang sudo && \
apt-get autoremove --purge -y && \
apt-get clean && \
apt-get autoclean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*

RUN mkdir /ohos && \
wget --progress=dot:giga https://repo.huaweicloud.com/openharmony/os/5.0.0-Release/ohos-sdk-windows_linux-public.tar.gz && \
wget https://repo.huaweicloud.com/openharmony/os/5.0.0-Release/ohos-sdk-windows_linux-public.tar.gz.sha256 && \
diff <(sha256sum ohos-sdk-windows_linux-public.tar.gz | cut -d ' ' -f 1) ohos-sdk-windows_linux-public.tar.gz.sha256 && \
tar zxvf ohos-sdk-windows_linux-public.tar.gz -C /ohos && \
cd /ohos/linux && \
unzip native-linux-x64-5.0.0.71-Release.zip && \
rm -rf /ohos/windows /ohos/linux/*.zip

RUN useradd -m docker
USER docker
RUN cd "${HOME}" && \
git config --global --add safe.directory '*' && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > ./rustup.sh && \
chmod +x ./rustup.sh && \
./rustup.sh -y && \
. "${HOME}/.cargo/env" && \
cargo install --locked bindgen-cli && \
rustup component add rustfmt clippy && \
rustup target add aarch64-unknown-linux-ohos armv7-unknown-linux-ohos x86_64-unknown-linux-ohos && \
rm ./rustup.sh

COPY aws_lc_rs_build.sh /
COPY entry.sh /

ENV CMAKE_TOOLCHAIN_FILE=/ohos/linux/native/build/cmake/ohos.toolchain.cmake
ENV OHOS_NDK_HOME=/ohos/linux

ENTRYPOINT ["/entry.sh"]
23 changes: 23 additions & 0 deletions .github/docker_images/ohos-5.0.0/aws_lc_rs_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex -o pipefail

. "${HOME}/.cargo/env"
SRC_DIR="${SRC_DIR:-/aws_lc_rs}"

pushd "${SRC_DIR}"

declare -A target_map
target_map[aarch64-unknown-linux-ohos]="aarch64-linux-ohos"
target_map[armv7-unknown-linux-ohos]="arm-linux-ohos"
target_map[x86_64-unknown-linux-ohos]="x86_64-linux-ohos"

for target in aarch64-unknown-linux-ohos armv7-unknown-linux-ohos x86_64-unknown-linux-ohos
do
export CPATH=/ohos/linux/native/sysroot/usr/include/:/ohos/linux/native/sysroot/usr/include/${target_map[${target}]}
cargo build -p aws-lc-rs --target ${target}
done

popd # ${SRC_DIR}
22 changes: 22 additions & 0 deletions .github/docker_images/ohos-5.0.0/build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Ubuntu:
# sudo apt-get install jq

# Amazon Linux:
# sudo yum install jq

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

EXTRA_ARGS=()
if [[ -n "${GOPROXY:+x}" ]]; then
EXTRA_ARGS=("--build-arg" "GOPROXY=${GOPROXY}" "${EXTRA_ARGS[@]}")
fi

docker build -t ohos:5.0.0 . --load "${EXTRA_ARGS[@]}"
7 changes: 7 additions & 0 deletions .github/docker_images/ohos-5.0.0/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex -o pipefail

/aws_lc_rs_build.sh "${argv[@]}"

0 comments on commit 172fd58

Please sign in to comment.