Skip to content

Commit

Permalink
Add Azure
Browse files Browse the repository at this point in the history
  • Loading branch information
eifelmicha committed Jan 14, 2025
1 parent 3281d35 commit 5deddc5
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: Build Azure CI Container

on:
workflow_dispatch:
push:
paths:
- 'dockerfiles/Azure'

env:
REGISTRY: ghcr.io

jobs:
azure:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: set up qemu
uses: docker/setup-qemu-action@v3

- name: set up docker buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Read azure_env
id: azure_env
uses: jaywcjlove/github-action-read-file@main
with:
path: azure_env

- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
file: dockerfiles/Azure
tags: ci
platforms: linux/amd64,linux/arm64
build-args: |
${{ steps.azure_env.outputs.content }}
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
- 'master'
tags:
- 'v*'
paths-ignore:
- 'dockerfiles/Azure'

env:
REGISTRY: ghcr.io
Expand Down
7 changes: 7 additions & 0 deletions azure_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ANSIBLE_VERSION=2.17.0
ANSIBLE_LINT_VERSION=24.9.2
PACKER_VERSION=1.11.0
PACKER_ANSIBLE_VERSION=1.1.1
PACKER_AMAZON_VERSION=1.3.2
TERRAFORM_VERSION=1.10.3
TFLINT_VERSION=0.35.0
74 changes: 74 additions & 0 deletions dockerfiles/Azure
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
ARG OS_VERSION=stable

FROM --platform=$BUILDPLATFORM debian:${OS_VERSION}

ARG DEBIAN_FRONTEND=noninteractive

ARG ANSIBLE_VERSION \
ANSIBLE_LINT_VERSION \
PACKER_VERSION \
PACKER_ANSIBLE_VERSION \
PACKER_AMAZON_VERSION \
TERRAFORM_VERSION \
TFLINT_VERSION

COPY ./requirements/collections_ansible_current.yml /collections_ansible.yml


# Install dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
bash \
gnupg \
ca-certificates \
curl \
locales \
lsb-release \
procps \
software-properties-common \
sudo \
tar \
unzip \
wget \
xz-utils \
zip \
&& apt-get clean \
&& rm -Rf /var/lib/apt/lists/* \
&& rm -Rf /usr/share/doc && find /usr/share/man -type f -delete \
&& rm -rf /tmp/* /var/tmp/*;

# Install Python 3.12
RUN wget -qO- https://pascalroeleven.nl/deb-pascalroeleven.gpg | sudo tee /etc/apt/keyrings/deb-pascalroeleven.gpg
RUN echo "\
Types: deb\n\
URIs: http://deb.pascalroeleven.nl/python3.12\n\
Suites: bookworm-backports\n\
Components: main\n\
Signed-By: /etc/apt/keyrings/deb-pascalroeleven.gpg" \
> /etc/apt/sources.list.d/pascalroeleven.sources

RUN apt-get update \
&& apt-get -y install python3.12 python3.12-dev python3.12-venv

# Use Python 3.12 when calling python3
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2

# Install pip
RUN . /opt/ansible_virtualenv/bin/activate && python3 -m venv /opt/ansible_virtualenv
RUN . /opt/ansible_virtualenv/bin/activate && python3 -m pip install --upgrade pip

# Install Ansible / AnsibleLint + Collections
RUN . /opt/ansible_virtualenv/bin/activate && pip3 install ansible==${ANSIBLE_VERSION} ansible-lint==${ANSIBLE_LINT_VERSION}
RUN ansible-galaxy collection install -r /collections_ansible.yml

# Install Packer + Plugins
RUN curl -sLSfo packer.zip https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_$(dpkg --print-architecture).zip && unzip -o packer.zip && mv packer /usr/bin -f && rm packer.zip
RUN packer plugins install "github.com/hashicorp/amazon" ${PACKER_ANSIBLE_VERSION} && \
packer plugins install "github.com/hashicorp/ansible" ${PACKER_ANSIBLE_VERSION}

# Install Terraform
RUN curl -sLSfo https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_$(dpkg --print-architecture).zip $tf_url && unzip -o terraform.zip && mv terraform /usr/bin -f && rm terraform.zip

# Install TFlint
RUN TFLINT_VERSION=${TFLINT_VERSION} curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash

0 comments on commit 5deddc5

Please sign in to comment.