Skip to content

Commit 3673d2b

Browse files
authored
Amazonlinux 2023 (#710)
* Switch to Amazon Linux 2023
1 parent 14bc867 commit 3673d2b

File tree

4 files changed

+33
-41
lines changed

4 files changed

+33
-41
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Please check the boxes below to confirm that you have followed the
77
required guidelines for contributions:
88

99
- [ ] If this pull request includes code changes, they were all properly tested. Automated tests were also included where possible.
10-
- [ ] If applicagle, this pull request includes the relevant documentation for this change.
10+
- [ ] If applicable, this pull request includes the relevant documentation for this change.
1111
- [ ] If this pull request is related to an existing issue, you can use the same description below but in any case include a [link](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue) like `Fixes #ISSUE_NUMBER.` or `Closese #ISSUE_NUMBER.`.
1212
- [ ] All the commits in this pull request were squashed into a single commit. That commit is [signed](https://docs.github.com/en/authentication/managing-commit-signature-verification).
1313

.github/workflows/docker-build-push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ jobs:
7676
run: |
7777
# shellcheck disable=SC2086
7878
VERSION="$(\grep ${IMAGE}/Dockerfile -e '^FROM' | \head -n 1 | \sed -e 's/@.*$//; s/^.*://;')"
79-
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then
80-
\echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
79+
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\-minimal$ ]] ; then
80+
\echo "VERSION=${VERSION/[0-9][0-9]*-minimal/}" >> "${GITHUB_ENV}"
8181
fi
8282
- name: Check if release already exists
8383
if: env.VERSION != ''

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ Docker container to run the AWS CLI and related tools (cfn-policy-validator, jq,
1212

1313
## Rational
1414

15-
This image is based on the official
16-
[amazon/aws-cli](https://hub.docker.com/r/amazon/aws-cli) image. The
17-
main difference is that default entrypoint of the official image is
18-
`aws` because it is the only command that this image is meant to run.
19-
On the other hand, this image's default entrypoint is a shell (`bash`)
15+
This image is based on the latest official
16+
[public.ecr.aws/amazonlinux/amazonlinux](https://gallery.ecr.aws/amazonlinux/amazonlinux)
17+
image. This image's default entrypoint is a shell (`bash`)
2018
in which you can run not only `aws` but also other commands typically
2119
useful when building a more advanced CI/CD pipeline. For example this
2220
image includes the `jq` utility often very useful to process the
2321
output of the `aws` command. The tool `cfn-policy-validator` is also
2422
included to run IAM policies from a CloudFormation template through
2523
IAM Access Analyzer checks.
2624

27-
Another significant difference with the official image is that this
25+
Another significant difference with the official AWS images is that this
2826
image is not running using the `root` user. Running as `root` should
2927
not be necessary for CI/CD activities and it is considered a security
3028
risk.

aws-cli/Dockerfile

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM amazon/aws-cli:2.27.36@sha256:0228db71362505ad9e8ad73b5da53a9d287ddc80424f1c92b1b0e5dedb9e4c70
1+
FROM public.ecr.aws/amazonlinux/amazonlinux:2023.7.20250609.0-minimal@sha256:c278930b7f4d5b703962bbcfb7a0ac4c6dc6c318ee02dd8123005d68cd94df17
22

33
HEALTHCHECK NONE
44

@@ -8,42 +8,26 @@ ARG USER_ID=1000
88

99
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
1010

11-
# Upgrade python to 3.8 (best we can do with Amazon Linux 2)
12-
RUN yum remove python3 \
13-
&& amazon-linux-extras install python3.8 \
14-
&& ln -s /usr/bin/python3.8 /usr/bin/python3
15-
16-
RUN yum update -y \
17-
&& yum install -y --setopt=skip_missing_names_on_install=False \
18-
bash-4.2.46-34.amzn2 \
19-
curl-8.3.0-1.amzn2.0.8 \
20-
git-2.47.1-1.amzn2.0.2 \
21-
libxml2-2.9.1-6.amzn2.5.16 \
22-
jq-1.5-1.amzn2.0.2 \
23-
make-3.82-24.amzn2 \
24-
python3-pip-20.2.2-1.amzn2.0.10 \
25-
tar-1.26-35.amzn2.0.4 \
26-
unzip-6.0-57.amzn2.0.1 \
27-
zip-3.0-11.amzn2.0.2 \
11+
RUN dnf upgrade -y \
12+
&& dnf install -y \
13+
awscli-2-2.23.11-1.amzn2023.0.1 \
14+
curl-minimal \
15+
git-2.47.1-1.amzn2023.0.3 \
16+
gzip-1.12-1.amzn2023.0.1 \
17+
libxml2-2.10.4-1.amzn2023.0.10 \
18+
jq-1.7.1-49.amzn2023.0.2 \
19+
make-1:4.3-5.amzn2023.0.2 \
20+
python3-3.9.22-1.amzn2023.0.1 \
21+
tar-2:1.34-1.amzn2023.0.4 \
22+
unzip-6.0-57.amzn2023.0.2 \
23+
zip-3.0-28.amzn2023.0.2 \
2824
&& IFS=$'\n\t' \
29-
&& if yum list updates | grep -q -e '^Updated Packages' ; then \
30-
yum list updates ; \
25+
&& if dnf upgrade -y | grep -v -e '^Nothing to do.' ; then \
3126
exit 1 ; \
3227
fi \
33-
&& yum clean all \
28+
&& dnf clean all \
3429
&& rm -rf /var/cache/yum
3530

36-
# @TL FIXME: cfn-policy-validator version is held back by Python 3.8.
37-
# @TL FIXME: --break-system-packages not supported until Python 3.11.
38-
RUN pip3 install --no-cache-dir --upgrade \
39-
cfn-policy-validator==0.0.29 \
40-
&& IFS=$'\n\t' \
41-
&& msg="$(pip3 list --outdated | grep -i -e '^cfn-policy-validator ' || true)" \
42-
&& if [ -n "${msg}" ]; then \
43-
>&2 echo "ERROR: outdated: ${msg}" ; \
44-
exit 1 ; \
45-
fi
46-
4731
RUN chmod 777 /opt \
4832
&& adduser --home-dir "${USER_HOME}" --uid "${USER_ID}" "${USER_NAME}"
4933

@@ -53,6 +37,16 @@ ENV HOME="${USER_HOME}"
5337

5438
WORKDIR /opt
5539

40+
# @TL FIXME: --break-system-packages not supported until Python 3.11.
41+
RUN pip3 install --no-cache-dir --upgrade \
42+
cfn-policy-validator==0.0.36 \
43+
&& IFS=$'\n\t' \
44+
&& msg="$(pip3 list --outdated | grep -i -e '^cfn-policy-validator ' || true)" \
45+
&& if [ -n "${msg}" ]; then \
46+
>&2 echo "ERROR: outdated: ${msg}" ; \
47+
exit 1 ; \
48+
fi
49+
5650
CMD ["/bin/bash"]
5751

5852
ENTRYPOINT []

0 commit comments

Comments
 (0)