OpenHarmony开发者论坛
标题:
OpenHarmony南向统一编译的docker镜像来了
[打印本页]
作者:
冷钦街
时间:
2023-12-19 20:34
标题:
OpenHarmony南向统一编译的docker镜像来了
[md]由于我自己的南向设备开发平台的需求,我将当前几个不同的docker镜像版本进行了整合,经过一段时间的攻关和验证,目前整合已完成,新版本的Dockerfile如下,这个不是公共需求,所以没有提交主干,存这里备个案,需要的伙伴自行使用。使用方法如下:
1。 在Dockerfile所在目录执行如下命令生成镜像
```
docker build -t oh_compile:v1 .
```
2。 使用docker images查看oh_compile:v1是否成功构建
其它使用方式与官方文档一致了。
https://gitee.com/openharmony/docs/tree/master/docker
本次整合后的完整Dockerfile如下,我额外调整了一下WORKDIR 为 /root, 你们可以恢复成/home/openharmony
```
FROM ubuntu:20.04
WORKDIR /root
ARG DEBIAN_FRONTEND=noninteractive
RUN TZ=Asia/Shanghai && sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list \
&& sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list \
&& apt-get update -y \
&& apt-get install -y locales default-jre default-jdk libelf-dev bc rsync mtools dosfstools \
wget curl ssh vim ccache libxi-dev libxrandr-dev libxcursor-dev libxinerama-dev libpixman-1-dev \
qemu gcc-arm-none-eabi xsltproc lib32z1-dev libgl1-mesa-dev libx11-dev libxml2-dev kmod \
libssl-dev openssl scons python3.8 mtd-utils binutils libglib2.0-dev genext2fs apt-utils gnupg \
zlib1g-dev m4 u-boot-tools build-essential unzip make libc6-dev-i386 x11proto-core-dev g++ \
libncurses5 libtinfo5 git-lfs gcc cpio perl ruby flex bison python3-pip zip git gperf \
doxygen liblz4-tool python3.8-distutils libffi-dev zlib* e2fsprogs device-tree-compiler \
git-core libdwarf-dev lib32ncurses5-dev gnutls-bin gcc-arm-linux-gnueabi \
binutils-dev grsync xxd jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils \
quota ppp libtinfo-dev libncurses5-dev libncursesw5 libstdc++6 \
&& wget -P /home/tools
https://repo.huaweicloud.com/har ... 86_64-linux.tar.bz2
\
&& wget -P /home/tools
https://repo.huaweicloud.com/har ... -gen-0.65-linux.tar
\
&& wget -P /home/tools
https://repo.huaweicloud.com/har ... -linux-7.3.0.tar.gz
\
&& wget -P /home/tools
https://mirrors.huaweicloud.com/ ... .1-linux-x64.tar.xz
\
&& wget -P /home/tools
https://repo.huaweicloud.com/har ... x-x86-1.10.1.tar.gz
\
&& wget -P /home/tools
https://repo.huaweicloud.com/har ... nux-x86-2021.tar.gz
\
&& wget -P /home/tools
https://repo.huaweicloud.com/har ... 05-20221030.tar.bz2
\
&& wget -P /home/tools
https://hm-verify.obs.cn-north-4 ... m/qemu-5.2.0.tar.xz
\
&& locale-gen "en_US.UTF-8" \
&& rm -rf /bin/sh /usr/bin/python /usr/bin/python3 \
&& mkdir -p /home/tools/gn \
&& mkdir -p /home/tools/ninja \
&& ln -s /bin/bash /bin/sh \
&& ln -s /usr/bin/python3.8 /usr/bin/python3 \
&& ln -s /usr/bin/python3.8 /usr/bin/python \
&& pip3 install --trusted-host
https://repo.huaweicloud.com
\
-i
https://repo.huaweicloud.com/repository/pypi/simple
\
pycryptodome ecdsa redis kconfiglib setuptools requests ohos-build \
pymongo pyyaml prompt_toolkit==1.0.14 json2html yagmail python-jenkins \
&& tar -xvf /home/tools/hc-gen-0.65-linux.tar -C /home/tools \
&& tar -xvf /home/tools/gcc_riscv32-linux-7.3.0.tar.gz -C /home/tools \
&& tar -xvf /home/tools/clang_linux-x86_64-36cd05-20221030.tar.bz2 -C /home/tools \
&& tar -xvf /home/tools/ninja-linux-x86-1.10.1.tar.gz -C /home/tools/ninja \
&& tar -xvf /home/tools/gn-linux-x86-2021.tar.gz -C /home/tools/gn \
&& tar -xJf /home/tools/node-v14.19.1-linux-x64.tar.xz -C /home/tools \
&& tar -jxvf /home/tools/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 -C /home/tools \
&& tar -xJf /home/tools/qemu-5.2.0.tar.xz -C /home/tools \
&& cp /home/tools/node-v14.19.1-linux-x64/bin/node /usr/local/bin \
&& ln -s /home/tools/node-v14.19.1-linux-x64/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
&& ln -s /home/tools/node-v14.19.1-linux-x64/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
&& sed -i '$aexport PATH=/home/tools/hc-gen
PATH' /root/.bashrc \
&& sed -i '$aexport PATH=/home/tools/gcc_riscv32/bin
PATH' /root/.bashrc \
&& sed -i '$aexport PATH=/home/tools/gcc-arm-none-eabi-10.3-2021.10/bin
PATH' /root/.bashrc \
&& sed -i '$aexport PATH=/home/tools/clang_linux-x86_64-36cd05-20221030/bin
PATH' /root/.bashrc \
&& sed -i '$aexport PATH=/home/tools/ninja
PATH' /root/.bashrc \
&& sed -i '$aexport PATH=/home/tools/gn
PATH' /root/.bashrc \
&& sed -i '$aexport PATH=/home/tools/node-v14.19.1-linux-x64/bin
PATH' /root/.bashrc \
&& sed -i '$aexport PATH=/root/.local/bin
PATH' /root/.bashrc \
&& export PATH=/home/tools/hc-gen
PATH \
&& export PATH=/home/tools/gcc_riscv32/bin
PATH \
&& export PATH=/home/tools/gcc-arm-none-eabi-10.3-2021.10/bin:$PATH \
&& export PATH=/home/tools/clang_linux-x86_64-36cd05-20221030/bin:$PATH \
&& export PATH=/home/tools/ninja:$PATH \
&& export PATH=/home/tools/gn:$PATH \
&& export PATH=/home/tools/node-v14.19.1-linux-x64/bin:$PATH \
&& export PATH=/root/.local/bin:$PATH \
&& cd /home/tools/qemu-5.2.0 \
&& mkdir build && cd build \
&& ../configure --target-list=arm-softmmu \
&& make -j \
&& make install \
&& cd /root \
&& rm -rf /home/tools/*.xz \
&& rm -rf /home/tools/*.gz \
&& rm -rf /home/tools/*.tar \
&& rm -rf /home/tools/*.bz2 \
&& rm -rf /home/tools/qemu-5.2.0 \
&& npm install -g @ohos/hpm-cli --registry
https://mirrors.huaweicloud.com/repository/npm/
\
&& pip3 install ohos-build
ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 TZ=Asia/Shanghai
CMD ["/bin/bash"]
```
[/md]
作者:
martinhu
时间:
2023-12-21 13:13
docker默认使用root账户,不太安全吧;怎么使用非root账户编译呢?
作者:
冷钦街
时间:
2023-12-21 16:44
回复
martinhu
: 这个其它小伙伴研究一下,目前我这边还没有遇到这类安全问题,感觉docker里面的root与主机的root有区别。
欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/)
Powered by Discuz! X3.5