Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/test-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Test Docker Image Build

on:
workflow_dispatch:
pull_request:
paths:
- 'Dockerfile'
- '.github/workflows/test-docker-image.yaml'

jobs:
build-test-image:
name: Build Test Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set lowercase owner
run: echo "OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push test image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ env.OWNER }}/github-runner:test
ghcr.io/${{ env.OWNER }}/github-runner:test-${{ github.sha }}

verify-tools:
name: Verify Pre-installed Tools
needs: build-test-image
runs-on: ubuntu-latest

steps:
- name: Set lowercase owner
run: echo "OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull and verify test image
run: |
# Pull the test image
docker pull ghcr.io/${{ env.OWNER }}/github-runner:test

# Verify Atmos
echo "Checking Atmos..."
docker run --rm ghcr.io/${{ env.OWNER }}/github-runner:test atmos version

# Verify Terraform
echo "Checking Terraform..."
docker run --rm ghcr.io/${{ env.OWNER }}/github-runner:test terraform version

# Verify tfcmt
echo "Checking tfcmt..."
docker run --rm ghcr.io/${{ env.OWNER }}/github-runner:test tfcmt --version

# Verify terraform-docs
echo "Checking terraform-docs..."
docker run --rm ghcr.io/${{ env.OWNER }}/github-runner:test terraform-docs --version

# Summary
echo "✅ All tools verified successfully!"
echo "The Docker image is ready to use and will avoid GitHub API rate limits."
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,46 @@ RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zi
&& sudo ./aws/install \
&& sudo rm -rf aws awscliv2.zip

# Install workflow tools to avoid GitHub API rate limits during execution
# All tools are installed in a single layer to minimize image size
RUN set -eux; \
ARCH="$(uname -m)"; \
case "$ARCH" in \
x86_64) ARCH='amd64' ;; \
aarch64) ARCH='arm64' ;; \
*) echo "Unsupported architecture: $ARCH"; exit 1 ;; \
esac; \
\
# Install Atmos CLI v1.195.0
echo "Installing Atmos CLI v1.195.0..."; \
curl -fsSL "https://github.com/cloudposse/atmos/releases/download/v1.195.0/atmos_1.195.0_linux_${ARCH}" -o /tmp/atmos && \
sudo install -m 755 /tmp/atmos /usr/local/bin/atmos && \
rm /tmp/atmos && \
atmos version && \
\
# Install Terraform (latest stable - 1.10.4)
echo "Installing Terraform v1.10.4..."; \
curl -fsSL "https://releases.hashicorp.com/terraform/1.10.4/terraform_1.10.4_linux_${ARCH}.zip" -o /tmp/terraform.zip && \
sudo unzip -q /tmp/terraform.zip -d /usr/local/bin/ && \
rm /tmp/terraform.zip && \
terraform version && \
\
# Install tfcmt v4.14.0
echo "Installing tfcmt v4.14.0..."; \
curl -fsSL "https://github.com/suzuki-shunsuke/tfcmt/releases/download/v4.14.0/tfcmt_linux_${ARCH}.tar.gz" -o /tmp/tfcmt.tar.gz && \
sudo tar -xzf /tmp/tfcmt.tar.gz -C /usr/local/bin/ tfcmt && \
rm /tmp/tfcmt.tar.gz && \
tfcmt --version && \
\
# Install terraform-docs v0.18.0
echo "Installing terraform-docs v0.18.0..."; \
curl -fsSL "https://github.com/terraform-docs/terraform-docs/releases/download/v0.18.0/terraform-docs-v0.18.0-linux-${ARCH}.tar.gz" -o /tmp/terraform-docs.tar.gz && \
sudo tar -xzf /tmp/terraform-docs.tar.gz -C /usr/local/bin/ terraform-docs && \
rm /tmp/terraform-docs.tar.gz && \
terraform-docs --version && \
\
echo "All tools installed successfully!"

RUN mkdir -p ~/.ssh && \
ssh-keyscan github.com >> ~/.ssh/known_hosts

Expand Down