diff --git a/.gitignore b/.gitignore index 4faf4bda..faeb702b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ venv .coverage .garmin-cookies.txt coverage.xml +.env +.env.* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..73cb0813 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3 +ADD ./ /app +WORKDIR /app +RUN pip install -r requirements.txt +VOLUME /data +ENV USERNAME example +ENV PASSWORD examplePassword +ENTRYPOINT ["python", "-m", "garminworkouts", "--cookie-jar", "/data/.garmin-cookies.txt"] diff --git a/README.md b/README.md index 8d53e6ff..61446ada 100644 --- a/README.md +++ b/README.md @@ -217,3 +217,30 @@ Note: the date format is as follows : 2021-12-31 ```shell python -m garminworkouts -u [GARMIN_USERNAME] -p [GARMIN_PASSWORD] schedule -d [DATE] -w [WORKOUT_ID] ``` + +## Username and password from environment variables + +Alternatively to the `-u` and `-p` arguments, it is possible to load the username and password from the `GARMIN_USERNAME` and `GARMIN_PASSWORD` environment variables: + +```shell +export GARMIN_USERNAME=username +export GARMIN_PASSWORD=password +python -m garminworkouts list +``` + +# Usage with Docker + +```shell +# store your credentials in a .env file +cat <> .env +GARMIN_USERNAME=user@domain.com +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.] +```