Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

More tinkering with the dockerfile for development

Roland Geiderb815c2471691
diff --git a/extras/docker/development/Dockerfile b/extras/docker/development/Dockerfile
index ef449317b..a76129210 100644
--- a/extras/docker/development/Dockerfile
+++ b/extras/docker/development/Dockerfile
@@ -1,23 +1,14 @@
#
# Docker image for wger development
#
-# Please consult the documentation for usage
+# 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
-#
-# (in docker) python3 manage.py download-exercise-images (optional, may take some time)
-# (in docker) python3 manage.py runserver 0.0.0.0:8000
-#
-# To stop the container:
-# sudo docker container stop wger.devel
-#
-# To start developing again
-# sudo docker container start --attach wger.devel
-#
+
##########
# Builder
@@ -47,8 +38,7 @@ LABEL maintainer="Roland Geider <[email protected]>"
ARG DOCKER_DIR=./extras/docker/development
EXPOSE 8000
-# Set locale to UTF8, otherwise problems with the encoding can occur, e.g.
-# when using the invoke/wger commands and bower
+# Set locale to UTF8
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
@@ -63,18 +53,18 @@ 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/* \
&& pip3 install psycopg2-binary \
&& pip3 install python-memcached \
&& python3 setup.py develop \
- && npm install \
- && npm install bower
-
+ && npm install
RUN chown -R wger:wger .
+
USER wger
-RUN mkdir ~/media
-RUN mkdir ~/db/
+RUN mkdir ~/media \
+ && mkdir ~/db/
CMD ["/home/wger/entrypoint.sh"]
diff --git a/extras/docker/development/README.md b/extras/docker/development/README.md
index 712596a61..c94a7af19 100644
--- a/extras/docker/development/README.md
+++ b/extras/docker/development/README.md
@@ -1,35 +1,46 @@
-Development image for wger - Ubuntu based
-=========================================
+# Development image for wger - Ubuntu based
+
Thank you for downloading wger Workout Manager. wger (ˈvɛɡɐ) is a free, open
source web application that manages your exercises and personal workouts, weight
and diet plans. It can also be used as a simple gym management utility, providing
different administrative roles (trainer, manager, etc.). It offers a REST API
as well, for easy integration with other projects and tools.
-It is written with python/django and uses jQuery and some D3js for charts.
-Installation
-------------
+## Usage
+
+This docker image is meant to provide a quick development environment using
+django's development server and an sqlite database from your current code
+checkout (if you don't want or need a local checkout, use the wger/apache image,
+it is self-contained)
+
+### 1 - Start the container
-This docker image contains an instance of the application running with django's
-development server using a sqlite database. It can be used to quickly setup a
-development instance::
docker run -ti \
-v /path/to/your/wger/checkout:/home/wger/src \
--name wger.devel \
- --publish 8000:8000 wger/devel \
+ --publish 8000:8000 wger/devel
+
+When developing with windows, you might have problems with the `--volume` option,
+use the more verbose mount instead:
+
+ --mount type=bind,source='"C:\your\path\to your\checkout"',target=/home/wger/src
-On the first run you might want to download the exercise images (might take
-some time):
+### 2 - Download additional files
-```python3 manage.py download-exercise-images```
+On the first run, you need to download some CSS and JS files with bower (
+as well as everytime there are updates):
-To start the development server
+ docker exec -ti wger.devel python3 manage.py bower install
-```python3 manage.py runserver 0.0.0.0:8000```
+You might also want to download the exercise images (will take some time):
-Then just open <http://localhost:8000> and log in as: **admin**, password **admin**
+ docker exec -ti wger.devel python3 manage.py download-exercise-images
+
+### 3 - Open the Application
+
+Just open <http://localhost:8000> and log in as: **admin**, password **admin**
To stop the container:
@@ -39,16 +50,16 @@ To start developing again:
```sudo docker container start --attach wger.devel```
-Building
---------
+
+## Building
If you build this yourself, keep in mind that you **must** build from the
project root!
```docker build -f extras/docker/development/Dockerfile --tag wger/devel .```
-Contact
--------
+
+## Contact
Feel free to contact us if you found this useful or if there was something that
didn't behave as you expected. We can't fix what we don't know about, so please
@@ -60,15 +71,13 @@ file a bug anyway.
* twitter: <https://twitter.com/wger_de>
* mailing list: <https://groups.google.com/group/wger> / [email protected], no registration needed
-Sources
--------
+## Sources
All the code and the content is freely available:
* Main repository: <https://github.com/wger-project/wger>
-Licence
--------
+## Licence
The application is licenced under the Affero GNU General Public License 3 or
later (AGPL 3+).
diff --git a/extras/docker/development/entrypoint.sh b/extras/docker/development/entrypoint.sh
index 92532ebc7..3be8c8bb8 100644
--- a/extras/docker/development/entrypoint.sh
+++ b/extras/docker/development/entrypoint.sh
@@ -1,7 +1,11 @@
#!/bin/bash
-cd /home/wger/src
+# Copy a settings file if not fould
+if [ test ! -f /home/wger/src ]
+ 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..."
@@ -12,12 +16,10 @@ if [[ "$DJANGO_DB_PORT" == "5432" ]]; then
echo "PostgreSQL started :)"
fi
-if [[ "$WGER_BOOTSTRAP" == "TRUE" ]];
-then
- wger bootstrap \
- --settings-path /home/wger/src/settings.py \
- --no-start-server
-fi
+# Bootstrap the application
+wger bootstrap \
+ --settings-path /home/wger/src/settings.py \
+ --no-start-server
if [[ "$WGER_DOWNLOAD_IMGS" == "TRUE" ]];
then
@@ -25,5 +27,5 @@ then
chmod -R g+w ~wger/media
fi
-#exec "$@"
+# Run the development server
python3 manage.py runserver 0.0.0.0:8000
diff --git a/extras/docker/docker-compose/dev.env b/extras/docker/docker-compose/dev.env
index 8b1292a9b..be833a91f 100644
--- a/extras/docker/docker-compose/dev.env
+++ b/extras/docker/docker-compose/dev.env
@@ -14,5 +14,3 @@ DJANGO_CACHE_PORT=11211
DJANGO_CACHE_TIMEOUT=100
DJANGO_MEDIA_ROOT=/home/wger/media
-
-WGER_BOOTSTRAP=TRUE
diff --git a/extras/docker/docker-compose/docker-compose.yml b/extras/docker/docker-compose/docker-compose.yml
index 744bdb56f..2f9586ebb 100644
--- a/extras/docker/docker-compose/docker-compose.yml
+++ b/extras/docker/docker-compose/docker-compose.yml
@@ -22,7 +22,7 @@ services:
image: postgres:12.0-alpine
volumes:
- type: bind
- source: ./wger-postgres-data
+ source: /tmp/wger-postgres-data
target: /var/lib/postgresql/data/
environment:
- POSTGRES_USER=wger
diff --git a/extras/docker/docker-compose/env b/extras/docker/docker-compose/env
deleted file mode 100644
index c00f63fc0..000000000
--- a/extras/docker/docker-compose/env
+++ /dev/null
@@ -1,5 +0,0 @@
-DB_NAME=myproject_web
-DB_USER=myproject_web
-DB_PASS=shoov3Phezaimahsh7eb2Tii4ohkah8k
-DB_SERVICE=postgres
-DB_PORT=5432
diff --git a/wger/tasks.py b/wger/tasks.py
index d38bcff3e..4f63b4f4a 100644
--- a/wger/tasks.py
+++ b/wger/tasks.py
@@ -119,8 +119,7 @@ def bootstrap(context,
create_or_reset_admin(context, settings_path=settings_path)
# Download JS libraries with bower
- context.run('npm install bower')
- context.run('npm install')
+ call_command("bower", "install")
# Start the webserver
if start_server: