From 03d0a33f36abf89ae256321a9b4a7021eccc0420 Mon Sep 17 00:00:00 2001 From: thorian93 Date: Sat, 1 Jun 2024 19:20:17 -0400 Subject: [PATCH 1/5] Move setup instruction to top. --- README.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0ab891c..c29beb3 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,15 @@ # GpxTrackPoster Create a visually appealing poster from your GPX tracks - heavily inspired by https://www.instagram.com/p/Behppx9HCfx/ +## Setup +1. Clone the repository: `git clone https://github.com/flopp/GpxTrackPoster.git` +2. `cd GpxTrackPoster` +3. Create virtualenv: `virtualenv -p /usr/bin/python3 venv` or `python -m venv venv` +4. Activate virtualenv: `source venv/bin/activate` +5. Install the package: `pip install .` +6. Install development requirements (only if you want to contribute code!): `pip install -r requirements-dev.txt` +7. Run `create_poster` (see above) +8. Deactivate virtualenv: `deactivate` ## Usage First of all, you need directory with a bunch of GPX files (e.g. you can export all your tracks from Garmin Connect with the excellent tool [garmin-connect-export](https://github.com/kjkjava/garmin-connect-export), or use [StravaExportToGPX](https://github.com/flopp/StravaExportToGPX), or use [runtastic](https://github.com/yihong0618/Runtastic), or use [nrc-exporter](https://github.com/yasoob/nrc-exporter) to convert the activities in a Strava or Runtastic or `Nike Run Club` export zip file to GPX or GPX files). @@ -213,17 +222,6 @@ We currently support - Russian (`--language ru_RU`) - Finnish (`--language fi_FI`) - -## Setup -1. Clone the repository: `git clone https://github.com/flopp/GpxTrackPoster.git` -2. `cd GpxTrackPoster` -3. Create virtualenv: `virtualenv -p /usr/bin/python3 venv` or `python -m venv venv` -4. Activate virtualenv: `source venv/bin/activate` -5. Install the package: `pip install .` -6. Install development requirements (only if you want to contribute code!): `pip install -r requirements-dev.txt` -7. Run `create_poster` (see above) -8. Deactivate virtualenv: `deactivate` - ## Contributing If you have found a bug or have a feature request, please create a new issue. I'm always happy improve the implementation! From ec1a9a3cc8001544e82b1ddaa6023ecad8b17d74 Mon Sep 17 00:00:00 2001 From: thorian93 Date: Sat, 1 Jun 2024 20:02:48 -0400 Subject: [PATCH 2/5] First draft of Dockerfile overhaul. --- Dockerfile | 20 +++++++++++++++++--- README.md | 5 +++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4891bf6..1222710 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,20 @@ FROM python:3 WORKDIR /usr/src/app COPY requirements.txt ./ -COPY src ./src -COPY create_poster.py ./ -RUN pip install --no-cache-dir -r requirements.txt \ No newline at end of file +COPY ./ /usr/src/app/ + +RUN pip install --upgrade pip wheel && \ + pip install --upgrade -r requirements.txt && \ + pip install . + +RUN \ + rm -rf /usr/src/app/.git* && \ + rm -rf /usr/src/app/examples && \ + rm -rf /usr/src/app/venv + +RUN apt-get purge -y \ + make \ + gcc &&\ + apt-get autoremove -y && \ + apt-get autoclean -y && \ + apt-get clean all diff --git a/README.md b/README.md index c29beb3..0868768 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ Create a visually appealing poster from your GPX tracks - heavily inspired by ht 7. Run `create_poster` (see above) 8. Deactivate virtualenv: `deactivate` +### Container +There is a Dockerfile in this repository, which you can use to run this software. +1. Build the container: `podman build -f Dockerfile -t gpxtrackposter:latest` +2. Run the container to build your poster: `podman run --rm -v /my/gpx/files:/gpx --name gpxtrackposter localhost/gpxtrackposter:latest create_poster --gpx-dir /gpx --output /gpx/poster.svg` + ## Usage First of all, you need directory with a bunch of GPX files (e.g. you can export all your tracks from Garmin Connect with the excellent tool [garmin-connect-export](https://github.com/kjkjava/garmin-connect-export), or use [StravaExportToGPX](https://github.com/flopp/StravaExportToGPX), or use [runtastic](https://github.com/yihong0618/Runtastic), or use [nrc-exporter](https://github.com/yasoob/nrc-exporter) to convert the activities in a Strava or Runtastic or `Nike Run Club` export zip file to GPX or GPX files). From 07f92def3b27a24c707fc4905854b2d9f326c910 Mon Sep 17 00:00:00 2001 From: thorian93 Date: Sat, 1 Jun 2024 22:40:14 -0400 Subject: [PATCH 3/5] Improve Dockerfile. --- Dockerfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1222710..cd10038 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,18 +4,27 @@ WORKDIR /usr/src/app COPY requirements.txt ./ COPY ./ /usr/src/app/ -RUN pip install --upgrade pip wheel && \ - pip install --upgrade -r requirements.txt && \ +RUN pip install --no-cache-dir --upgrade pip wheel && \ + pip install --no-cache-dir --upgrade -r requirements.txt && \ pip install . RUN \ + rm -rf /usr/share/man/* && \ + rm -rf /root/.cache/pip/ && \ rm -rf /usr/src/app/.git* && \ rm -rf /usr/src/app/examples && \ rm -rf /usr/src/app/venv RUN apt-get purge -y \ make \ - gcc &&\ + git \ + wget \ + unzip \ + perl \ + gcc && \ apt-get autoremove -y && \ apt-get autoclean -y && \ apt-get clean all + + +CMD ["/bin/bash"] From adc1ba5b96661b1b5ea57c4c7d823de096883959 Mon Sep 17 00:00:00 2001 From: thorian93 Date: Sun, 2 Jun 2024 12:44:21 -0400 Subject: [PATCH 4/5] Remove trailing whitespace. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b6c2af5..6332f31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,4 @@ s2sphere svgwrite>=1.1.9 stravalib~=0.10 polyline -timezonefinder +timezonefinder From 4b0c975dab6bbda9f30cb8cfce3d8653c4a0197b Mon Sep 17 00:00:00 2001 From: thorian93 Date: Sun, 2 Jun 2024 14:16:34 -0400 Subject: [PATCH 5/5] Update docker-compose.yaml for easy use. --- .env.example | 9 ++++++--- .gitignore | 3 ++- README.md | 16 ++++++++++++++-- docker-compose.yml | 29 +++++++++++++++++++++-------- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/.env.example b/.env.example index b6c6f96..5b0768d 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,8 @@ +# Refer to the README or `create_poster -h` for details on the below options + +TYPE="grid" TITLE="Running" -YEAR="2017" -ATHLETE="Your name here" -UNITS="imperial" +YEAR="2024" +ATHLETE="John Doe" +UNITS="metric" EXTRA_OPTIONS= \ No newline at end of file diff --git a/.gitignore b/.gitignore index a884dde..cd0e3b7 100644 --- a/.gitignore +++ b/.gitignore @@ -57,7 +57,8 @@ sdist .mypy_cache # Project specific -gpx_dir/* +.env +gpx/* output/* data *.svg diff --git a/README.md b/README.md index 0868768..6933b7b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Create a visually appealing poster from your GPX tracks - heavily inspired by https://www.instagram.com/p/Behppx9HCfx/ ## Setup +### Local 1. Clone the repository: `git clone https://github.com/flopp/GpxTrackPoster.git` 2. `cd GpxTrackPoster` 3. Create virtualenv: `virtualenv -p /usr/bin/python3 venv` or `python -m venv venv` @@ -17,8 +18,19 @@ Create a visually appealing poster from your GPX tracks - heavily inspired by ht ### Container There is a Dockerfile in this repository, which you can use to run this software. -1. Build the container: `podman build -f Dockerfile -t gpxtrackposter:latest` -2. Run the container to build your poster: `podman run --rm -v /my/gpx/files:/gpx --name gpxtrackposter localhost/gpxtrackposter:latest create_poster --gpx-dir /gpx --output /gpx/poster.svg` + +1. Build the container: `podman build -f Dockerfile -t gpxtrackposter:latest`. +2. Run the container to build your poster: + ``` + podman run --rm -v ./gpx/:/usr/src/app/gpx -v ./output:/usr/src/app/output \ + --name gpxtrackposter localhost/gpxtrackposter:latest \ + create_poster --gpx-dir /usr/src/app/gpx --output /usr/src/app/output/poster.svg + ``` + +Alternatively you can use the included `docker-compose.yml`, which will do all the above for you. + +1. Copy the `.env.example` to `.env` and adapt it to your needs. +2. Run `podman compose up` in the root of this directory. ## Usage First of all, you need directory with a bunch of GPX files (e.g. you can export all your tracks from Garmin Connect with the excellent tool [garmin-connect-export](https://github.com/kjkjava/garmin-connect-export), or use [StravaExportToGPX](https://github.com/flopp/StravaExportToGPX), or use [runtastic](https://github.com/yihong0618/Runtastic), or use [nrc-exporter](https://github.com/yasoob/nrc-exporter) to convert the activities in a Strava or Runtastic or `Nike Run Club` export zip file to GPX or GPX files). diff --git a/docker-compose.yml b/docker-compose.yml index 3a6843e..6b31ab4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,21 @@ -app: - build: . - env_file: - - .env - command: /usr/src/app/create_poster.py --type grid --gpx-dir /usr/src/app/gpx_dir --year $YEAR --title $TITLE --athlete $ATHLETE --units $UNITS $EXTRA_OPTIONS --output /usr/src/app/output/output.svg - volumes: - - ./output:/usr/src/app/output - - ./gpx_dir:/usr/src/app/gpx_dir \ No newline at end of file +name: gpxtrackposter + +services: + create: + build: ./ + image: gpxtrackposter:latest + restart: "no" + env_file: + - .env + command: "/usr/local/bin/create_poster \ + --type ${TYPE:-'grid'} \ + --title ${TITLE:-'Running'} \ + --year ${YEAR:-'2024'} \ + --athlete ${ATHLETE:-'John Doe'} \ + --units ${UNITS:-'metric'} \ + --gpx-dir /usr/src/app/gpx \ + ${EXTRA_OPTIONS:-'--verbose'} \ + --output /usr/src/app/output/output.svg" + volumes: + - ./output:/usr/src/app/output + - ./gpx:/usr/src/app/gpx