Skip to content

Commit 8e4d4c3

Browse files
bgauduchbgauduch
and
bgauduch
authored
Feat/debian upgrade (#78)
* move to bookworm debian release, upgrade all dockerfile dependencies * updated dependencies update doc, renamed binaries check doc, fmt and update readme * improved local dev script * remove useless python from dockerfile, update container test template tom atch version udpates * update doc to match python removal, add openssh in included tools list * update dockerhub description action to use org dockerhub PAT --------- Co-authored-by: bgauduch <[email protected]>
1 parent db8fbcd commit 8e4d4c3

7 files changed

+58
-42
lines changed

.github/workflows/dockerhub-description-update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ jobs:
1919
uses: peter-evans/dockerhub-description@v3
2020
with:
2121
username: ${{ secrets.DOCKERHUB_USERNAME }}
22-
password: ${{ secrets.DOCKERHUB_PAT_BGA }}
22+
password: ${{ secrets.DOCKERHUB_PAT }}
2323
repository: zenika/terraform-aws-cli

Dockerfile

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Setup build arguments
22
ARG AWS_CLI_VERSION
33
ARG TERRAFORM_VERSION
4-
ARG PYTHON_MAJOR_VERSION=3.9
5-
ARG DEBIAN_VERSION=bullseye-20230109-slim
4+
ARG DEBIAN_VERSION=bookworm-20230612-slim
65
ARG DEBIAN_FRONTEND=noninteractive
76

87
# Download Terraform binary
@@ -11,10 +10,10 @@ ARG TARGETARCH
1110
ARG TERRAFORM_VERSION
1211
RUN apt-get update
1312
# RUN apt-get install --no-install-recommends -y libcurl4=7.74.0-1.3+deb11u7
14-
RUN apt-get install --no-install-recommends -y curl=7.74.0-1.3+deb11u7
15-
RUN apt-get install --no-install-recommends -y ca-certificates=20210119
16-
RUN apt-get install --no-install-recommends -y unzip=6.0-26+deb11u1
17-
RUN apt-get install --no-install-recommends -y gnupg=2.2.27-2+deb11u2
13+
RUN apt-get install --no-install-recommends -y ca-certificates=20230311
14+
RUN apt-get install --no-install-recommends -y curl=7.88.1-10
15+
RUN apt-get install --no-install-recommends -y gnupg=2.2.40-1.1
16+
RUN apt-get install --no-install-recommends -y unzip=6.0-28
1817
WORKDIR /workspace
1918
RUN curl --silent --show-error --fail --remote-name https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${TARGETARCH}.zip
2019
COPY security/hashicorp.asc ./
@@ -28,12 +27,11 @@ RUN unzip -j terraform_${TERRAFORM_VERSION}_linux_${TARGETARCH}.zip
2827
FROM debian:${DEBIAN_VERSION} as aws-cli
2928
ARG AWS_CLI_VERSION
3029
RUN apt-get update
31-
RUN apt-get install -y --no-install-recommends curl=7.74.0-1.3+deb11u7
32-
RUN apt-get install -y --no-install-recommends ca-certificates=20210119
33-
RUN apt-get install -y --no-install-recommends unzip=6.0-26+deb11u1
34-
RUN apt-get install -y --no-install-recommends groff=1.22.4-6
35-
RUN apt-get install -y --no-install-recommends gnupg=2.2.27-2+deb11u2
36-
RUN apt-get install -y --no-install-recommends git=1:2.30.2-1+deb11u2
30+
RUN apt-get install -y --no-install-recommends ca-certificates=20230311
31+
RUN apt-get install -y --no-install-recommends curl=7.88.1-10
32+
RUN apt-get install -y --no-install-recommends gnupg=2.2.40-1.1
33+
RUN apt-get install -y --no-install-recommends unzip=6.0-28
34+
RUN apt-get install -y --no-install-recommends git=1:2.39.2-1.1
3735
RUN apt-get install -y --no-install-recommends jq=1.6-2.1
3836
WORKDIR /workspace
3937
RUN curl --show-error --fail --output "awscliv2.zip" --remote-name "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip"
@@ -47,17 +45,14 @@ RUN ./aws/install --install-dir /usr/local/aws-cli --bin-dir /usr/local/bin
4745
# Build final image
4846
FROM debian:${DEBIAN_VERSION} as build
4947
LABEL maintainer="bgauduch@github"
50-
ARG PYTHON_MAJOR_VERSION
5148
RUN apt-get update \
5249
&& apt-get install -y --no-install-recommends \
53-
ca-certificates=20210119\
54-
git=1:2.30.2-1+deb11u2 \
50+
ca-certificates=20230311\
51+
git=1:2.39.2-1.1 \
5552
jq=1.6-2.1 \
56-
python3=${PYTHON_MAJOR_VERSION}.2-3 \
57-
openssh-client=1:8.4p1-5+deb11u1 \
53+
openssh-client=1:9.2p1-2 \
5854
&& apt-get clean \
59-
&& rm -rf /var/lib/apt/lists/* \
60-
&& update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_MAJOR_VERSION} 1
55+
&& rm -rf /var/lib/apt/lists/*
6156
WORKDIR /workspace
6257
COPY --from=terraform /workspace/terraform /usr/local/bin/terraform
6358
COPY --from=aws-cli /usr/local/bin/ /usr/local/bin/

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
# Terraform and AWS CLI Docker image
1111

1212
## 📦 Supported tags and respective Dockerfile links
13+
1314
Available image tags can be found on the Docker Hub registry: [zenika/terraform-aws-cli](https://hub.docker.com/r/zenika/terraform-aws-cli/tags)
1415

1516
Supported versions are listed in the [`supported_versions.json`](https://github.com/Zenika/terraform-aws-cli/blob/master/supported_versions.json) file.
1617

1718
The following image tag strategy is applied:
19+
1820
* `zenika/terraform-aws-cli:latest` - build from master
19-
* Included CLI versions are the latest in [`supported_versions.json` ](https://github.com/Zenika/terraform-aws-cli/blob/master/supported_versions.json) file.
21+
* Included CLI versions are the latest in [`supported_versions.json`](https://github.com/Zenika/terraform-aws-cli/blob/master/supported_versions.json) file.
2022
* `zenika/terraform-aws-cli:release-S.T_terraform-UU.VV.WW_awscli-XX.YY.ZZ` - build from releases
2123
* `release-S.T` is the release tag
2224
* `terraform-UU.VV.WWW` is the **Terraform** version included in the image
@@ -27,23 +29,26 @@ Please report to the [releases page](https://github.com/Zenika/terraform-aws-cli
2729
> Any other tags are not supported even if available.
2830
2931
## 💡 Motivation
32+
3033
The goal is to create a **minimalist** and **lightweight** image with these tools in order to reduce network and storage impact.
3134

3235
This image gives you the flexibility to be used for development or as a base image as you see fits.
3336

3437
## 🔧 What's inside ?
38+
3539
Tools included:
3640

3741
* [Terraform CLI](https://www.terraform.io/docs/commands/index.html)
3842
* [AWS CLI](https://aws.amazon.com/fr/cli/)
3943
* [Git](https://git-scm.com/) for Terraform remote module usage
40-
* [Python 3](https://www.python.org/)
4144
* [jq](https://stedolan.github.io/jq/) to process JSON returned by AWS
45+
* [OpenSSH Client](https://www.openssh.com/) to handle Terraform module clone over SSH
4246
* This image uses a non-root user with a UID and GID of 1001 to conform with docker security best practices.
4347

4448
## 🚀 Usage
4549

4650
### 🐚 Launch the CLI
51+
4752
Set your AWS credentials (optional) and use the CLI as you would on any other platform, for instance using the latest image:
4853

4954
```bash
@@ -57,9 +62,11 @@ docker container run -it --rm -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AW
5762
> The `--rm` flag will completely destroy the container and its data on exit.
5863
5964
### ⚙️ Build the image
65+
6066
The image can be built locally directly from the Dockerfiles, using the build script.
6167

6268
It will :
69+
6370
* Lint the Dockerfile with [Hadolint](https://github.com/hadolint/hadolint);
6471
* Build and tag the image `zenika/terraform-aws-cli:dev`;
6572
* Execute [container structure tests](https://github.com/GoogleContainerTools/container-structure-test) on the image.
@@ -73,8 +80,8 @@ Optionally, it is possible to choose the tools desired versions :
7380

7481
```bash
7582
# Set tools desired versions
76-
AWS_CLI_VERSION=1.18.189
77-
TERRAFORM_VERSION=0.14.0
83+
AWS_CLI_VERSION=2.12.6
84+
TERRAFORM_VERSION=1.5.2
7885

7986
# launch the build script with parameters
8087
./dev.sh $AWS_CLI_VERSION $TERRAFORM_VERSION
@@ -86,7 +93,7 @@ Do not hesitate to contribute by [filling an issue](https://github.com/Zenika/te
8693
## 📚 Documentations
8794

8895
* [Dependencies upgrades checklist](https://github.com/zenika-open-source/terraform-aws-cli/tree/master/docs/dependencies-upgrades.md)
89-
* [Terraform binaries verifications](https://github.com/zenika-open-source/terraform-aws-cli/tree/master/docs/terraform-binaries-verifications.md)
96+
* [Binaries verifications](https://github.com/zenika-open-source/terraform-aws-cli/tree/master/docs/binaries-verifications.md)
9097

9198
## 🚩 Similar repositories
9299

dev.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,22 @@ PLATEFORM="linux/$(uname -m)"
1818

1919
# Lint Dockerfile
2020
echo "Linting Dockerfile..."
21-
docker container run --rm --interactive --volume "${PWD}":/data --workdir /data --platform "${PLATEFORM}" hadolint/hadolint:2.12.0-alpine /bin/hadolint --config hadolint.yaml Dockerfile
21+
docker container run --rm --interactive \
22+
--volume "${PWD}":/data \
23+
--workdir /data \
24+
--platform "${PLATEFORM}" \
25+
hadolint/hadolint:2.12.0-alpine /bin/hadolint \
26+
--config hadolint.yaml Dockerfile
2227
echo "Lint Successful!"
2328

2429
# Build image
2530
echo "Building images with AWS_CLI_VERSION=${AWS_VERSION} and TERRAFORM_VERSION=${TF_VERSION}..."
26-
docker buildx build --platform "${PLATEFORM}" --build-arg AWS_CLI_VERSION="${AWS_VERSION}" --build-arg TERRAFORM_VERSION="${TF_VERSION}" --tag ${IMAGE_NAME}:${IMAGE_TAG} .
31+
docker buildx build \
32+
--progress plain \
33+
--platform "${PLATEFORM}" \
34+
--build-arg AWS_CLI_VERSION="${AWS_VERSION}" \
35+
--build-arg TERRAFORM_VERSION="${TF_VERSION}" \
36+
--tag ${IMAGE_NAME}:${IMAGE_TAG} .
2737
echo "Image successfully builded!"
2838

2939
# Test image
@@ -32,7 +42,12 @@ export AWS_VERSION=${AWS_VERSION} && export TF_VERSION=${TF_VERSION}
3242
envsubst '${AWS_VERSION},${TF_VERSION}' < tests/container-structure-tests.yml.template > tests/container-structure-tests.yml
3343
echo "Test config successfully generated!"
3444
echo "Executing container structure test..."
35-
docker container run --rm --interactive --volume "${PWD}"/tests/container-structure-tests.yml:/tests.yml:ro --volume /var/run/docker.sock:/var/run/docker.sock:ro gcr.io/gcp-runtimes/container-structure-test:v1.15.0 test --image ${IMAGE_NAME}:${IMAGE_TAG} --config /tests.yml
45+
docker container run --rm --interactive \
46+
--volume "${PWD}"/tests/container-structure-tests.yml:/tests.yml:ro \
47+
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
48+
gcr.io/gcp-runtimes/container-structure-test:v1.15.0 test \
49+
--image ${IMAGE_NAME}:${IMAGE_TAG} \
50+
--config /tests.yml
3651

3752
# cleanup
3853
unset AWS_VERSION

docs/dependencies-upgrades.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
# ⬆️ Dependencies upgrades checklist
22

3-
* Supported versions:
4-
* check available **AWS CLI** version on the [PyPip release page](https://pypi.org/project/awscli/)
5-
* check available **Terraform CLI** version (keep all minor versions from 0.11) available on the [project release page](https://github.com/hashicorp/terraform/releases)
6-
* [Report to the doc](https://github.com/zenika-open-source/terraform-aws-cli/tree/master/docs/terraform-binaries-verifications.md) to add required security files when adding a new supported Terraform version
3+
* Supported tools versions:
4+
* [Report to the doc](https://github.com/zenika-open-source/terraform-aws-cli/tree/master/docs/binaries-verifications.md) to add required security files when adding a new supported versions
5+
* check available **AWS CLI** version on the [project release page](https://github.com/aws/aws-cli/tags)
6+
* check available **Terraform CLI** version (keep all minor versions from 0.11) on the [project release page](https://github.com/hashicorp/terraform/releases)
77
* Dockerfile:
88
* check **base image** version [on DockerHub](https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye)
99
* check OS package versions on Debian package repository
1010
* Available **Git** versions on the [Debian Packages repository](https://packages.debian.org/search?suite=bullseye&arch=any&searchon=names&keywords=git)
11-
* Available **Python** versions on the [Debian packages repository](https://packages.debian.org/search?suite=bullseye&arch=any&searchon=names&keywords=python3)
1211
* Available **JQ** versions on the [Debian Packages repository](https://packages.debian.org/search?suite=bullseye&arch=any&searchon=names&keywords=jq)
1312
* same process for all other packages
14-
* check **Pip** package versions on [pypi](https://pypi.org/)
13+
* Dockerfile tests : update version according to changes in Dockerfile in [tests/container-structure-tests.yml.template](tests/container-structure-tests.yml.template)
1514
* Github actions:
1615
* check [runner version](https://github.com/actions/virtual-environments#available-environments)
1716
* check **each action release** versions

tests/container-structure-tests.yml.template

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ metadataTest:
88
workdir: "/workspace"
99

1010
commandTests:
11-
- name: "Check Python version"
12-
command: "python"
13-
args: ["--version"]
14-
expectedOutput: ["Python 3.9.2"]
15-
1611
- name: "Check Git version"
1712
command: "git"
1813
args: ["--version"]
19-
expectedOutput: ["git version 2.30.2"]
14+
expectedOutput: ["git version 2.39.2"]
2015

2116
- name: "Check JQ version"
2217
command: "jq"
2318
args: ["--version"]
2419
expectedOutput: ["jq-1.6"]
2520

21+
- name: "Check OpenSSH client version"
22+
command: "ssh"
23+
args: ["-V"]
24+
expectedError: ["OpenSSH_9.2p1"]
25+
2626
- name: "Check Terraform CLI version"
2727
command: "terraform"
2828
args: ["version"]
@@ -34,14 +34,14 @@ commandTests:
3434
expectedOutput: ["aws-cli/${AWS_VERSION}"]
3535

3636
fileExistenceTests:
37-
- name: 'Check nonroot user home'
37+
- name: 'Check non-root user home'
3838
path: '/home/nonroot'
3939
shouldExist: true
4040
permissions: 'drwxr-xr-x'
4141
uid: 1001
4242
gid: 1001
4343
isExecutableBy: 'group'
44-
- name: 'Check nonroot user rights on /workspace folder'
44+
- name: 'Check non-root user rights on /workspace folder'
4545
path: '/workspace'
4646
shouldExist: true
4747
permissions: 'drwxr-xr-x'

0 commit comments

Comments
 (0)