-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(otaclient_release): add Dockerfile for otaclient application image (…
…#477) This PR adds dockerfile for creating otaclient application docker image, which is for further creating otaclient squashfs application image. A README.md is also added containing the steps to create zstd compressed otaclient application squashfs image.
- Loading branch information
1 parent
3887ecd
commit c70e3ca
Showing
2 changed files
with
112 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
ARG UBUNTU_BASE="ubuntu:22.04" | ||
|
||
FROM ${UBUNTU_BASE} AS image_build | ||
|
||
ARG OTACLIENT_WHL | ||
COPY ./${OTACLIENT_WHL} /tmp | ||
|
||
ARG OTACLIENT_INSTALLATION="/otaclient" | ||
ENV OTACLIENT_VENV=${OTACLIENT_INSTALLATION}/venv | ||
|
||
RUN set -eux; \ | ||
apt-get update -qq; \ | ||
apt-get install --no-install-recommends -y \ | ||
python3-venv \ | ||
python3-pip; \ | ||
# setup virtual env | ||
mkdir -p ${OTACLIENT_VENV}; \ | ||
cd ${OTACLIENT_INSTALLATION}; \ | ||
python3 -m venv ${OTACLIENT_VENV}; \ | ||
. ${OTACLIENT_VENV}/bin/activate; \ | ||
# install otaclient | ||
python3 -m pip install -U pip; \ | ||
python3 -m pip install /tmp/${OTACLIENT_WHL}; \ | ||
# cleanup | ||
apt-get clean; \ | ||
\ | ||
# NOTE: copy from docker official python3 dockerfile | ||
find ${OTACLIENT_VENV} -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests -o -name idle_test -o -name __pycache__ \) \) \ | ||
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ | ||
\) -exec rm -rf '{}' + \ | ||
; \ | ||
\ | ||
rm -rf \ | ||
/root/.cache \ | ||
/tmp/* \ | ||
/var/lib/apt/lists/* \ | ||
/var/tmp/* | ||
|
||
FROM ${UBUNTU_BASE} | ||
|
||
ARG OTACLIENT_VERSION | ||
ARG OTACLIENT_INSTALLATION="/otaclient" | ||
|
||
COPY --from=image_build ${OTACLIENT_INSTALLATION} ${OTACLIENT_INSTALLATION} | ||
|
||
ENV OTACLIENT_VERSION=${OTACLIENT_VERSION} | ||
ENV OTACLIENT_INSTALLATION=${OTACLIENT_INSTALLATION} | ||
ENV OTACLIENT_VENV=${OTACLIENT_INSTALLATION}/venv | ||
|
||
RUN set -eux; \ | ||
ln -s ${OTACLIENT_VENV}/bin/python3 /otaclient_py3; \ | ||
apt-get update -qq; \ | ||
apt-get install --no-install-recommends -y \ | ||
python3; \ | ||
apt-get clean; \ | ||
rm -rf \ | ||
/root/.cache \ | ||
/tmp/* \ | ||
/var/lib/apt/lists/* \ | ||
/var/tmp/* | ||
|
||
CMD ["sh", "-c", "${OTACLIENT_VENV}/bin/python3 -m otaclient"] |
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,48 @@ | ||
## otaclient application squashfs image creation howto | ||
|
||
Please note that upto otaclient v3.8.x, otaclient still cannot run inside container environment. | ||
Future PRs will implement the above feature. | ||
|
||
Also the container environment needed to be carefully setup to let otaclient run as expected. See related document for more details. | ||
|
||
### Steps to create otaclient application image | ||
|
||
1. download the otaclient whl package | ||
|
||
2. build docker image | ||
|
||
```bash | ||
sudo docker build \ | ||
--no-cache --build-arg=OTACLIENT_VERSION=3.8.4 \ | ||
--build-arg=OTACLIENT_WHL=otaclient-3.8.4-py3-none-any.whl -t otaclient:3.8.4 . | ||
``` | ||
|
||
3. export docker image and create zstd compressed squashfs | ||
|
||
```bash | ||
# enter root shell | ||
sudo -s | ||
|
||
docker create otaclient_v3.8.4_export otaclient:3.8.4 | ||
docker export otaclient_v3.8.4 | mksquashfs - otaclient_v3.8.4.squashfs \ | ||
-tar -b 1M \ | ||
-mkfs-time 1729810800 \ | ||
-all-time 1729810800 \ | ||
-no-xattrs \ | ||
-all-root \ | ||
-progress \ | ||
-comp zstd \ | ||
-Xcompression-level 22 | ||
``` | ||
|
||
## Step to create otaclient app image update patch | ||
|
||
```bash | ||
zstd --patch-from=otaclient_v3.7.1.squashfs otaclient_v3.8.2.squashfs -o v3.7.1-v3.8.2_patch | ||
``` | ||
|
||
## Step to apply app image update patch | ||
|
||
```bash | ||
zstd -d --patch-from=otaclient_v3.7.1.squashfs v3.7.1-v3.8.2_patch -o v3.8.2_from_patch.squashfs | ||
``` |