diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml new file mode 100644 index 0000000..112a49a --- /dev/null +++ b/.github/workflows/publish-docker.yaml @@ -0,0 +1,66 @@ +name: 'Build and Publish Docker Image' + +env: + platforms: linux/amd64,linux/arm64 + +on: + push: + branches: + - main + tags: + - v* + paths-ignore: + - 'docs/**' + - '**/*.md' + pull_request: + paths-ignore: + - 'docs/**' + - '**/*.md' + +jobs: + buildAndPush: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: | + ghcr.io/${{ github.repository_owner }}/kicktipp + tags: | + type=semver,pattern={{version}} + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=sha + flavor: | + latest=${{ github.ref == 'refs/heads/main' }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:latest + platforms: ${{env.platforms}} + - name: Set up Docker Buildx + timeout-minutes: 5 + uses: docker/setup-buildx-action@v3 + with: + version: latest + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + timeout-minutes: 100 + uses: docker/build-push-action@v5 + with: + context: . + platforms: ${{env.platforms}} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..82c6dfe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.11 AS builder +COPY requirements.txt . + +RUN pip install --user -r requirements.txt + +FROM python:3.11-slim +WORKDIR /code + +# copy only the dependencies installation from the 1st stage image +COPY --from=builder /root/.local /root/.local +COPY ./src . + +# update PATH environment variable +ENV PATH=/root/.local:$PATH + +ENTRYPOINT [ "python", "auto_submit_tips.py" ]