diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 0000000..81bbca6 --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,45 @@ +name: Build Docker Image + +on: + push: + branches: + - master + paths-ignore: + - 'README.md' + workflow_dispatch: + +env: + GHCR_REPO: ghcr.io/stdioa/beancount-bot + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_PAT }} + + - name: Build and push to GHCR + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/s390x + file: Dockerfile + push: true + tags: | + ${{ env.GHCR_REPO }}:latest + ${{ env.GHCR_REPO }}:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.gitignore b/.gitignore index 08b6a78..c7afdf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.ruff_cache __pycache__ tx_db.* config.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4f9ac5c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.11-slim + +RUN apt-get update && apt-get install -y python3-pip sqlite3 && \ + pip install --upgrade pip uv && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN mkdir -p /app +WORKDIR /app +ENV VIRTUAL_ENV=/packages/.venv +RUN mkdir -p $VIRTUAL_ENV && uv venv $VIRTUAL_ENV +COPY requirements-full.txt /app/ +RUN uv pip install --no-cache-dir -r requirements-full.txt +RUN uv pip install --no-cache-dir sqlite-vec=0.1.1 || true +COPY . /app + +VOLUME /data/ledger +WORKDIR /data/ledger +ENTRYPOINT ["/app/entrypoint.sh", "python", "/app/main.py"] +CMD ["telegram"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..77ccc84 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +source $VIRTUAL_ENV/bin/activate +exec "$@" diff --git a/requirements-full.txt b/requirements-full.txt new file mode 100644 index 0000000..4a16413 --- /dev/null +++ b/requirements-full.txt @@ -0,0 +1,7 @@ +beancount==2.3.6 +numpy==2.0.1 +fava==1.28 +requests==2.32.3 +pyyaml==6.0.2 +python-telegram-bot==21.4 +mmpy-bot==2.1.4