diff --git a/.github/workflows/openldap-minion.yml b/.github/workflows/openldap-minion.yml new file mode 100644 index 0000000..8f222e5 --- /dev/null +++ b/.github/workflows/openldap-minion.yml @@ -0,0 +1,107 @@ +name: "OpenLDAP Minion 🐳 Container" + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + push: + branches: + - '*' + paths: + - containers.yml + - '.github/workflows/*.yml' + - 'custom/openldap-minion/*.Dockerfile' + +env: + MIRROR_IMAGE_PATH: custom/openldap-minion + +jobs: + matrix-generator: + name: "Mirror Matrix Generator" + runs-on: ubuntu-latest + outputs: + dockerinfo: ${{ steps.set-matrix.outputs.dockerinfo }} + steps: + - name: "Fetching Repository Contents" + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + + - name: Install Requirements + run: | + python -m pip install -r requirements.txt + + - name: "Generate Matrix Data" + id: set-matrix + run: | + inv containers.matrix --from-workflow ${{ env.MIRROR_IMAGE_PATH }} + + mirror-image: + runs-on: ubuntu-latest + needs: matrix-generator + name: "${{ matrix.dockerinfo.name }}" + strategy: + fail-fast: false + max-parallel: 20 + matrix: + dockerinfo: ${{ fromJson(needs.matrix-generator.outputs.dockerinfo) }} + + permissions: + actions: read + checks: write + issues: read + packages: write + pull-requests: read + repository-projects: read + statuses: read + + steps: + - name: "Fetching Repository Contents" + uses: actions/checkout@v2 + + - name: "Throttle concurrent pushes" + run: | + t=$(shuf -i 5-30 -n 1); echo "Sleeping $t seconds"; sleep $t + + - name: "Setup DockerFile" + run: | + echo " " >> ./${{matrix.dockerinfo.file}} + echo "LABEL org.opencontainers.image.source=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}} + echo "LABEL org.opencontainers.image.url=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}} + echo "LABEL org.opencontainers.image.documentation=\"https://github.com/${GITHUB_REPOSITORY}/\"" >> ${{matrix.dockerinfo.file}} + echo "LABEL org.opencontainers.image.vendor=\"Unofficial Docker Hub Mirror\"" >> ${{matrix.dockerinfo.file}} + cat ./${{matrix.dockerinfo.file}} + + - name: "Docker QEMU" + uses: docker/setup-qemu-action@v2 + + - name: "Docker BuildX" + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Inspect builder + run: | + echo "Name: ${{ steps.buildx.outputs.name }}" + echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" + echo "Status: ${{ steps.buildx.outputs.status }}" + echo "Flags: ${{ steps.buildx.outputs.flags }}" + echo "Platforms: ${{ steps.buildx.outputs.platforms }}" + + - name: "Log into GitHub Container Registry" + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: "Build & Publish" + uses: docker/build-push-action@v3 + with: + file: ${{ matrix.dockerinfo.file }} + context: ${{ env.MIRROR_IMAGE_PATH }} + push: true + tags: | + ghcr.io/${{ github.repository }}/${{ matrix.dockerinfo.name }} diff --git a/README.md b/README.md index 5fec341..c53597b 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,11 @@ will be commited. ## Custom +### [![OpenLDAP Minion](https://github.com/saltstack/salt-ci-containers/actions/workflows/openldap-minion.yml/badge.svg)](https://github.com/saltstack/salt-ci-containers/actions/workflows/openldap-minion.yml) + +- openldap-minion:latest - `ghcr.io/saltstack/salt-ci-containers/openldap-minion:latest` + + ### [![Virt Minion](https://github.com/saltstack/salt-ci-containers/actions/workflows/virt-minion.yml/badge.svg)](https://github.com/saltstack/salt-ci-containers/actions/workflows/virt-minion.yml) - virt-minion:latest - `ghcr.io/saltstack/salt-ci-containers/virt-minion:latest` diff --git a/containers.yml b/containers.yml index f45ef1b..9517bc1 100644 --- a/containers.yml +++ b/containers.yml @@ -13,6 +13,10 @@ salt: # ----- Custom Containers --------------------------------------------------------------------------------> # Custom images used in the CI pipeline custom: + OpenLDAP Minion: + name: openldap-minion + versions: + - latest Virt Minion: name: virt-minion versions: diff --git a/custom/openldap-minion/Makefile b/custom/openldap-minion/Makefile new file mode 100644 index 0000000..37ea0f9 --- /dev/null +++ b/custom/openldap-minion/Makefile @@ -0,0 +1,23 @@ +SALT_PATH ?= $(shell python -c 'import os, salt; print(os.path.abspath(salt.__file__ + "../../.."))') + +all: build + +build: + docker build -t openldap-minion:latest -f latest.Dockerfile . + +run: + if [ -d $(SALT_PATH) ]; then \ + docker run \ + --rm \ + --privileged \ + --device /dev/mem \ + --network host \ + --name openldap-minion \ + -it \ + --mount type=bind,source=$(SALT_PATH),target=/salt \ + openldap-minion:latest \ + sh; \ + fi + +clean: + docker rmi openldap-minion diff --git a/custom/openldap-minion/README.md b/custom/openldap-minion/README.md new file mode 100644 index 0000000..eb9ed8b --- /dev/null +++ b/custom/openldap-minion/README.md @@ -0,0 +1,3 @@ +# [![OpenLDAP Minion](https://github.com/saltstack/salt-ci-containers/actions/workflows/openldap-minion.yml/badge.svg)](https://github.com/saltstack/salt-ci-containers/actions/workflows/openldap-minion.yml) + +- openldap-minion:latest - `ghcr.io/saltstack/salt-ci-containers/openldap-minion:latest` diff --git a/custom/openldap-minion/latest.Dockerfile b/custom/openldap-minion/latest.Dockerfile new file mode 100644 index 0000000..0a31579 --- /dev/null +++ b/custom/openldap-minion/latest.Dockerfile @@ -0,0 +1,12 @@ +FROM docker.io/bitnami/openldap:latest + +USER root +RUN install_packages \ + python3-distro \ + python3-jinja2 \ + python3-ldap \ + python3-msgpack \ + python3-pycryptodome \ + python3-yaml \ + python3-zmq +USER 1001