Skip to content

Commit

Permalink
Merge pull request #27 from jmuzina/build-updates
Browse files Browse the repository at this point in the history
Change local dev environment setup to use Docker
  • Loading branch information
jmuzina authored Jan 13, 2024
2 parents 4f02115 + 241b2a6 commit 4869dc9
Show file tree
Hide file tree
Showing 51 changed files with 62 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/logs
src/uploads
start.sh
start.bat
venv
Dockerfile-local
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
*venv*

# User uploaded files directory
uploads/
src/uploads/
# sensitive auth data
*.cfg
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
static/all.css
src/static/all.css

# logging data
logs/
src/logs
src/uploads

# C extensions
*.so
Expand Down Expand Up @@ -113,7 +114,7 @@ celerybeat.pid
*.sage.py

# Environments
.env
src/.env
.venv
env/
venv/
Expand All @@ -139,3 +140,7 @@ dmypy.json
# Pyre type checker
.pyre/
*.cfg

# IDEs
/.vscode
/.idea
17 changes: 17 additions & 0 deletions Dockerfile-local
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.9.18-slim-bullseye

# Set the working directory in the container
WORKDIR /gpxvis

# Copy the dependencies file to the working directory
COPY src/ /gpxvis/

# Install any dependencies
RUN pip3 install -r requirements.txt
RUN rm requirements.txt

# Listen on port 5000
EXPOSE 5000

# Run flask
ENTRYPOINT ["python3", "-m", "flask", "run", "--host=0.0.0.0"]
18 changes: 13 additions & 5 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
* **Activity filtering**: Filter activities by date, activity type, and other attributes
* **Generate custom images**: Turn your activities into images with custom color, background, and style!
------------------
## Building
- Install python dependencies: `pip install -r requirements.txt`
- Set environment variables (.env):
- `APP_ADDRESS`: Base address of the application where it is being served. If unset, the app will use `http://127.0.0.1:5000`.
## Running in developer environment
- Set environment variables (src/.env):
- `APP_ADDRESS`: Base address of the application where it is being served. If unset, the app will use [http://localhost](http://localhost).
- Strava auth data (see [Developer Dashboard](https://www.strava.com/settings/api))
- `STRAVA_CLIENT_ID`: Strava OAUTH Client ID
- `STRAVA_CLIENT_SECRET`: Strava OAUTH Client Secret
- Run Flask locally: `python3 -m flask run`

### Docker container

Docker is used to build and run the application.

#### Windows
`./start.bat`

#### Unix
`source ./start.sh`
File renamed without changes.
18 changes: 9 additions & 9 deletions app.py → src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,38 +286,38 @@ def refreshSessionTimer():

@flaskApp.route("/activityFiltering.js")
def returnActivityFiltering():
return send_file("./static/activityFiltering.js")
return send_file("static/activityFiltering.js")

@flaskApp.route("/fileVerification.js")
def returnFileVerification():
return send_file("./static/fileVerification.js")
return send_file("static/fileVerification.js")

@flaskApp.route("/dynamicParameters.js")
def returnDynamicParameters():
return send_file("./static/dynamicParameters.js")
return send_file("static/dynamicParameters.js")

@flaskApp.route("/resize.js")
def returnResize():
return send_file("./static/resize.js")
return send_file("static/resize.js")

@flaskApp.route("/logo")
def returnLogo():
if not request.args.get("size") or request.args.get("size") == "full":
return send_file("./static/logo/logo_full.png")
return send_file("static/logo/logo_full.png")
elif request.args.get("size") == "300":
return send_file("./static/logo/logo_300.png")
return send_file("static/logo/logo_300.png")
elif request.args.get("size") == "favicon":
return send_file("./static/logo/favicons/favicon.ico")
return send_file("static/logo/favicons/favicon.ico")
else:
return functions.throwError("Invalid logo size argument given.")

@flaskApp.route("/favicon.ico")
def returnFavicon():
return send_file("./static/logo/favicons/favicon.ico")
return send_file("static/logo/favicons/favicon.ico")

@flaskApp.route("/wait.js")
def returnWait():
return send_file("./static/wait.js")
return send_file("static/wait.js")

@flaskApp.route('/aboutPage')
def render_aboutPage():
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion generateVis.py → src/generateVis.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def draw_overlay(self):

##draw text background fade
if(self.textBackgroundFade == True):
fade = pil_image.open("static/fade.png").resize((self.resolution,self.resolution))
fade = pil_image.open("static/fade.png").resize((self.resolution, self.resolution))
self.image = pil_image.alpha_composite(self.image, fade)
##draw grid
if (self.gridOn==True):
Expand Down
2 changes: 1 addition & 1 deletion networks/strava.py → src/networks/strava.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, app):
self.tokenUrl = 'https://www.strava.com/oauth/token'.strip('\'')
self.clientId = os.getenv('STRAVA_CLIENT_ID').strip('\'')
self.clientSecret = os.getenv('STRAVA_CLIENT_SECRET').strip('\'')
self.authUrl = "www.strava.com/oauth/authorize?client_id={client_id}&response_type=code&redirect_uri={app_address}/strava-login&approval_prompt=auto&scope=read,activity:read".format(client_id=os.getenv('STRAVA_CLIENT_ID'), app_address=os.getenv('APP_ADDRESS') or 'http://127.0.0.1:5000').strip('\'')
self.authUrl = "www.strava.com/oauth/authorize?client_id={client_id}&response_type=code&redirect_uri={app_address}/strava-login&approval_prompt=auto&scope=read,activity:read".format(client_id=os.getenv('STRAVA_CLIENT_ID'), app_address=os.getenv('APP_ADDRESS') or 'http://localhost').strip('\'')
self.verifyToken = str(binascii.hexlify(os.urandom(24)))[2:-1]
self.loginWith = True

Expand Down
File renamed without changes.
Binary file renamed requirements.txt → src/requirements.txt
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Docker build -f ./Dockerfile-local . -t gpxvis:latest
Docker run -d -p 80:5000 --name gpxivs gpxvis:latest
4 changes: 4 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

Docker build -f ./Dockerfile-local . -t gpxvis:latest
Docker run -d -p 80:5000 --name gpxivs gpxvis:latest

0 comments on commit 4869dc9

Please sign in to comment.