Skip to content

Commit b94afc9

Browse files
moioncounter
authored andcommitted
Tentative: multi-staged builds
Signed-off-by: Silvio Moioli <[email protected]>
1 parent 0882131 commit b94afc9

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

containers/proxy-salt-broker-image/Dockerfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# HACK: Open Build Service currently only supports short names. Assume short name by default, allow to override to qualified name via ARG
44
ARG BASE_IMAGE_PREFIX=
5-
FROM ${BASE_IMAGE_PREFIX}suse/sle15:15.3
5+
FROM ${BASE_IMAGE_PREFIX}suse/sle15:15.3 AS fat
66

77
# Distro repos
88
RUN zypper addrepo http://download.opensuse.org/distribution/leap/15.3/repo/oss/ main
@@ -11,6 +11,23 @@ RUN zypper addrepo http://download.opensuse.org/update/leap/15.3/sle/ updates
1111
# Product repos
1212
RUN zypper addrepo https://download.opensuse.org/repositories/systemsmanagement:/Uyuni:/Master/images/repo/Uyuni-Proxy-POOL-x86_64-Media1/ product
1313

14+
# Main packages
15+
RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses spacewalk-proxy-salt
16+
17+
# Additional material
18+
COPY uyuni-configure.py /usr/bin/uyuni-configure.py
19+
RUN chmod +x /usr/bin/uyuni-configure.py
20+
21+
# Prepare for slimming down
22+
COPY prepare_target.sh .
23+
RUN sh prepare_target.sh
24+
25+
# Define slim image
26+
FROM ${BASE_IMAGE_PREFIX}suse/sle15:15.3 AS slim
27+
28+
RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses python3 python3-PyYAML python3-pyzmq
29+
COPY --from=fat /target /
30+
1431
# Build Service required labels
1532
# labelprefix=org.opensuse.uyuni.proxy-salt-broker
1633
LABEL org.opencontainers.image.title="Proxy salt-broker container"
@@ -26,9 +43,4 @@ EXPOSE 4506/tcp
2643

2744
VOLUME "/etc/uyuni"
2845

29-
RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses spacewalk-proxy-salt
30-
31-
COPY uyuni-configure.py /usr/bin/uyuni-configure.py
32-
RUN chmod +x /usr/bin/uyuni-configure.py
33-
3446
CMD uyuni-configure.py && salt-broker
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# Moves to /target any file to be preserved in the slimmed-down image
3+
4+
set -xe
5+
6+
mkdir -p /target/etc/rhn
7+
mv /etc/rhn/rhn*.conf /target/etc/rhn/rhn.conf
8+
9+
mkdir -p /target/etc/salt
10+
mv /etc/salt/broker /target/etc/salt
11+
12+
mkdir -p /target/usr/share/rhn/config-defaults
13+
mv /usr/share/rhn/config-defaults/rhn*.conf /target/usr/share/rhn/config-defaults
14+
15+
mkdir -p /target/usr/bin
16+
mv /usr/bin/salt-broker /target/usr/bin/
17+
mv /usr/bin/uyuni-configure.py /target/usr/bin/
18+
19+
SITE_PACKAGES=usr/lib/$(ls /usr/lib/ | grep python)/site-packages
20+
mkdir -p /target/$SITE_PACKAGES
21+
mv /$SITE_PACKAGES/spacewalk /target/$SITE_PACKAGES
22+
mv /$SITE_PACKAGES/rhn /target/$SITE_PACKAGES
23+
mv /$SITE_PACKAGES/uyuni /target/$SITE_PACKAGES
24+
25+
mkdir -p /target/var/log/salt

0 commit comments

Comments
 (0)