-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from zzxwill/build
Automatically build docker terraform image
- Loading branch information
Showing
3 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Docker | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "v*" | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Get the version | ||
id: get_version | ||
run: | | ||
tag=${GITHUB_REF#refs/tags/} | ||
VERSION=${tag#"v"} | ||
if [[ ${GITHUB_REF} == "refs/heads/master" ]]; then | ||
VERSION=latest | ||
fi | ||
echo ::set-output name=VERSION::${VERSION} | ||
- name: Get git revision | ||
id: vars | ||
shell: bash | ||
run: | | ||
echo "::set-output name=git_revision::$(git rev-parse --short HEAD)" | ||
- name: Login docker.io | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- uses: docker/setup-qemu-action@v1 | ||
- uses: docker/setup-buildx-action@v1 | ||
with: | ||
driver-opts: image=moby/buildkit:master | ||
|
||
- uses: docker/build-push-action@v2 | ||
name: Build & Pushing terraform controller for Dockerhub | ||
with: | ||
context: . | ||
file: Dockerfile | ||
labels: |- | ||
org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
platforms: linux/amd64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
build-args: | | ||
GITVERSION=git-${{ steps.vars.outputs.git_revision }} | ||
VERSION=${{ steps.get_version.outputs.VERSION }} | ||
GOPROXY=https://proxy.golang.org | ||
tags: |- | ||
docker.io/oamdev/docker-terraform:${{ steps.get_version.outputs.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
FROM oamdev/docker-terraform-base:1.0.9 | ||
FROM alpine:3.13 | ||
|
||
RUN \ | ||
apk update && \ | ||
apk add bash py-pip && \ | ||
apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python3-dev make && \ | ||
apk add curl jq python3 ca-certificates git openssl unzip wget && \ | ||
pip --no-cache-dir install -U pip && \ | ||
pip install azure-cli && \ | ||
apk del --purge build | ||
|
||
VOLUME ["/data"] | ||
|
||
WORKDIR /data | ||
|
||
ENTRYPOINT ["tail", "-f", "/dev/null"] | ||
|
||
ENV TERRAFORM_VERSION=1.0.2 | ||
COPY terraform_${TERRAFORM_VERSION}_linux_amd64.zip /tmp | ||
RUN cd /tmp && \ | ||
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/bin | ||
COPY retrieve_tf_provider.sh /tmp | ||
|
||
ARG VCS_REF | ||
ENV RETRIEVE_TF_PROVIDER=/tmp/retrieve_tf_provider.sh | ||
|
||
LABEL org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vcs-url="https://github.com/broadinstitute/docker-terraform" | ||
RUN $RETRIEVE_TF_PROVIDER random 3.1.0 | ||
RUN $RETRIEVE_TF_PROVIDER alicloud 1.140.0 | ||
|
||
RUN cp -r .terraform.d /root/.terraform.d | ||
|
||
ENTRYPOINT ["tail", "-f", "/dev/null"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
set -x | ||
# accept two arguments from command line | ||
# 1. the name of the Terraform provider | ||
# 2. the version of the Terraform provider | ||
|
||
PROVIDER_NAME=$1 | ||
PROVIDER_VERSION=$2 | ||
|
||
echo "Downloading: $PROVIDER_NAME, $PROVIDER_VERSION" | ||
|
||
TERRAFORM_DIR=.terraform.d/plugins/registry.terraform.io/hashicorp | ||
HASHICORP_RELEASE_DOMAIN=https://releases.hashicorp.com | ||
|
||
PROVIDER_RUL=$HASHICORP_RELEASE_DOMAIN/terraform-provider-"$PROVIDER_NAME"/"$PROVIDER_VERSION"/terraform-provider-"$PROVIDER_NAME"_"$PROVIDER_VERSION"_linux_amd64.zip | ||
wget "$PROVIDER_RUL" -O provider.zip && | ||
unzip provider.zip && | ||
chmod +x terraform-provider-"$PROVIDER_NAME"_* && | ||
mkdir -p $TERRAFORM_DIR/"$PROVIDER_NAME"/"$PROVIDER_VERSION"/linux_amd64 && | ||
mv terraform-provider-"$PROVIDER_NAME"_* $TERRAFORM_DIR/"$PROVIDER_NAME"/"$PROVIDER_VERSION"/linux_amd64 && | ||
rm -f provider.zip |