11# ###############################################################################
22# Base image for all builds
33
4- FROM public.ecr.aws/amazonlinux/amazonlinux:2 AS builder-base
5- RUN yum group install -y "Development Tools"
4+ FROM public.ecr.aws/amazonlinux/amazonlinux:2023 AS builder-base
5+ RUN dnf group install -y "Development Tools"
66RUN useradd builder
77
88
99# ###############################################################################
1010# Statically linked, more recent version of bash
1111
1212FROM builder-base AS builder-static
13- RUN yum install -y glibc-static
13+ RUN dnf install -y glibc-static
1414
1515ARG musl_version=1.2.5
16- ARG bash_version=5.1.16
16+ ARG bash_version=5.2.15
1717
1818WORKDIR /opt/build
1919COPY ./sdk-fetch ./
@@ -47,51 +47,18 @@ RUN CC=""/usr/local/musl/bin/musl-gcc CFLAGS="-Os -DHAVE_DLOPEN=0" \
4747 --enable-static-link \
4848 --without-bash-malloc \
4949 || { cat config.log; exit 1; }
50- RUN make -j`nproc`
50+ RUN make lib/sh/libsh.a && \
51+ cd ./lib/sh && ar d libsh.a strtoimax.o && ranlib libsh.a && \
52+ cd ../.. && make -j`nproc`
5153RUN cp bash /opt/bash
5254RUN mkdir -p /usr/share/licenses/bash && \
5355 cp -p COPYING /usr/share/licenses/bash
5456
5557
56- # ###############################################################################
57- # Rebuild of Amazon Linux 2's systemd v219 with downstream patches
58-
59- FROM builder-base AS builder-systemd
60- RUN yum install -y yum-utils rpm-build
61- RUN yum-builddep -y systemd
62-
63- USER builder
64- WORKDIR /home/builder
65- RUN yumdownloader --source systemd
66- RUN rpm -Uv systemd-219-*.src.rpm
67-
68- WORKDIR /home/builder/rpmbuild/SOURCES
69- COPY systemd-patches/*.patch ./
70-
71- WORKDIR /home/builder/rpmbuild/SPECS
72- # Recreate the spec file from three parts: everything up until the last upstream
73- # patch, downstream patches, everything else.
74- RUN last_patch=$(awk '/^Patch[0-9]+/ { line = NR } END { print line }' systemd.spec); \
75- head -n${last_patch} systemd.spec >systemd.mod.spec; \
76- { \
77- echo ;\
78- echo '# Bottlerocket Patches' ; \
79- echo 'Patch9500: 9500-cgroup-util-extract-cgroup-hierarchy-base-path-into-.patch' ; \
80- echo 'Patch9501: 9501-cgroup-util-accept-cgroup-hierarchy-base-as-option.patch' ; \
81- echo 'Patch9502: 9502-core-move-initialization-of-.slice-and-init.scope-in.patch' ; \
82- echo 'Patch9503: 9503-core-drop-.slice-from-shipped-units.patch' ; \
83- echo 'Patch9504: 9504-core-skip-restart-when-a-JOB_STOP-job-is-pending.patch' ; \
84- echo ; \
85- } >>systemd.mod.spec; \
86- tail -n+$((last_patch + 1)) systemd.spec >>systemd.mod.spec; \
87- mv systemd.mod.spec systemd.spec
88- RUN rpmbuild --bb systemd.spec
89-
90-
9158# ###############################################################################
9259# Actual admin container image
9360
94- FROM public.ecr.aws/amazonlinux/amazonlinux:2
61+ FROM public.ecr.aws/amazonlinux/amazonlinux:2023
9562
9663ARG IMAGE_VERSION
9764# Make the container image version a mandatory build argument
@@ -103,10 +70,8 @@ LABEL "org.opencontainers.image.version"="$IMAGE_VERSION"
10370# dependency is best satisfied by the downstream build. Reinstalling it later
10471# would result in also carrying around the original systemd in the final image
10572# where it would remain forever hidden and unused in a lower layer.
106- RUN --mount=type=bind,from=builder-systemd,source=/home/builder/rpmbuild/RPMS,target=/tmp/systemd-rpms \
107- yum update -y \
108- && yum install -y \
109- /tmp/systemd-rpms/*/systemd-{219,libs}*.rpm \
73+ RUN dnf update -y \
74+ && dnf install -y \
11075 ec2-instance-connect \
11176 jq \
11277 openssh-server \
@@ -115,7 +80,7 @@ RUN --mount=type=bind,from=builder-systemd,source=/home/builder/rpmbuild/RPMS,ta
11580 shadow-utils \
11681 sudo \
11782 util-linux \
118- && yum clean all
83+ && dnf clean all
11984
12085# Delete SELinux config file to prevent relabeling with contexts provided by the container's image
12186RUN rm -rf /etc/selinux/config
@@ -144,4 +109,4 @@ RUN groupadd -g 274 api
144109RUN ln -sf /usr/bin/true /usr/bin/logger
145110
146111CMD ["/usr/sbin/start_admin.sh" ]
147- ENTRYPOINT ["/bin/bash" , "-c" ]
112+ ENTRYPOINT ["/bin/bash" , "-c" ]
0 commit comments