diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 5f30c53..338453e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -5,6 +5,9 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + ANSIBLE_CORE_VERSION: 2.16.3 + ANSIBLE_VERSION: 9.2.0 + ANSIBLE_LINT: 6.22.2 jobs: build: runs-on: ubuntu-latest @@ -44,6 +47,10 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + ANSIBLE_CORE_VERSION=2.16.3 + ANSIBLE_VERSION=9.2.0 + ANSIBLE_LINT=6.22.2 - name: Sign the published Docker image if: ${{ github.event_name != 'pull_request' }} env: diff --git a/Dockerfile b/Dockerfile index 4ea060f..8d7505c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,30 @@ -FROM debian:12 +FROM ubuntu:22.04 -RUN apt-get update \ - && apt-get install --no-install-recommends -y python3-pip \ - && rm -rf /var/lib/apt/lists/* -RUN pip install pip --upgrade -RUN pip install ansible +ARG ANSIBLE_CORE_VERSION +ARG ANSIBLE_VERSION +ARG ANSIBLE_LINT +ENV ANSIBLE_CORE_VERSION ${ANSIBLE_CORE_VERSION} +ENV ANSIBLE_VERSION ${ANSIBLE_VERSION} +ENV ANSIBLE_LINT ${ANSIBLE_LINT} -RUN apt-get update -y && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - sshpass +LABEL maintainer="contact@thinkcube.dev" -WORKDIR /work +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + apt-get install -y gnupg2 python3-pip sshpass git openssh-client && \ + rm -rf /var/lib/apt/lists/* && \ + apt-get clean + +RUN python3 -m pip install --upgrade pip cffi && \ + pip3 install ansible-core==${ANSIBLE_CORE_VERSION} && \ + pip3 install ansible==${ANSIBLE_VERSION} ansible-lint==${ANSIBLE_LINT} && \ + pip3 install mitogen jmespath && \ + pip install --upgrade pywinrm && \ + rm -rf /root/.cache/pip + +RUN mkdir /ansible && \ + mkdir -p /etc/ansible && \ + echo 'localhost' > /etc/ansible/hosts + +WORKDIR /ansible + +CMD [ "ansible-playbook", "--version" ] diff --git a/README.md b/README.md index e63841a..a8d689e 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,16 @@ This repository houses a Dockerfile for creating a Docker image tailored for Ans The Dockerfile follows these major steps: -1. Update package lists and install Python 3 and Pip. -2. Upgrade Pip and install Ansible. -3. Install `sshpass` for SSH password support. -4. Set the working directory to `/work`. +1. Update package lists and install required dependencies. +2. Install and configure Python, Pip, and other necessary tools. +3. Install specified versions of Ansible, Ansible Core, and Ansible Lint. +4. Set up the working directory and essential Ansible files. + +## Environment Variables + +* `ANSIBLE_CORE_VERSION`: Version of Ansible Core. +* `ANSIBLE_VERSION`: Version of Ansible. +* `ANSIBLE_LINT`: Version of Ansible Lint. ## License