Skip to content

Commit

Permalink
Merge pull request tfutils#346 from OJFord/impl-241
Browse files Browse the repository at this point in the history
Add a dockerfile, end-to-end sanity test
  • Loading branch information
Zordrak authored Oct 1, 2022
2 parents 9151b3e + 5e1a3f5 commit 1ccfddb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ jobs:
run: './test/run.sh'
shell: 'bash'

- uses: 'docker/setup-buildx-action@v2'
if: contains(matrix.os, 'ubuntu')
with:
install: true
- uses: 'docker/build-push-action@v3'
if: contains(matrix.os, 'ubuntu')
with:
context: .
load: true
tags: "tfenv-terraform:${{ github.head_ref }}"
- name: 'Check Dockerfile'
if: contains(matrix.os, 'ubuntu')
run: |
expect=1.2.3;
got="$(docker run -e "TFENV_TERRAFORM_VERSION=${expect}" "tfenv-terraform:${{ github.head_ref }}" version)";
echo "${got}" | tee /dev/stderr | grep -e 'Terraform v1.2.3'
# When we push to master, test everything in order to guarantee releases
test-master-pushes:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand All @@ -51,3 +68,20 @@ jobs:
- name: 'Run all tests'
run: './test/run.sh'
shell: 'bash'

- uses: 'docker/setup-buildx-action@v2'
if: contains(matrix.os, 'ubuntu')
with:
install: true
- uses: 'docker/build-push-action@v3'
if: contains(matrix.os, 'ubuntu')
with:
context: .
load: true
tags: 'tfenv-terraform:latest'
- name: 'Check Dockerfile'
if: contains(matrix.os, 'ubuntu')
run: |
expect=1.2.3;
got="$(docker run -e "TFENV_TERRAFORM_VERSION=${expect}" tfenv-terraform:latest version)";
echo "${got}" | tee /dev/stderr | grep -e 'Terraform v1.2.3'
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ARG BASH_VERSION=5
FROM "docker.io/bash:${BASH_VERSION}"

# Runtime dependencies
RUN apk add --no-cache --purge \
curl \
;

ARG TFENV_VERSION=3.0.0
RUN wget -O /tmp/tfenv.tar.gz "https://github.com/tfutils/tfenv/archive/refs/tags/v${TFENV_VERSION}.tar.gz" \
&& tar -C /tmp -xf /tmp/tfenv.tar.gz \
&& mv "/tmp/tfenv-${TFENV_VERSION}/bin"/* /usr/local/bin/ \
&& mkdir -p /usr/local/lib/tfenv \
&& mv "/tmp/tfenv-${TFENV_VERSION}/lib" /usr/local/lib/tfenv/ \
&& mv "/tmp/tfenv-${TFENV_VERSION}/libexec" /usr/local/lib/tfenv/ \
&& mkdir -p /usr/local/share/licenses \
&& mv "/tmp/tfenv-${TFENV_VERSION}/LICENSE" /usr/local/share/licenses/tfenv \
&& rm -rf /tmp/tfenv* \
;
ENV TFENV_ROOT /usr/local/lib/tfenv

ENV TFENV_CONFIG_DIR /var/tfenv
VOLUME /var/tfenv

# Default to latest; user-specifiable
ENV TFENV_TERRAFORM_VERSION latest
ENTRYPOINT ["/usr/local/bin/terraform"]

0 comments on commit 1ccfddb

Please sign in to comment.