File tree Expand file tree Collapse file tree 3 files changed +101
-3
lines changed
Expand file tree Collapse file tree 3 files changed +101
-3
lines changed Original file line number Diff line number Diff line change 1+ name : Docker Image CI
2+
3+ on :
4+ push :
5+ branches :
6+ - " !main"
7+ pull_request :
8+ branches : [main]
9+
10+ env :
11+ ORGANIZATION : " smerrell"
12+ IMAGE_NAME : " terraform-python-build"
13+
14+ jobs :
15+ lint :
16+ runs-on : ubuntu-latest
17+
18+ steps :
19+ - uses : actions/checkout@v2
20+ - name : Lint Dockerfile
21+ uses : brpaz/hadolint-action@master
22+ with :
23+ dockerfile : " Dockerfile"
24+
25+ build :
26+ runs-on : ubuntu-latest
27+ needs : lint
28+
29+ steps :
30+ - uses : actions/checkout@v2
31+ - name : Build the Docker image
32+ run : docker build . --file Dockerfile --tag $ORGANIZATION/$IMAGE_NAME:$(date +%s)
Original file line number Diff line number Diff line change 1+ name : release
2+
3+ # trigger on published release
4+ on :
5+ release :
6+ types : [published]
7+
8+ jobs :
9+ lint :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Check out the repo
14+ uses : actions/checkout@v2
15+
16+ - name : Lint Dockerfile
17+ uses : brpaz/hadolint-action@master
18+ with :
19+ dockerfile : " Dockerfile"
20+
21+ build_push_release :
22+ runs-on : ubuntu-latest
23+ needs : lint
24+
25+ strategy :
26+ matrix :
27+ tf_version :
28+ - " 0.12.29"
29+ - " 0.13.5"
30+
31+ azcli_version :
32+ - " 2.15.1"
33+
34+ env :
35+ ORGANIZATION : " smerrell"
36+ IMAGE_NAME : " terraform-python-build"
37+
38+ steps :
39+ - name : Check out the repo
40+ uses : actions/checkout@v2
41+
42+ - name : Login to Docker Hub
43+ uses : docker/login-action@v1
44+ with :
45+ username : ${{ secrets.DOCKER_HUB_USERNAME }}
46+ password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
47+
48+ - name : Get and save release tag
49+ run : echo "RELEASE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
50+
51+ - name : Build and save image release tag
52+ run : echo "IMAGE_RELEASE_TAG=release-${RELEASE_TAG}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV
53+
54+ - name : Build image
55+ run : docker image build . --file Dockerfile --build-arg TF_AZ_CLI_VERSION=release-5.1_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }} --tag ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}
56+
57+ - name : Push image to registry
58+ run : docker push ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}
Original file line number Diff line number Diff line change 1- FROM zenika/terraform-azure-cli:latest AS build
1+ ARG TF_AZ_CLI_VERSION=release-5.1_terraform-0.12.29_azcli-2.15.1
2+ FROM zenika/terraform-azure-cli:${TF_AZ_CLI_VERSION} AS build
23
3- RUN apt-get update && apt-get install make git python3-pip -y
4- RUN pip3 install gitpython python-terraform pyhcl
4+ RUN apt-get update && \
5+ apt-get install --no-install-recommends git=1:2.20.1-2+deb10u3 python3-pip=18.1-5 -y && \
6+ apt-get clean && rm -rf /var/lib/apt/lists/*
7+ RUN pip3 install gitpython==3.1.12 python-terraform==0.10.1 pyhcl==0.4.4
58
69FROM build as final
710WORKDIR /workspace
11+ RUN groupadd --gid 1001 nonroot \
12+ # user needs a home folder to store azure credentials
13+ && useradd --gid nonroot --create-home --uid 1001 nonroot \
14+ && chown nonroot:nonroot /workspace
15+ USER nonroot
816CMD [ "bash" ]
You can’t perform that action at this time.
0 commit comments