Skip to content

Commit f435fa3

Browse files
committed
base: update to Amazon Linux 2023 and bash 5.2.15
Upgrade the base image from Amazon Linux 2 to Amazon Linux 2023 for improved security, performance, and long-term support. This change also updates bash from 5.1.16 to 5.2.15. Signed-off-by: Maher Homsi <[email protected]>
1 parent 0b37ebd commit f435fa3

File tree

2 files changed

+14
-49
lines changed

2 files changed

+14
-49
lines changed

Dockerfile

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
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"
66
RUN useradd builder
77

88

99
################################################################################
1010
# Statically linked, more recent version of bash
1111

1212
FROM builder-base AS builder-static
13-
RUN yum install -y glibc-static
13+
RUN dnf install -y glibc-static
1414

1515
ARG musl_version=1.2.5
16-
ARG bash_version=5.1.16
16+
ARG bash_version=5.2.15
1717

1818
WORKDIR /opt/build
1919
COPY ./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`
5153
RUN cp bash /opt/bash
5254
RUN 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

9663
ARG 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
12186
RUN rm -rf /etc/selinux/config
@@ -144,4 +109,4 @@ RUN groupadd -g 274 api
144109
RUN ln -sf /usr/bin/true /usr/bin/logger
145110

146111
CMD ["/usr/sbin/start_admin.sh"]
147-
ENTRYPOINT ["/bin/bash", "-c"]
112+
ENTRYPOINT ["/bin/bash", "-c"]

hashes/bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# https://ftp.gnu.org/gnu/bash/bash-5.1.16.tar.gz
2-
SHA512 (bash-5.1.16.tar.gz) = a32a343b6dde9a18eb6217602655f72c4098b0d90f04cf4e686fb21b81fc4ef26ade30f7226929fbb7c207cde34617dbad2c44f6103161d1141122bb31dc6c80
1+
# https://ftp.gnu.org/gnu/bash/bash-5.2.15.tar.gz
2+
SHA512 (bash-5.2.15.tar.gz) = 08a67f6da4af7a75ff2b2d5a9eb8fc46d8c6e9ae80ccaf73b51736d6609916861b1f3fced938ce3ea16d014edb324e1a3d8e03f4917f68dc56ffb665316f26c7

0 commit comments

Comments
 (0)