From db4e3b51000ba0f626961d752d4e4e7f56866c37 Mon Sep 17 00:00:00 2001 From: NMC Date: Wed, 15 Jan 2025 00:36:14 -0500 Subject: [PATCH] Add docker and build-push github action. --- .github/workflows/docker-build-push.yml | 48 +++++++++++++++++++++++++ Dockerfile | 15 ++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/docker-build-push.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..355dd56 --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,48 @@ +name: Docker Build and Push + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..739c302 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3-alpine + +RUN apk update && \ + apk add --no-cache py3-colorama && \ + pip install --no-cache-dir setuptools && \ + rm -rf /var/cache/apk/* + +WORKDIR /app + +COPY . /app + +RUN python3 setup.py install + + +CMD [ "sara", "--config-file", "/config/routeros.rsc" ] \ No newline at end of file