From 5c62f90b7fa3aa2523955553cbac6f1cef276bca Mon Sep 17 00:00:00 2001 From: Ryan Moon Date: Tue, 31 Mar 2026 18:29:15 -0500 Subject: [PATCH] Add custom runner image with ansible, terraform, community.docker --- .gitea/workflows/ansible.yml | 6 +----- .gitea/workflows/build-runner.yml | 27 +++++++++++++++++++++++++++ .gitea/workflows/terraform.yml | 4 +--- runner/Dockerfile | 24 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .gitea/workflows/build-runner.yml create mode 100644 runner/Dockerfile diff --git a/.gitea/workflows/ansible.yml b/.gitea/workflows/ansible.yml index afdc233..bc919b1 100644 --- a/.gitea/workflows/ansible.yml +++ b/.gitea/workflows/ansible.yml @@ -18,6 +18,7 @@ on: jobs: ansible: runs-on: ubuntu-latest + container: git.lunarfront.tech/ryan/runner:latest defaults: run: working-directory: ansible @@ -26,11 +27,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Install Ansible - run: | - apt-get update -qq - apt-get install -y ansible - - name: Write SSH key run: | mkdir -p ~/.ssh diff --git a/.gitea/workflows/build-runner.yml b/.gitea/workflows/build-runner.yml new file mode 100644 index 0000000..ca3b71f --- /dev/null +++ b/.gitea/workflows/build-runner.yml @@ -0,0 +1,27 @@ +name: Build Runner Image + +on: + push: + branches: [main] + paths: + - 'runner/**' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Gitea registry + run: echo "${{ secrets.GITEA_TOKEN }}" | docker login git.lunarfront.tech -u ryan --password-stdin + + - name: Build and push + run: | + docker build -t git.lunarfront.tech/ryan/runner:latest runner/ + docker push git.lunarfront.tech/ryan/runner:latest + + - name: Logout + if: always() + run: docker logout git.lunarfront.tech diff --git a/.gitea/workflows/terraform.yml b/.gitea/workflows/terraform.yml index 8668326..b2fe216 100644 --- a/.gitea/workflows/terraform.yml +++ b/.gitea/workflows/terraform.yml @@ -20,6 +20,7 @@ on: jobs: terraform: runs-on: ubuntu-latest + container: git.lunarfront.tech/ryan/runner:latest defaults: run: working-directory: terraform @@ -28,9 +29,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup Terraform - uses: hashicorp/setup-terraform@v3 - - name: Terraform Init env: AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} diff --git a/runner/Dockerfile b/runner/Dockerfile new file mode 100644 index 0000000..bb88e77 --- /dev/null +++ b/runner/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:24.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + ansible \ + curl \ + git \ + gnupg \ + openssh-client \ + python3 \ + python3-pip \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# Terraform +RUN curl -fsSL https://releases.hashicorp.com/terraform/1.10.5/terraform_1.10.5_linux_amd64.zip -o terraform.zip \ + && unzip terraform.zip -d /usr/local/bin \ + && rm terraform.zip + +# Ansible collections +RUN ansible-galaxy collection install community.docker + +RUN terraform --version && ansible --version