Skip to content

Commit f7c615b

Browse files
committed
Update README
1 parent eb0c6f6 commit f7c615b

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<div align="center">
2+
<p>English | <a href="README.zh-CN.md">简体中文</a></p>
3+
</div>
4+
15
# docker-mini-openharmony
26
Because the userland of OpenHarmony can run on the Linux kernel, containerization of OpenHarmony is feasible.
37

@@ -21,6 +25,13 @@ docker run -itd --name=ohos ghcr.io/hqzing/docker-mini-openharmony:latest
2125
docker exec -it ohos sh
2226
```
2327

28+
Available tags
29+
| Tag | Description |
30+
|---------|-------------------------------------------------------------------------|
31+
| latest | The latest release. currently equivalent to v6.0. |
32+
| v6.0 | An image based on OpenHarmony 6.0 Release. |
33+
| main | The mainline version, built using the latest build scripts from the main branch of this repository. |
34+
2435
## Need more software?
2536
The OpenHarmony root filesystem (rootfs) is composed of three main components: [musl libc](https://musl.libc.org), [toybox](https://landley.net/toybox), and [mksh](https://github.com/MirBSD/mksh). Command-line utilities are provided by `toybox`, which offers only a minimal set of tools.
2637

README.zh-CN.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<div align="center">
2+
<p><a href="README.md">English</a> | 简体中文 </p>
3+
</div>
4+
5+
# docker-mini-openharmony
6+
由于 OpenHarmony 的 userland 可以运行在 Linux kernel 上,因此 OpenHarmony 的容器化是可行的。
7+
8+
该项目将 OpenHarmony 的 mini rootfs 做成 Docker 容器镜像,使我们能够使用 Linux 服务器来运行和测试我们的命令行程序,而不用依赖 OpenHarmony 物理设备。
9+
10+
## 支持的架构
11+
仅支持 arm64
12+
13+
## 用法
14+
从 GitHub Container Registry 拉取镜像
15+
```sh
16+
docker pull ghcr.io/hqzing/docker-mini-openharmony:latest
17+
18+
# 国内的镜像站
19+
# docker pull ghcr.nju.edu.cn/hqzing/docker-mini-openharmony:latest
20+
```
21+
22+
使用默认命令运行容器
23+
```sh
24+
docker run -itd --name=ohos ghcr.io/hqzing/docker-mini-openharmony:latest
25+
docker exec -it ohos sh
26+
```
27+
28+
可用的标签
29+
| 标签 | 描述 |
30+
|------------|---------------------------------------------------------- |
31+
| latest | 最新的正式版本,当前等价于 v6.0 |
32+
| v6.0 | 基于 OpenHarmony 6.0 Release 制作的镜像 |
33+
| main | 主干版本,基于本仓库 main 分支的最新构建脚本进行构建 |
34+
35+
## 需要更多软件?
36+
OpenHarmony 的根文件系统(rootfs)主要由三个部分组成:[musl libc](https://musl.libc.org)[toybox](https://landley.net/toybox)[mksh](https://github.com/MirBSD/mksh)。命令行实用工具(Command-line utilities)由 `toybox` 提供,但 `toybox` 只提供了很少量的命令。
37+
38+
由于 OpenHarmony 目前还没有包管理器,所以我们没法通过一条命令去自动下载安装软件包,只能手动下载。
39+
40+
为了方便用户手动下载软件,容器镜像中预置了一个 `curl`
41+
42+
许多为 linux-musl-arm64 平台编译的软件都可以在这个容器中运行。例如,来自 Alpine Linux 软件仓库的 `make` 就是兼容的:
43+
44+
```sh
45+
package_name="make"
46+
alpine_repository="http://dl-cdn.alpinelinux.org/alpine/v3.22/main/aarch64"
47+
curl -fsSL ${alpine_repository}/APKINDEX.tar.gz | tar -zx -C /tmp
48+
package_version=$(grep -A1 "^P:${package_name}$" /tmp/APKINDEX | sed -n "s/^V://p")
49+
apk_file_name=${package_name}-${package_version}.apk
50+
curl -L -O ${alpine_repository}/${apk_file_name}
51+
tar -zxf ${apk_file_name} -C /
52+
53+
# 现在你可以使用 make 命令了
54+
```
55+
56+
你也可以在 [这个社区](https://gitcode.com/OpenHarmonyPCDeveloper) 进行探索,里面有一些已经移植到 OpenHarmony 平台上的软件。
57+
58+
## 在 GitHub 工作流中使用
59+
要在 GitHub 工作流中使用这个镜像,首先你使用的执行机需要是 arm64 架构的。GitHub 提供了 arm64 架构的 [partner runner images](https://github.com/actions/partner-runner-images),我们可以免费使用它们。
60+
61+
需要注意的是,GitHub 上许多预置的工作流(例如 actions/checkout)依赖于 Node.js 运行时环境,我们需要为此做一些特殊准备。
62+
63+
```yml
64+
jobs:
65+
buid:
66+
name: build
67+
runs-on: ubuntu-24.04-arm
68+
container:
69+
image: ghcr.io/hqzing/docker-mini-openharmony:latest
70+
volumes:
71+
- /tmp/node20:/__e/node20:rw,rshared
72+
steps:
73+
- name: Setup node for actions
74+
run: |
75+
curl -L -O https://github.com/hqzing/ohos-node/releases/download/v24.2.0/node-v24.2.0-openharmony-arm64.tar.gz
76+
mkdir /__e/node20/bin
77+
tar -zxf node-v24.2.0-openharmony-arm64.tar.gz -C /opt
78+
ln -s /opt/node-v24.2.0-openharmony-arm64/bin/node /__e/node20/bin/node
79+
- name: Chekout
80+
uses: actions/checkout@v4
81+
# 编写你的业务...
82+
```
83+
84+
这个方案参考了:https://github.com/actions/runner/issues/801.
85+
86+
## 从源码构建镜像
87+
88+
环境要求:
89+
- Ubuntu 22.04 x64(不支持 24.04)
90+
- 至少 300GB 的可用磁盘空间
91+
- 机器上安装了 Docker
92+
- 一个通畅的网络环境,可以正常访问 GitHub、Gitee 等网站
93+
- 使用 root 用户 (OpenHarmony 源码里面的 build.sh 就需要 root, 因此这个项目也同样需要)
94+
95+
建议:
96+
- 建议构建之前重置你的构建机,使用一个干净全新的构建机来进行构建。这可以避免很多因环境问题导致的构建失败。
97+
- 建议使用尽可能高的带宽和 CPU 规格,因为构建一个操作系统需要下载和编译非常多的文件。
98+
99+
构建容器镜像的命令如下:
100+
```sh
101+
git clone https://github.com/hqzing/docker-mini-openharmony
102+
cd docker-mini-openharmony
103+
./build-images.sh
104+
./build-curl.sh
105+
./build-rootfs.sh
106+
DOCKER_BUILDKIT=1 docker buildx build --platform linux/arm64 -t docker-mini-openharmony:latest .
107+
```
108+
109+
由于构建机是 x64 架构的,而容器是 arm64 架构的,所以你不能直接在构建机上运行这个容器。你需要将镜像导出或者发布,放到 arm64 架构的服务器上去运行。

0 commit comments

Comments
 (0)