Skip to content

Commit b8f48df

Browse files
author
az
committed
test: add pre-installed packages to Docker image
1 parent 686a1e8 commit b8f48df

2 files changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Test Docker Image Build
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- 'Dockerfile'
8+
- '.github/workflows/test-docker-image.yaml'
9+
10+
jobs:
11+
build-test-image:
12+
name: Build Test Image
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set lowercase owner
24+
run: echo "OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Build and push test image
37+
uses: docker/build-push-action@v5
38+
with:
39+
context: .
40+
platforms: linux/amd64
41+
push: true
42+
tags: |
43+
ghcr.io/${{ env.OWNER }}/github-runner:test
44+
ghcr.io/${{ env.OWNER }}/github-runner:test-${{ github.sha }}
45+
46+
verify-tools:
47+
name: Verify Pre-installed Tools
48+
needs: build-test-image
49+
runs-on: ubuntu-latest
50+
container:
51+
image: ghcr.io/${{ github.repository_owner }}/github-runner:test
52+
credentials:
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
steps:
57+
- name: Verify Atmos installation
58+
run: |
59+
echo "Checking Atmos..."
60+
atmos version
61+
which atmos
62+
63+
- name: Verify Terraform installation
64+
run: |
65+
echo "Checking Terraform..."
66+
terraform version
67+
which terraform
68+
69+
- name: Verify tfcmt installation
70+
run: |
71+
echo "Checking tfcmt..."
72+
tfcmt --version
73+
which tfcmt
74+
75+
- name: Verify terraform-docs installation
76+
run: |
77+
echo "Checking terraform-docs..."
78+
terraform-docs --version
79+
which terraform-docs
80+
81+
- name: Verify all tools are in PATH
82+
run: |
83+
echo "All tools verified successfully!"
84+
echo "✅ Atmos: $(atmos version | head -n 1)"
85+
echo "✅ Terraform: $(terraform version | head -n 1)"
86+
echo "✅ tfcmt: $(tfcmt --version)"
87+
echo "✅ terraform-docs: $(terraform-docs --version)"
88+
89+
- name: Summary
90+
if: success()
91+
run: |
92+
echo "🎉 All pre-installed tools are working correctly!"
93+
echo "The Docker image is ready to use and will avoid GitHub API rate limits."

‎Dockerfile‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,46 @@ RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zi
2626
&& sudo ./aws/install \
2727
&& sudo rm -rf aws awscliv2.zip
2828

29+
# Install workflow tools to avoid GitHub API rate limits during execution
30+
# All tools are installed in a single layer to minimize image size
31+
RUN set -eux; \
32+
ARCH="$(uname -m)"; \
33+
case "$ARCH" in \
34+
x86_64) ARCH='amd64' ;; \
35+
aarch64) ARCH='arm64' ;; \
36+
*) echo "Unsupported architecture: $ARCH"; exit 1 ;; \
37+
esac; \
38+
\
39+
# Install Atmos CLI v1.195.0
40+
echo "Installing Atmos CLI v1.195.0..."; \
41+
curl -fsSL "https://github.com/cloudposse/atmos/releases/download/v1.195.0/atmos_1.195.0_linux_${ARCH}" -o /tmp/atmos && \
42+
sudo install -m 755 /tmp/atmos /usr/local/bin/atmos && \
43+
rm /tmp/atmos && \
44+
atmos version && \
45+
\
46+
# Install Terraform (latest stable - 1.10.4)
47+
echo "Installing Terraform v1.10.4..."; \
48+
curl -fsSL "https://releases.hashicorp.com/terraform/1.10.4/terraform_1.10.4_linux_${ARCH}.zip" -o /tmp/terraform.zip && \
49+
sudo unzip -q /tmp/terraform.zip -d /usr/local/bin/ && \
50+
rm /tmp/terraform.zip && \
51+
terraform version && \
52+
\
53+
# Install tfcmt v4.14.0
54+
echo "Installing tfcmt v4.14.0..."; \
55+
curl -fsSL "https://github.com/suzuki-shunsuke/tfcmt/releases/download/v4.14.0/tfcmt_linux_${ARCH}.tar.gz" -o /tmp/tfcmt.tar.gz && \
56+
sudo tar -xzf /tmp/tfcmt.tar.gz -C /usr/local/bin/ tfcmt && \
57+
rm /tmp/tfcmt.tar.gz && \
58+
tfcmt --version && \
59+
\
60+
# Install terraform-docs v0.18.0
61+
echo "Installing terraform-docs v0.18.0..."; \
62+
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 && \
63+
sudo tar -xzf /tmp/terraform-docs.tar.gz -C /usr/local/bin/ terraform-docs && \
64+
rm /tmp/terraform-docs.tar.gz && \
65+
terraform-docs --version && \
66+
\
67+
echo "All tools installed successfully!"
68+
2969
RUN mkdir -p ~/.ssh && \
3070
ssh-keyscan github.com >> ~/.ssh/known_hosts
3171

0 commit comments

Comments
 (0)