-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically build docker terraform image #10
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe always use the newest version is better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alicloud or random? |
||
|
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why used the azure-cli here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the provide is
azurerm
, it's needed.