Skip to content

Commit da675c7

Browse files
committed
Add Dockerfile and usage examples
1 parent 7b1eeba commit da675c7

2 files changed

Lines changed: 99 additions & 1 deletion

File tree

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
COPY . .
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
ENTRYPOINT ["python3", "gcexport.py"]
9+
10+
# Default command if no arguments are provided to `docker run`
11+
CMD ["--help"]

README.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ If there is no GPS track data (e.g., due to an indoor treadmill workout), a data
3434

3535
If you have many activities, you may find that this script crashes with an "Operation timed out" message. Just run the script again and it will pick up where it left off.
3636

37-
## Installation
37+
## Running the script
38+
39+
To run the script, you can either:
40+
41+
- Run the script using the Docker CLI using the pre-built Docker image. See [Docker Usage](#docker-usage) for details.
42+
- Install the dependencies locally and run the script using the Python CLI. See [Local Installation](#local-installation) and [Usage](#usage) for details.
43+
44+
## Local Installation
45+
46+
If you are **not** using Docker, install the dependencies locally:
3847

3948
- If you're comfortable using Git, just clone the repo from github
4049
- Otherwise get the latest `zip` (or `tar.gz`) from the [releases page](https://github.com/pe-st/garmin-connect-export/releases)
@@ -95,6 +104,84 @@ optional arguments:
95104
enable loading and storing SSO information from/to given directory
96105
```
97106

107+
### Docker Usage
108+
109+
This section contains some tips and tricks to run the script using Docker. See the [Usage](#usage) section above for general script usage.
110+
111+
#### Create working directory
112+
113+
Create a directory where you want to store the garmin export data and session data:
114+
115+
```shell
116+
mkdir -p ~/Documents/garmin_export
117+
cd ~/Documents/garmin_export
118+
```
119+
120+
#### Set environment variables
121+
122+
Export your username and password as environment variables:
123+
124+
```shell
125+
export GARMIN_USERNAME=abc
126+
export GARMIN_PASSWORD=xyz
127+
```
128+
129+
#### Run the docker container
130+
131+
When running the docker container, make sure to:
132+
133+
1. Override the `--directory` and `--session` command line arguments with static directories in the container.
134+
2. Mount the static `export_data` and `session_data` directories in the container to your local directories.
135+
136+
This results in garmin export data being outputted to the local `./my_garmin_data` directory.
137+
138+
```shell
139+
docker run -it --rm \
140+
-v "$(pwd)/my_garmin_data:/export_data" \
141+
-v "$(pwd)/my_garmin_session:/session_data" \
142+
garmin-connect-exporter \
143+
--directory /export_data \
144+
--subdir '{YYYY}/{MM}/' \
145+
--logpath /export_data/logs \
146+
--session /session_data \
147+
--username ${GARMIN_USERNAME} \
148+
--password ${GARMIN_PASSWORD}
149+
```
150+
151+
Optionally, follow the same process for the `--template` argument:
152+
153+
```shell
154+
155+
docker run -it --rm \
156+
-v "$(pwd)/my_garmin_template:/template_data" \
157+
... \
158+
garmin-connect-exporter \
159+
--template /template_data/my_template.properties \
160+
...
161+
```
162+
163+
#### Output directories
164+
165+
After running the script, you should see the following directories in your working directory (e.g. `~/Documents/garmin_export`):
166+
167+
```text
168+
.
169+
├── my_garmin_data
170+
│   ├── 2025
171+
│   │   └── 05
172+
│   │   └── activity_19000000000.gpx
173+
│   ├── activities-1-1.json
174+
│   ├── activities.csv
175+
│   ├── device_120000.json
176+
│   ├── downloaded_ids.json
177+
│   ├── logs
178+
│   │   └── gcexport.log
179+
│   └── userstats.json
180+
└── my_garmin_session
181+
├── oauth1_token.json
182+
└── oauth2_token.json
183+
```
184+
98185
### Authentication
99186

100187
You have to authenticate with username and password, and possibly an MFA code, at least for an initial login.

0 commit comments

Comments
 (0)