Skip to content

Commit 82acf17

Browse files
authored
⬆️ Dev tools update (#77)
* 🐳 remove useless hadolint ignore tag * 🔧 add lint and test in dev-build script, moved to repository root * 📝 add license badge and update dev doc * 🚚 renamed container structure test config * 👷 update container structure test config name in build-test workflow * 🔧 update dev-build script to use container-structure-test image instead of local binary
1 parent 5a482aa commit 82acf17

File tree

7 files changed

+34
-25
lines changed

7 files changed

+34
-25
lines changed

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ jobs:
7575
uses: plexsystems/[email protected]
7676
with:
7777
image: ${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH }}
78-
config: tests/container-structure-test.yml
78+
config: tests/container-structure-tests.yml

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ ARG PYTHON_MAJOR_VERSION=3.7
77
FROM debian:buster-20191118-slim as terraform-cli
88
ARG TERRAFORM_VERSION
99
RUN apt-get update
10-
# hadolint ignore=DL3015
1110
RUN apt-get install -y --no-install-recommends curl=7.64.0-4+deb10u1
1211
RUN apt-get install -y --no-install-recommends ca-certificates=20190110
1312
RUN apt-get install -y --no-install-recommends unzip=6.0-23+deb10u1

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[![build-test](https://github.com/Zenika/terraform-azure-cli/workflows/build-test/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Abuild-test)
22
[![push-latest](https://github.com/Zenika/terraform-azure-cli/workflows/push-latest/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Apush-latest)
33
[![release](https://github.com/Zenika/terraform-azure-cli/workflows/release/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Arelease)
4+
5+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
46
[![Docker Pulls](https://img.shields.io/docker/pulls/zenika/terraform-azure-cli.svg)](https://hub.docker.com/r/zenika/terraform-azure-cli/)
57

68
<p align="center">
@@ -52,11 +54,16 @@ docker container run -it --rm --mount type=bind,source="$(pwd)",target=/workspac
5254
> The `--rm` flag will completely destroy the container and its data on exit.
5355
5456
### Build the image
55-
You can build the image locally directly from the Dockerfiles, using the build script:
57+
You can build the image locally directly from the Dockerfile, using the build script.
58+
59+
It will :
60+
* Lint the Dockerfile with [Hadolint](https://github.com/hadolint/hadolint);
61+
* Build and tag the image `zenika/terraform-azure-cli:dev`;
62+
* Execute [container structure tests](https://github.com/GoogleContainerTools/container-structure-test) on the image.
5663

5764
```bash
5865
# launch build script
59-
./scripts/dev-build.sh
66+
./dev-build.sh
6067
```
6168

6269
Optionally, it is possible to choose the tools desired versions using [Docker builds arguments](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) :
@@ -67,7 +74,7 @@ AZURE_CLI_VERSION=2.5.1
6774
TERRAFORM_VERSION=0.12.24
6875

6976
# launch the build script with parameters
70-
./scripts/dev-build.sh $AZURE_CLI_VERSION $TERRAFORM_VERSION
77+
./dev-build.sh $AZURE_CLI_VERSION $TERRAFORM_VERSION
7178
```
7279

7380
## 🙏 Roadmap & Contributions

dev-build.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
IMAGE_NAME="zenika/terraform-azure-cli:dev"
6+
7+
# Lint Dockerfile
8+
echo "Linting Dockerfile..."
9+
docker run --rm -i hadolint/hadolint:v1.17.6-alpine < Dockerfile
10+
echo "Lint Successful!"
11+
12+
# Build dev image
13+
if [ -n "$1" ] && [ -n "$2" ] ; then
14+
echo "Building images with parameters AZURE_CLI_VERSION=${1} and TERRAFORM_VERSION=${2}..."
15+
docker image build --build-arg AZURE_CLI_VERSION="$1" --build-arg TERRAFORM_VERSION="$2" -t $IMAGE_NAME .
16+
else
17+
echo "Building images with default parameters..."
18+
docker image build -f Dockerfile -t $IMAGE_NAME .
19+
fi
20+
21+
# Test dev image
22+
echo "Executing container structure test..."
23+
docker container run --rm -it -v "${PWD}"/tests/container-structure-tests.yml:/tests.yml:ro -v /var/run/docker.sock:/var/run/docker.sock:ro gcr.io/gcp-runtimes/container-structure-test:v1.8.0 test --image $IMAGE_NAME --config /tests.yml

scripts/dev-build.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

scripts/lint.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)