From 4b3fbe34fa91da818e26f56deea0aa649e3319a9 Mon Sep 17 00:00:00 2001 From: Aine Date: Sun, 15 Sep 2024 20:17:46 +0300 Subject: [PATCH] add Dockerfile and CI config --- .dockerignore | 21 +++++++++++++++++++ .github/workflows/workflow.yml | 38 ++++++++++++++++++++++++++++++++++ Dockerfile | 13 ++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/workflow.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e748acc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +/inventory + +# ignore roles pulled by ansible-galaxy +/roles/galaxy/* +!/roles/galaxy/.gitkeep + +# ignores vscode file +.vscode + +# ignores macos files +.DS_Store + +/requirements.yml +/setup.yml +/group_vars/mash_servers + +/run/* +!/run/.gitkeep + +/group_vars/* +!/group_vars/.gitkeep diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..1ddced7 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,38 @@ +name: CI (main and tags) +on: + push: + branches: [ "main" ] + tags: [ "v*" ] +permissions: + checks: write + contents: write + packages: write + pull-requests: read +jobs: + build-publish: + name: Build and Publish + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable=${{ github.ref_name == 'main' }} + type=semver,pattern={{raw}} + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a394f2e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM alpine:latest + +ENV ANSIBLE_LOG_PATH=" " +WORKDIR /playbook +ENTRYPOINT ["/bin/sh"] + +RUN apk add --no-cache ansible ansible-core py3-passlib git openssh-client just + +COPY . /playbook + +RUN git rev-parse HEAD > /playbook/source-commit && \ + rm -rf /playbook/.git && \ + just roles