Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

First pass at reading en vars for customization As well as fixing a few typos

Aaron Kimbrelldd9e9a29bf07
diff --git a/extras/docker/development/settings.py b/extras/docker/development/settings.py
index bb6a5ee17..4abdf69fb 100644
--- a/extras/docker/development/settings.py
+++ b/extras/docker/development/settings.py
@@ -22,7 +22,7 @@ if os.environ.get("DJANGO_DB_ENGINE"):
'USER': os.environ.get("DJANGO_DB_USER"),
'PASSWORD': os.environ.get("DJANGO_DB_PASSWORD"),
'HOST': os.environ.get("DJANGO_DB_HOST"),
- 'PORT': os.environ.get("DJANGO_DB_PART"),
+ 'PORT': os.environ.get("DJANGO_DB_PORT"),
}
}
else:
diff --git a/extras/docker/unraid/Dockerfile b/extras/docker/unraid/Dockerfile
new file mode 100644
index 000000000..515c1dc76
--- /dev/null
+++ b/extras/docker/unraid/Dockerfile
@@ -0,0 +1,59 @@
+#
+# Docker image for wger development
+#
+# Please consult the README for usage
+#
+# Note: you MUST build this image from the projec's root!
+# docker build -f extras/docker/development/Dockerfile --tag wger/devel .
+#
+# Run the container:
+# docker run -ti -v /path/to/this/checkout:/home/wger/src --name wger.devel --publish 8000:8000 wger/devel
+
+##########
+# Builder
+##########
+FROM ubuntu:20.04 as builder
+
+RUN apt-get update \
+ && apt-get install --no-install-recommends -y \
+ build-essential \
+ python3-dev \
+ python3-pip \
+ python3-wheel \
+ git \
+ && rm -rf /var/lib/apt/lists/*
+
+# Build the necessary python wheels
+COPY requirements* ./
+RUN pip3 wheel --no-cache-dir --wheel-dir /wheels -r requirements_prod.txt
+
+
+
+########
+# Final
+########
+FROM wger/base:2.0-dev
+LABEL maintainer="Roland Geider <[email protected]>"
+ARG DOCKER_DIR=./extras/docker/prod
+EXPOSE 8000
+
+
+# Set up the application
+WORKDIR /home/wger/src
+COPY --chown=wger:wger . /home/wger/src
+COPY --from=builder /wheels /wheels
+COPY ${DOCKER_DIR}/settings.py /home/wger/src
+COPY ${DOCKER_DIR}/settings.py /tmp/
+COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh
+RUN chmod +x /home/wger/entrypoint.sh
+RUN pip3 install --no-cache /wheels/* \
+ && python3 setup.py prod
+
+RUN chown -R wger:wger .
+
+USER wger
+RUN mkdir ~/media \
+ && mkdir ~/static \
+ && mkdir ~/db/
+
+CMD ["/home/wger/entrypoint.sh"]
diff --git a/extras/docker/unraid/entrypoint.sh b/extras/docker/unraid/entrypoint.sh
new file mode 100644
index 000000000..58a9202ee
--- /dev/null
+++ b/extras/docker/unraid/entrypoint.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Copy a settings file if nothing's found (e.g. when mounting a fresh checkout)
+if [ ! -f /home/wger/src/settings.py ]; then
+ cp /tmp/settings.py /home/wger/src
+fi
+
+# If using docker compose, wait for postgres
+if [[ "$DJANGO_DB_PORT" == "5432" ]]; then
+ echo "Waiting for postgres..."
+
+ while ! nc -z $DJANGO_DB_HOST $DJANGO_DB_PORT; do
+ sleep 0.1
+ done
+
+ echo "PostgreSQL started :)"
+fi
+
+# Bootstrap the application
+wger bootstrap
+
+if [[ "$WGER_DOWNLOAD_IMGS" == "TRUE" ]];
+then
+ wger download-exercise-images
+ chmod -R g+w ~wger/media
+fi
+
+# Run the server
+if [ -z "$WGER_USE_GUNICORN" ]
+then
+ python3 manage.py runserver 0.0.0.0:8000
+else
+ gunicorn wger.wsgi:application --reload --bind 0.0.0.0:8000
+fi
+
+
diff --git a/extras/docker/unraid/settings.py b/extras/docker/unraid/settings.py
new file mode 100644
index 000000000..58c4b51f5
--- /dev/null
+++ b/extras/docker/unraid/settings.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# wger
+from wger.settings_global import *
+
+
+# Use 'DEBUG = True' to get more details for server errors
+DEBUG = os.environ.get("DJANGO_DEBUG", True)
+TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
+
+ADMINS = (
+ ('Your name', '[email protected]'),
+)
+MANAGERS = ADMINS
+
+if os.environ.get("DJANGO_DB_ENGINE"):
+ DATABASES = {
+ 'default': {
+ 'ENGINE': os.environ.get("DJANGO_DB_ENGINE"),
+ 'NAME': os.environ.get("DJANGO_DB_DATABASE"),
+ 'USER': os.environ.get("DJANGO_DB_USER"),
+ 'PASSWORD': os.environ.get("DJANGO_DB_PASSWORD"),
+ 'HOST': os.environ.get("DJANGO_DB_HOST"),
+ 'PORT': os.environ.get("DJANGO_DB_PORT"),
+ }
+ }
+else:
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': '/home/wger/db/database.sqlite',
+ }
+ }
+
+# Timezone for this installation. Consult settings_global.py for more information
+TIME_ZONE = os.environ.get("TIME_ZONE")
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = os.environ.get("SECRET_KEY")
+
+
+# Your reCaptcha keys
+RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY')
+RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY')
+NOCAPTCHA = os.environ.get('NOCAPTCHA')
+
+# The site's URL (e.g. http://www.my-local-gym.com or http://localhost:8000)
+# This is needed for uploaded files and images (exercise images, etc.) to be
+# properly served.
+SITE_URL = os.environ.get('SITE_URL')
+
+# Path to uploaded files
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+MEDIA_ROOT = os.environ.get("DJANGO_MEDIA_ROOT", '/home/wger/media')
+MEDIA_URL = '/media/'
+
+STATIC_ROOT = os.environ.get("DJANGO_STATIC_ROOT", '/home/wger/static')
+
+# Allow all hosts to access the application. Change if used in production.
+ALLOWED_HOSTS = '*'
+
+SESSION_ENGINE = "django.contrib.sessions.backends.cache"
+
+# Configure a real backend in production
+if DEBUG:
+ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+else:
+ # add email vars from env
+ pass
+
+# Sender address used for sent emails
+WGER_SETTINGS['EMAIL_FROM'] = f'wger Workout Manager <{os.environ.get("FROM_EMAIL")}>'
+
+# Management
+if os.environ.get("ALLOW_REGISTRATION"):
+ WGER_SETTINGS["ALLOW_REGISTRATION"] = os.environ.get("ALLOW_REGISTRATION")
+if os.environ.get("ALLOW_GUEST_USERS"):
+ WGER_SETTINGS["ALLOW_GUEST_USERS"] = os.environ.get("ALLOW_GUEST_USERS")
+
+# Cache
+if os.environ.get("DJANGO_CACHE_BACKEND"):
+ CACHES = {
+ 'default': {
+ 'BACKEND': os.environ.get("DJANGO_CACHE_BACKEND"),
+ 'LOCATION': os.environ.get("DJANGO_CACHE_LOCATION"),
+ 'TIMEOUT': os.environ.get("DJANGO_CACHE_TIMEOUT"),
+ 'OPTIONS': {
+ 'CLIENT_CLASS': os.environ.get("DJANGO_CACHE_CLIENT_CLASS"),
+ }
+ }
+ }
diff --git a/setup.py b/setup.py
index c74c11fce..e4eaff647 100644
--- a/setup.py
+++ b/setup.py
@@ -49,7 +49,7 @@ setup(
'Programming Language :: Python :: 3.8',
],
- nstall_requires=install_requires,
+ install_requires=install_requires,
entry_points={
'console_scripts': [
'wger = wger.__main__:main',