Skip to content

Commit 3e51058

Browse files
committed
Refactor Dockerfile to use less layer
Consolidate RUN commands for efficiency and cleanup. Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
1 parent c9a1e31 commit 3e51058

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

Dockerfile

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,35 @@ FROM quay.io/fedora/fedora:43
44
WORKDIR /root/containerbuild
55
# This variable is enabled by Konflux to build the container image hermatically.
66
ARG NO_NETWORK=0
7-
87
# Keep this Dockerfile idempotent for local development rebuild use cases.
98
USER root
10-
RUN rm -rfv /usr/lib/coreos-assembler /usr/bin/coreos-assembler
119

1210
COPY ./src/print-dependencies.sh ./src/deps*.txt ./src/vmdeps*.txt ./src/build-deps.txt /root/containerbuild/src/
1311
COPY ./build.sh /root/containerbuild/
14-
RUN ./build.sh configure_yum_repos
15-
RUN ./build.sh install_rpms
16-
RUN ./build.sh install_ocp_tools
17-
RUN ./build.sh trust_redhat_gpg_keys
12+
RUN rm -rfv /usr/lib/coreos-assembler /usr/bin/coreos-assembler \
13+
&& ./build.sh configure_yum_repos \
14+
&& ./build.sh install_rpms \
15+
&& ./build.sh install_ocp_tools \
16+
&& ./build.sh trust_redhat_gpg_keys
1817

1918
COPY ./ /root/containerbuild/
20-
RUN ./build.sh write_archive_info
21-
RUN ./build.sh make_and_makeinstall
22-
RUN ./build.sh configure_user
23-
RUN ./build.sh patch_osbuild
24-
25-
# clean up scripts (it will get cached in layers, but oh well)
26-
WORKDIR /srv/
27-
RUN chown builder: /srv
28-
RUN rm -rf /root/containerbuild
29-
30-
# allow writing to /etc/passwd from arbitrary UID
31-
# https://docs.openshift.com/container-platform/4.8/openshift_images/create-images.html
32-
RUN chmod g=u /etc/passwd
33-
34-
# also allow adding certificates
35-
RUN chmod -R g=u /etc/pki/ca-trust
36-
37-
# This allows Prow jobs for other projects to use our cosa image as their
38-
# buildroot image (so clonerefs can copy the repo into `/go`). For cosa itself,
39-
# this same hack is inlined in the YAML (see openshift/release link above).
40-
RUN mkdir -p /go && chmod 777 /go
41-
42-
# run as `builder` user
19+
RUN ./build.sh write_archive_info \
20+
&& ./build.sh make_and_makeinstall \
21+
&& ./build.sh configure_user \
22+
&& ./build.sh patch_osbuild \
23+
# clean up scripts (it will get cached in layers, but oh well)
24+
&& chown builder: /srv \
25+
&& rm -rf /root/containerbuild \
26+
# allow writing to /etc/passwd from arbitrary UID
27+
# https://docs.openshift.com/container-platform/4.8/openshift_images/create-images.html
28+
&& chmod g=u /etc/passwd \
29+
# also allow adding certificates
30+
&& chmod -R g=u /etc/pki/ca-trust \
31+
# This allows Prow jobs for other projects to use our cosa image as their
32+
# buildroot image (so clonerefs can copy the repo into `/go`). For cosa itself,
33+
# this same hack is inlined in the YAML (see openshift/release link above).
34+
&& mkdir -p /go && chmod 777 /go
35+
36+
# run as `builder` user
4337
USER builder
4438
ENTRYPOINT ["/usr/bin/dumb-init", "/usr/bin/coreos-assembler"]

0 commit comments

Comments
 (0)