Skip to content

Commit fa0809e

Browse files
authored
✨ added alpine based image (#17)
* ✨ added alpine based image * 🚚 renamed debian based image Dockerfile * 📝 updated readme to match alpine based dockerfile addition * 👌 review by @pyaillet
1 parent a9029b6 commit fa0809e

File tree

5 files changed

+61
-17
lines changed

5 files changed

+61
-17
lines changed

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,31 @@
33
[![Docker Pulls](https://img.shields.io/docker/pulls/zenika/terraform-azure-cli.svg)](https://hub.docker.com/r/zenika/terraform-azure-cli/)
44

55
# Terraform and Azure CLI Docker image
6-
Docker Image including Azure and Terraform CLI tools.
76

87
## Availables Docker image tags
9-
Repository available on the Docker Hub: [zenika/terraform-azure-cli](https://hub.docker.com/r/zenika/terraform-azure-cli)
10-
* zenika/terraform-azure-cli:latest - latest image build on master branch
11-
* zenika/terraform-azure-cli:vX.Y - versionned image build on specific repository tag
8+
Repository available on Docker Hub: [zenika/terraform-azure-cli](https://hub.docker.com/r/zenika/terraform-azure-cli)
9+
10+
One images uses [Debian](https://hub.docker.com/_/debian) and the other one uses [Alpine](https://hub.docker.com/_/alpine) as a base.
11+
12+
Debian-based images ([debian.Dockerfile](https://github.com/Zenika/terraform-azure-cli/blob/master/debian.Dockerfile)):
13+
14+
* zenika/terraform-azure-cli:latest-latest - latest image build on master branch
15+
* zenika/terraform-azure-cli:X.Y-debian - versionned image build on repository tags
16+
17+
Alpine-based images ([alpine.Dockerfile](https://github.com/Zenika/terraform-azure-cli/blob/master/alpine.Dockerfile)):
18+
19+
* zenika/terraform-azure-cli:alpine-latest - latest image build on master branch
20+
* zenika/terraform-azure-cli:X.Y-alpine - versionned image build on repository tags
21+
22+
> Git repository tag naming convention: `/^([0-9.]+)$/`
1223
1324
## Motivation
1425
Many Docker images including the Terraform and Azure CLI already exist out there, both on the Docker Hub and Github.
1526
But they all are quite oversized.
1627

17-
The goal is to create a functional, minimalist and lightweight image with these tools in order to reduce network and storage impact.
28+
The goal is to create a **functional**, **minimalist** and **lightweight** image with these tools in order to reduce network and storage impact.
1829

1930
## What's inside ?
20-
This image uses [Debian Stretch](https://hub.docker.com/_/debian) as a base.
21-
2231
Tools included:
2332

2433
* Azure CLI **v2.0.64**
@@ -32,19 +41,25 @@ Tools included:
3241
## Usage
3342

3443
### Launch the CLI
35-
Simply launch the container and use the CLI as you would on any other platform:
44+
Simply launch the container and use the CLI as you would on any other platform, for instance using the *alpine* based image:
3645
```bash
37-
docker container run -it --rm zenika/terraform-azure-cli
46+
docker container run -it --rm zenika/terraform-azure-cli:alpine-latest
3847
```
3948

4049
> The `--rm` flag will completely destroy the container and its data on exit.
4150
4251
### Build the image
43-
Build the image locally directly from the Dockerfile:
52+
You can build the image locally directly from the Dockerfiles:
4453
```bash
45-
docker image build -t zenika/terraform-azure-cli .
54+
# build the Debian based image:
55+
docker image build -f debian.Dockerfile -t zenika/terraform-azure-cli:debian .
56+
57+
# build the Alpine based image:
58+
docker image build -f alpine.Dockerfile -t zenika/terraform-azure-cli:alpine .
4659
```
4760

61+
> You can use [Docker build arguments](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) to set custom Terraform & Azure CLI version.
62+
4863
## Roadmap & Contributions
4964
Please refer to the [github project](https://github.com/Zenika/terraform-azure-cli/projects/1) to track new features.
5065

alpine.Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG TERRAFORM_VERSION=0.11.13
2+
ARG AZ_CLI_VERSION=2.0.64
3+
4+
# Download Terraform binary
5+
FROM alpine:3.9.4 as terraform
6+
ARG TERRAFORM_VERSION
7+
RUN apk update
8+
RUN apk add curl=7.64.0-r1
9+
RUN apk add unzip=6.0-r4
10+
RUN curl -sSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform-${TERRAFORM_VERSION}.zip
11+
# FIXME: validate terraform signature & checksum
12+
RUN unzip -j terraform-${TERRAFORM_VERSION}.zip
13+
14+
# Install az CLI using PIP
15+
FROM alpine:3.9.4 as azure-cli
16+
ARG AZ_CLI_VERSION
17+
RUN apk update
18+
RUN apk add python3=3.6.8-r2
19+
RUN apk add python3-dev=3.6.8-r2
20+
RUN apk add py3-setuptools=40.6.3-r0
21+
RUN apk add gcc=8.3.0-r0
22+
RUN apk add musl-dev=1.1.20-r4
23+
RUN apk add libffi-dev=3.2.1-r6
24+
RUN apk add openssl-dev=1.1.1b-r1
25+
RUN apk add make=4.2.1-r2
26+
RUN pip3 install azure-cli==${AZ_CLI_VERSION}
27+
28+
# Build final image
29+
FROM alpine:3.9.4
30+
RUN apk --no-cache add python3=3.6.8-r2 bash=4.4.19-r1 \
31+
&& ln -s /usr/bin/python3 /usr/bin/python
32+
COPY --from=terraform /terraform /usr/bin/terraform
33+
COPY --from=azure-cli /usr/bin/az* /usr/bin/
34+
COPY --from=azure-cli /usr/lib/python3.6/site-packages /usr/lib/python3.6/site-packages
35+
CMD ["bash"]
File renamed without changes.

scripts/build.sh

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

scripts/run.sh

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

0 commit comments

Comments
 (0)