Skip to content

Commit

Permalink
Add docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
StdioA committed Aug 19, 2024
1 parent 88bf9d8 commit 1445725
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.ruff_cache
__pycache__
tx_db.*
config.yaml
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.11

RUN apt-get update && apt-get install -y python3-lxml 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"]
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
source $VIRTUAL_ENV/bin/activate
exec "$@"
7 changes: 7 additions & 0 deletions requirements-full.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1445725

Please sign in to comment.