Skip to content

Commit

Permalink
Base image, dependencies and terraform upgrade (#114)
Browse files Browse the repository at this point in the history
* renamed dev script

* update base image, dependencies and terravorm v1 versions

* small updated in actions

* update readme

* remove useless dependecies from dockerfile

Co-authored-by: bgauduch <[email protected]>
  • Loading branch information
bgauduch and bgauduch authored Sep 14, 2021
1 parent 86a905b commit b86bcba
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build-test

# trigger on any push
# but not on master or tags
# and only for dockerfile-related modifications
# and only for Dockerfile related modifications
on:
push:
tags-ignore:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dockerhub-description.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Update Docker Hub Description

# trigger on master
# and only for readme related modifications
on:
push:
branches:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint-dockerfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: lint-dockerfile

# trigger on any push
# but not on master or tags
# and only for dockerfile modifications
# and only for Dockerfile related modifications
on:
push:
tags-ignore:
Expand All @@ -12,6 +12,7 @@ on:
- "!master"
paths:
- "Dockerfile"
- "hadolint.yaml"
- ".github/workflows/lint-dockerfile.yml"

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-latest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: push-latest

# trigger on push to master
# only on image-related modifications
# only on Dockerfile related modifications
on:
push:
branches:
Expand Down
32 changes: 13 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Build arguments
ARG AZURE_CLI_VERSION
ARG TERRAFORM_VERSION
ARG PYTHON_MAJOR_VERSION=3.7
ARG DEBIAN_VERSION=buster-20210511-slim
ARG PYTHON_MAJOR_VERSION=3.9
ARG DEBIAN_VERSION=bullseye-20210902-slim

# Download Terraform binary
FROM debian:${DEBIAN_VERSION} as terraform-cli
ARG TERRAFORM_VERSION
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt=1.8.2.3
RUN apt-get install -y --no-install-recommends curl=7.64.0-4+deb10u2
RUN apt-get install -y --no-install-recommends ca-certificates=20200601~deb10u2
RUN apt-get install -y --no-install-recommends unzip=6.0-23+deb10u2
RUN apt-get install -y --no-install-recommends gnupg=2.2.12-1+deb10u1
RUN apt-get install --no-install-recommends -y curl=7.74.0-1.3+b1
RUN apt-get install --no-install-recommends -y ca-certificates=20210119
RUN apt-get install --no-install-recommends -y unzip=6.0-26
RUN apt-get install --no-install-recommends -y gnupg=2.2.27-2
WORKDIR /workspace
RUN curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS
RUN curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
Expand All @@ -29,14 +28,9 @@ FROM debian:${DEBIAN_VERSION} as azure-cli
ARG AZURE_CLI_VERSION
ARG PYTHON_MAJOR_VERSION
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt=1.8.2.3
RUN apt-get install -y --no-install-recommends python3=${PYTHON_MAJOR_VERSION}.3-1
RUN apt-get install -y --no-install-recommends python3-pip=18.1-5
RUN apt-get install -y --no-install-recommends gcc=4:8.3.0-1
RUN apt-get install -y --no-install-recommends python3-dev=${PYTHON_MAJOR_VERSION}.3-1
RUN pip3 install --upgrade --no-cache-dir pip==21.0.1
RUN pip3 install --no-cache-dir setuptools==54.1.1
RUN pip3 install --no-cache-dir wheel==0.36.2
RUN apt-get install -y --no-install-recommends python3=${PYTHON_MAJOR_VERSION}.2-3
RUN apt-get install -y --no-install-recommends python3-pip=20.3.4-4
RUN pip3 install --no-cache-dir setuptools==58.0.4
RUN pip3 install --no-cache-dir azure-cli==${AZURE_CLI_VERSION}

# Build final image
Expand All @@ -45,10 +39,10 @@ LABEL maintainer="bgauduch@github"
ARG PYTHON_MAJOR_VERSION
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates=20200601~deb10u2 \
git=1:2.20.1-2+deb10u3 \
python3=${PYTHON_MAJOR_VERSION}.3-1 \
python3-distutils=${PYTHON_MAJOR_VERSION}.3-1 \
ca-certificates=20210119 \
git=1:2.30.2-1 \
python3=${PYTHON_MAJOR_VERSION}.2-3 \
python3-distutils=${PYTHON_MAJOR_VERSION}.2-1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_MAJOR_VERSION} 1
Expand Down
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[![lint-dockerfile](https://github.com/Zenika/terraform-azure-cli/workflows/lint-dockerfile/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Alint-dockerfile)
[![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)
[![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)
[![release](https://github.com/Zenika/terraform-azure-cli/workflows/release/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Arelease)
[![lint-dockerfile](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/lint-dockerfile.yml/badge.svg)](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/lint-dockerfile.yml)
[![build-test](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/build-test.yml/badge.svg)](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/build-test.yml)
[![push-latest](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/push-latest.yml/badge.svg)](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/push-latest.yml)
[![release](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/release.yml/badge.svg)](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/release.yml)

[![Update Docker Hub Description](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/dockerhub-description.yml/badge.svg)](https://github.com/zenika-open-source/terraform-azure-cli/actions/workflows/dockerhub-description.yml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Docker Pulls](https://img.shields.io/docker/pulls/zenika/terraform-azure-cli.svg)](https://hub.docker.com/r/zenika/terraform-azure-cli/)

Expand All @@ -16,17 +17,17 @@
## 📦 Supported tags and respective Dockerfile links
Available image tags can be found on the Docker Hub registry: [zenika/terraform-azure-cli](https://hub.docker.com/r/zenika/terraform-azure-cli/tags)

Supported versions are listed in the [`supported_versions.json` ](https://github.com/Zenika/terraform-azure-cli/blob/master/supported_versions.json) file in project root folder.
Supported versions are listed in the [`supported_versions.json` ](https://github.com/zenika-open-source/terraform-azure-cli/blob/master/supported_versions.json) file in project root folder.

The following image tag strategy is applied:
* `zenika/terraform-azure-cli:latest` - build from master
* Included CLI versions can be found in the [Dockerfile](https://github.com/Zenika/terraform-azure-cli/blob/master/Dockerfile)
* Included CLI versions are the newest in the [`supported_versions.json` ](https://github.com/zenika-open-source/terraform-azure-cli/blob/master/supported_versions.json) file.
* `zenika/terraform-azure-cli:release-S.T_terraform-UU.VV.WW_azcli-XX.YY.ZZ` - build from releases
* `release-S.T` is the release tag
* `terraform-UU.VV.WWW` is the included Terraform CLI version
* `azcli-XX.YY.ZZ` is the included Azure CLI version
* `terraform-UU.VV.WWW` is the included **Terraform CLI** version
* `azcli-XX.YY.ZZ` is the included **Azure CLI** version

Please report to the [releases page](https://github.com/Zenika/terraform-azure-cli/releases) for the changelogs.
Please report to the [releases page](https://github.com/zenika-open-source/terraform-azure-cli/releases) for the changelogs.

> Any other tags are not supported even if available.
Expand All @@ -36,17 +37,16 @@ The goal is to create a **minimalist** and **lightweight** image with these tool
This image gives you the flexibility to be used either for development or as a base image as you see fits.

## 🔧 What's inside ?

* [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest):
* Included version indicated in the image tag: `azcli-XX.YY.ZZ`
* [Terraform CLI](https://www.terraform.io/docs/commands/index.html):
* Included version indicated in the image tag: `terraform-XX.YY.ZZ`
* [Git](https://git-scm.com/)
* [Python 3](https://www.python.org/)
* This image use a non root user with a GID and UID of 1001 to conform with docker security best practices.

## 🚀 Usage

### Launch the CLI
### 🐚 Launch the CLI
Simply launch the container and use the CLI as you would on any other platform, for instance using the latest image:

```bash
Expand All @@ -55,7 +55,7 @@ docker container run -it --rm --mount type=bind,source="$(pwd)",target=/workspac

> The `--rm` flag will completely destroy the container and its data on exit.
### Build the image
### ⚙️ Build the image
You can build the image locally directly from the Dockerfile, using the build script.

It will :
Expand All @@ -64,8 +64,8 @@ It will :
* Execute [container structure tests](https://github.com/GoogleContainerTools/container-structure-test) on the image.

```bash
# launch build script using latest supported versions for both Azure and Terraform CLI
./build.sh
# launch dev script using latest supported versions for both Azure and Terraform CLI
./dev.sh
```

Optionally, it is possible to choose the tools desired versions:
Expand All @@ -75,42 +75,42 @@ Optionally, it is possible to choose the tools desired versions:
AZURE_CLI_VERSION=2.24.2
TERRAFORM_VERSION=0.15.5

# launch build script with parameters
./build.sh $AZURE_CLI_VERSION $TERRAFORM_VERSION
# launch dev script with parameters
./dev.sh $AZURE_CLI_VERSION $TERRAFORM_VERSION
```

## 🙏 Roadmap & Contributions
Please refer to the [github project](https://github.com/Zenika/terraform-azure-cli/projects/1) to track new features.
Please refer to the [github project](https://github.com/zenika-open-source/terraform-azure-cli/projects/1) to track new features.

Do not hesitate to contribute by [filling an issue](https://github.com/Zenika/terraform-azure-cli/issues) or [opening a PR](https://github.com/Zenika/terraform-azure-cli/pulls) !
Do not hesitate to contribute by [filling an issue](https://github.com/zenika-open-source/terraform-azure-cli/issues/new) or [opening a PR](https://github.com/zenika-open-source/terraform-azure-cli/pulls) !

## ⬆️ Dependencies upgrades checklist

* Supported versions:
* check Azure CLI version (only keep 2 latest releases), available on the [project release page](https://github.com/Azure/azure-cli/releases)
* check Terraform CLI version (keep all minor versions from 0.11), available on the [project release page](https://github.com/hashicorp/terraform/releases)
* check **Azure CLI** version on the [project release page](https://github.com/Azure/azure-cli/releases)
* check **Terraform CLI** version (keep all minor versions from 0.11) available on the [project release page](https://github.com/hashicorp/terraform/releases)
* Dockerfile:
* check base image version on DockerHub
* check OS package versions on Debian package repository
* Available Git versions on the [Debian Packages repository](https://packages.debian.org/search?suite=buster&arch=any&searchon=names&keywords=git)
* Available Python versions on the [Debian packages repository](https://packages.debian.org/search?suite=buster&arch=any&searchon=names&keywords=python3)
* same process for all other packages
* check Pip package versions on [pypi](https://pypi.org/)
* check **base image** version on DockerHub
* check **OS package** versions on Debian package repository
* Available **Git** versions on the [Debian Packages repository](https://packages.debian.org/search?arch=any&searchon=names&keywords=git)
* Available **Python** versions on the [Debian packages repository](https://packages.debian.org/search?arch=any&searchon=names&keywords=python3)
* same process for **all other packages**
* check **Pip package** versions on [pypi](https://pypi.org/)
* Github actions:
* check [runner version](https://github.com/actions/virtual-environments#available-environments)
* check each action release versions
* check **each action release** versions
* Build scripts:
* check container tags:
* check **container tags**:
* [Hadolint releases](https://github.com/hadolint/hadolint/releases)
* [Container-structure-test](https://github.com/GoogleContainerTools/container-structure-test/releases)
* Readme:
* update version in code exemples

## Similar repositories
## 🚩 Similar repositories

* For AWS: [zenika-open-source/terraform-aws-cli](https://github.com/zenika-open-source/terraform-aws-cli)

## 📖 License
This project is under the [Apache License 2.0](https://raw.githubusercontent.com/Zenika/terraform-azure-cli/master/LICENSE)
This project is under the [Apache License 2.0](https://github.com/zenika-open-source/terraform-azure-cli/blob/master/LICENSE)

[![with love by zenika](https://img.shields.io/badge/With%20%E2%9D%A4%EF%B8%8F%20by-Zenika-b51432.svg)](https://oss.zenika.com)
File renamed without changes.
5 changes: 2 additions & 3 deletions supported_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"0.13.7",
"0.14.11",
"0.15.5",
"1.0.0"
"1.0.6"
],
"azcli_version": [
"2.24.2",
"2.25.0"
"2.28.1"
]
}
4 changes: 2 additions & 2 deletions tests/container-structure-tests.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ commandTests:
- name: "Check Python version"
command: "python"
args: ["--version"]
expectedOutput: ["Python 3.7.3"]
expectedOutput: ["Python 3.9.2"]

- name: "Check Git version"
command: "git"
args: ["--version"]
expectedOutput: ["git version 2.20.1"]
expectedOutput: ["git version 2.30.2"]

- name: "Check Terraform CLI version"
command: "terraform"
Expand Down

0 comments on commit b86bcba

Please sign in to comment.