Skip to content

Commit

Permalink
Add docker support (#14)
Browse files Browse the repository at this point in the history
* Add Dockerfile

* Add docker image building action
  • Loading branch information
damyan authored Jan 25, 2024
1 parent d594388 commit 15f4031
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]

0 comments on commit 15f4031

Please sign in to comment.