diff --git a/.github/workflows/azure.yml b/.github/workflows/azure.yml new file mode 100644 index 0000000..f102a18 --- /dev/null +++ b/.github/workflows/azure.yml @@ -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.package.azure_env.content }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1f0a224..8d3953b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,6 +15,8 @@ on: - 'master' tags: - 'v*' + paths-ignore: + - 'dockerfiles/Azure' env: REGISTRY: ghcr.io diff --git a/azure_env b/azure_env new file mode 100644 index 0000000..c3e5895 --- /dev/null +++ b/azure_env @@ -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 diff --git a/dockerfiles/Azure b/dockerfiles/Azure new file mode 100644 index 0000000..4c4b5d6 --- /dev/null +++ b/dockerfiles/Azure @@ -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 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