Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile and instructions to run with docker #45

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ venv
.coverage
.garmin-cookies.txt
coverage.xml
.env
.env.*
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3
ADD ./ /app
WORKDIR /app
RUN pip install -r requirements.txt
VOLUME /data
VOLUME /tmp
ENV USERNAME example
ENV PASSWORD examplePassword
ENTRYPOINT ["python", "-m", "garminworkouts", "--cookie-jar", "/tmp/.garmin-cookies.txt"]
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,27 @@ Note: the date format is as follows : 2021-12-31
```shell
python -m garminworkouts schedule -d [DATE] -w [WORKOUT_ID]
```

# Usage with Docker

```shell
# store your credentials in a .env file
cat <<EOT >> .env
[email protected]
GARMIN_PASSWORD=mypassword
EOT
# name the image
IMAGE=garminworkouts
# build the image
docker build --load -t ${IMAGE} .
# run the image (the "-v /tmp/garmin:/data" part is optional
# and will be used to persist the cookies file)
docker run --env-file=./.env -v /tmp/garmin:/data -ti ${IMAGE} [your command and arguments: list, export, etc.]
# alternatively you can use this wrapper
./dockerwrap.sh [your command and arguments: list, export, etc.]
# in case you want to export to a directory, you need to use /data
# inside the container and point DATADIR to the local dir where to
# write the data (./ by default).
export DATADIR=/path/where/to/store/data/locally
./dockerwrap.sh export /data
```
8 changes: 8 additions & 0 deletions dockerwrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -u

IMAGE="${IMAGE}"
ENVFILE="${ENVFILE-.env}"
TMPDIR="${TMPDIR-/tmp/garmin}"
DATADIR="${DATADIR-./}"
exec docker run --env-file=${ENVFILE} -v ${TMPDIR}:/tmp -v ${DATADIR}:/data/ -ti ${IMAGE} $@