From 80c002db3300d52f668d1d515a2d0398a4d62534 Mon Sep 17 00:00:00 2001 From: Robert Williams <1266467+bobdoah@users.noreply.github.com> Date: Tue, 30 Apr 2024 21:04:59 +0100 Subject: [PATCH] feat: add image for strava uploader --- .github/workflows/containers.yaml | 54 +++++++++++++++++++++++++++++++ strava/Dockerfile | 13 ++++++++ strava/requirements.in | 1 + strava/requirements.txt | 11 ++++--- 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/containers.yaml create mode 100644 strava/Dockerfile diff --git a/.github/workflows/containers.yaml b/.github/workflows/containers.yaml new file mode 100644 index 0000000..6e41a24 --- /dev/null +++ b/.github/workflows/containers.yaml @@ -0,0 +1,54 @@ +name: containers +on: + push: + branches: main +jobs: + changes: + runs-on: ubuntu-latest + outputs: + strava: ${{ steps.filter.outputs.strava }} + steps: + - uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + strava: + - 'strava/**' + strava: + needs: changes + if: ${{ needs.changes.outputs.strava == 'true' }} + permissions: + contents: read + packages: write + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Generate Tag + shell: bash + run: echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}-${GITHUB_SHA:0:7}-$(date +%s)" >> $GITHUB_OUTPUT + id: generate_tag + - + name: Build and push + uses: docker/build-push-action@v4 + with: + context: strava/ + platforms: linux/amd64 + push: true + tags: | + ghcr.io/bobdoah/strava-uploader:${{ steps.generate_tag.outputs.tag }} diff --git a/strava/Dockerfile b/strava/Dockerfile new file mode 100644 index 0000000..2004d12 --- /dev/null +++ b/strava/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.12-slim + +WORKDIR /usr/src/app + +RUN pip install uv + +COPY requirements.txt . + +RUN uv venv && uv pip sync requirements.txt + +COPY uploader.py strava_client.py . + +ENTRYPOINT ["/usr/src/app/.venv/bin/python", "/usr/src/app/uploader.py"] diff --git a/strava/requirements.in b/strava/requirements.in index 620755a..362fc7d 100644 --- a/strava/requirements.in +++ b/strava/requirements.in @@ -1,2 +1,3 @@ stravalib tomli-w +beautifulsoup4 diff --git a/strava/requirements.txt b/strava/requirements.txt index 3a8ae66..e01c2bb 100644 --- a/strava/requirements.txt +++ b/strava/requirements.txt @@ -2,15 +2,16 @@ # uv pip compile requirements.in arrow==1.3.0 # via stravalib +beautifulsoup4==4.12.3 certifi==2024.2.2 # via requests charset-normalizer==3.3.2 # via requests -idna==3.6 +idna==3.7 # via requests pint==0.23 # via stravalib -pydantic==1.10.9 +pydantic==1.10.15 # via stravalib python-dateutil==2.9.0.post0 # via arrow @@ -20,11 +21,13 @@ requests==2.31.0 # via stravalib six==1.16.0 # via python-dateutil -stravalib==1.6 +soupsieve==2.5 + # via beautifulsoup4 +stravalib==1.7 tomli-w==1.0.0 types-python-dateutil==2.9.0.20240316 # via arrow -typing-extensions==4.10.0 +typing-extensions==4.11.0 # via # pint # pydantic