Open lsandov1 opened 5 years ago
Yes, the container version is following clearlinux/os-core:latest when multi-stage build.
To construct any multi-stage image with a desired CLR version, we could rebuild clearlinux/os-core with desired CLR version first.
docker build --no-cache=true -t clearlinux/os-core:latest --build-arg swupd_args="-m 30170" os-core/
Then rebuild the dockerfile (for cgit, we need to rebuild clearlinux/httpd, then clearlinux/cgit):
docker build --no-cache=true -t clearlinux/httpd:latest --build-arg httpd/
docker build --no-cache=true -t clearlinux/cgit:latest --build-arg cgit/
Please share if this way works for you.
Thanks a lot for your finding!
Or if you don't care much about the container image size (mutli-build way with os-core may save up to 150 MB), you can use the below traditional way.
" FROM clearlinux/httpd
ARG swupd_args RUN swupd update --no-boot-update $swupd_args RUN swupd bundle-add sudo curl scm-server $swupd_args \ && rm -rf /var/lib/swupd/*
COPY cgitrc /etc/cgitrc COPY httpd-cgit.conf /etc/httpd/conf.d/httpd-cgit.conf "
@liujianjunhq thanks for sharing the workaround, although I have not tested. So we either document it (what you mentioned) or fix the dockerfile somehow. This can be an approach
@@ -5,13 +5,9 @@ FROM clearlinux:latest AS builder
# correct
RUN swupd update --no-boot-update $swupd_args
-# Grab os-release info from the minimal base image so
-# that the new content matches the exact OS version
-COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
-
# Install additional content in a target directory
# using the os version from the minimal base
-RUN source /os-release && \
+RUN source /usr/lib/os-release && \
mkdir /install_root \
&& swupd os-install -V ${VERSION_ID} \
--path /install_root --statedir /swupd-state \
however, I have not tested it yet.
@qzheng527 right. We do care about the space. We are using bundles with heavy packages so footprint is important. BTW, I did some analysis on the saved spaced, and the savings is around 10% compared to the non-multi-stage approach, so the multi-stage is indeed a good strategy (in terms of space and modularity..)
@lsandov1 thanks a lot for your sharing. Will document it and update the github. The reason to use "COPY --from=clearlinux/os-core:latest /usr/lib/os-release /" and "RUN source /os-release" is to keep the up layer image to have the same version as clearlinux/os-core, the base layer. Also, with the same clearlinux/os-core as base layer, we could share it among difference clearlinux containers to save further disk size. So, we need to keep the current approach. Thanks!
@bryteise
clone
clearlinux/dockerfiles
repositoryconstruct any multi-stage image ( for example
cgit
) with a desired CLR versiondocker build --no-cache=true -t clearlinux/cgit --build-arg="-m 30170" dockerfiles/cgit/
Desired result: container version should be the same as the one specified in the docker build parameter.
Current result: versions differ. In this case, 30170 != 30140. Seems that the one defining the version is
clearlinux/os-core:latest