Some improvement to development Dockerfile

Don't use a virtualenv insise the Dockerfile, not actually needed
This commit is contained in:
Roland Geider
2020-07-16 20:42:05 +02:00
parent 6d5e56e1d3
commit db954634af
10 changed files with 126 additions and 171 deletions

View File

@@ -48,7 +48,7 @@ jobs:
- name: Lint Code Base
uses: docker://github/super-linter:v2.2.2
env:
# Note: pythong was removed from validation because there seemed to
# Note: python was removed from validation because there seemed to
# be a problem with custom pylintrc files. If this bug is solved,
# python linting can be activated again (obviously!)
VALIDATE_PYTHON: false

View File

@@ -1,4 +1,4 @@
docker run -ti -v /path/to/this/checkout:/home/wger/src --name wger.devel --publish 8000:8000 wger/develThank you for downloading wger Workout Manager. wger (ˈɡɐ) is a free, open source web
Thank you for downloading wger Workout Manager. wger (ˈɡɐ) 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
@@ -25,8 +25,8 @@ parameters.
Docker
------
Useful to just try it out. Check the documentatio on how to use docker for
development::
Useful to just try it out. Check the documentation on how to use the wger/devel
docker image for development::
docker run -ti --name wger.apache --publish 8000:80 wger/apache

View File

@@ -25,19 +25,19 @@ RUN apt-get update \
build-essential \
python3-dev \
python3-pip \
python3-wheel \
git \
&& rm -rf /var/lib/apt/lists/*
# Set up the application
COPY . .
RUN pip3 install wheel \
&& pip3 wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements_devel.txt
RUN pip3 wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements_devel.txt
########
# Final
########
FROM wger/base:1.9
FROM wger/base:2.0-dev
LABEL maintainer="Roland Geider <roland@geider.net>"
ARG DOCKER_DIR=./extras/docker/apache
@@ -77,14 +77,15 @@ RUN chmod 0644 /etc/cron.d/wger \
&& chmod +x /home/wger/venvwrapper /home/wger/entrypoint.sh \
&& touch /var/log/cron.log
COPY --chown=wger:www-data . /home/wger/src
COPY --from=builder /usr/src/app/wheels /wheels
#COPY --chown=wger:www-data . /home/wger/src
# Set up the application
RUN ln -s /home/wger/static/CACHE /var/www
USER wger
WORKDIR /home/wger/src
RUN git clone https://github.com/wger-project/wger.git
RUN python3 -m venv /home/wger/venv
RUN . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \

View File

@@ -21,6 +21,7 @@ RUN apt-get update \
nodejs \
npm \
python3-venv \
python3-pip \
vim \
tmux \
sqlite3 \

View File

@@ -3,7 +3,7 @@ Development image for wger - Base image
This is the base image for some of the other wger images and offers no
functionality, it's only use is to provide some common dependencies.
If you want to develop, try either ``wger/devel`` oder ``wger/devel-fedora``.
If you want to develop, try ``wger/devel``.
Contact

View File

@@ -1,66 +0,0 @@
#
# Docker image for wger development on a fedora base image
#
# Please consult the documentation for usage
# docker build -t wger/devel-fedora .
# docker run -ti --name wger.devel-fedora --publish 8000:8000 wger/devel-fedora
# (in docker) source ~/venv/bin/activate
# (in docker) python manage.py runserver 0.0.0.0:8000
#
#
FROM fedora:25
LABEL maintainer="Roland Geider <roland@geider.net>"
# Install dependencies
RUN dnf update;\
dnf install -y python3-devel python-virtualenv \
nodejs npm libjpeg-turbo-devel zlib-devel git \
tmux redhat-rpm-config gcc python-imaging
# Set locale to UTF8, otherwise problems with the encoding can occur, e.g.
# when using the invoke/wger commands and bower
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Add wger user
RUN adduser wger
RUN echo "wger ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/wger
EXPOSE 8000
# Set up the application
USER wger
RUN git clone https://github.com/wger-project/wger.git /home/wger/src
WORKDIR /home/wger/src
RUN virtualenv --python python3 /home/wger/venv
RUN . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install -r requirements_devel.txt \
&& python setup.py develop \
&& wger create_settings \
--settings-path /home/wger/src/settings.py \
--database-path /home/wger/db/database.sqlite \
&& wger bootstrap \
--settings-path /home/wger/src/settings.py \
--no-start-server
# Install node modules for JS linting and download the exercise images
#
# Note: it seems there are problems with node and docker, so it's necessary
# to delete the node_modules folder and install everything again
# -> https://github.com/npm/npm/issues/9863
# -> https://github.com/npm/npm/issues/13306
RUN cd wger \
&& rm -r node_modules \
&& npm install bower \
&& npm install \
&& cd .. \
&& mkdir ~/media \
&& sed -i "/^MEDIA_ROOT/c\MEDIA_ROOT='\/home\/wger\/media'" settings.py \
&& . /home/wger/venv/bin/activate \
&& python manage.py download-exercise-images
CMD ["/bin/bash"]

View File

@@ -1,64 +0,0 @@
Development image for wger - Fedora based
=========================================
Thank you for downloading wger Workout Manager. wger (ˈɡɐ) 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
------------
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 (vim and tmux are already installed):
```docker run -ti --name wger.devel-fedora --publish 8000:8000 wger/devel-fedora```
Then, *within the docker image*, activate the virtualenv
```source ~/venv/bin/activate```
and start the development server
```python manage.py runserver 0.0.0.0:8000```
Then just open <http://localhost:8000> and log in as: **admin**, password **admin**
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
report liberally. If you're not sure if something is a bug or not, feel free to
file a bug anyway.
* gitter: <https://gitter.im/wger-project/wger>
* twitter: <https://twitter.com/wger_de>
* mailing list: <https://groups.google.com/group/wger> / wger@googlegroups.com, no registration needed
* issue tracker: <https://github.com/wger-project/wger/issues>
Sources
-------
All the code and the content is freely available:
* Main repository: <https://github.com/wger-project/wger>
Licence
-------
The application is licenced under the Affero GNU General Public License 3 or
later (AGPL 3+).
The initial exercise and ingredient data is licensed additionally under one of
the Creative Commons licenses, see the individual exercises for more details.
The documentation is released under a CC-BY-SA either version 4 of the License,
or (at your option) any later version.
Some images where taken from Wikipedia, see the SOURCES file in their respective
folders for more details.

View File

@@ -0,0 +1,90 @@
#
# Docker image for wger development:
#
# This image uses a virtual environment, which is not necessary in a docker
# image and is more or less intented to check that the installation instructions
# for a local develoment are up-to-date
#
# Please consult the documentation 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 --publish 8000:8000 --name wger.devel wger/devel
# (in docker) source ~/venv/bin/activate
# (in docker) python manage.py download-exercise-images (optional, may take some time)
# (in docker) python manage.py runserver 0.0.0.0:8000
#
# Alternatively, you can bind the local checkout into the container:
# docker run -ti -v /path/to/this/checkout:/home/wger/src --name wger.devel --publish 8000:8000 wger/devel
#
#
# To stop the container:
# sudo docker container stop wger.devel
#
# To start developing again
# sudo docker container start --attach 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 \
git \
&& rm -rf /var/lib/apt/lists/*
# Set up the application
COPY . .
RUN pip3 install wheel \
&& pip3 wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements_devel.txt
########
# Final
########
FROM wger/base:2.0-dev
LABEL maintainer="Roland Geider <roland@geider.net>"
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
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Set up the application
USER wger
COPY --chown=wger:wger . /home/wger/src
COPY --from=builder /usr/src/app/wheels /wheels
#RUN git clone https://github.com/wger-project/wger.git /home/wger/src
WORKDIR /home/wger/src
RUN python3 -m venv /home/wger/venv
RUN . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install --no-cache /wheels/* \
&& python setup.py develop \
&& npm install \
&& npm install bower \
&& wger create_settings \
--settings-path /home/wger/src/settings.py \
--database-path /home/wger/db/database.sqlite \
&& wger bootstrap \
--settings-path /home/wger/src/settings.py \
--no-start-server
# Download the exercise images
RUN mkdir ~/media \
&& sed -i "/^MEDIA_ROOT/c\MEDIA_ROOT='\/home\/wger\/media'" settings.py
CMD ["/bin/bash"]

View File

@@ -7,14 +7,10 @@
# docker build -f extras/docker/development/Dockerfile --tag wger/devel .
#
# Run the container:
# docker run -ti --publish 8000:8000 --name wger.devel wger/devel
# (in docker) source ~/venv/bin/activate
# (in docker) python manage.py download-exercise-images (optional, may take some time)
# (in docker) python manage.py runserver 0.0.0.0:8000
#
# Alternatively, you can bind the local checkout into 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
@@ -33,21 +29,21 @@ RUN apt-get update \
build-essential \
python3-dev \
python3-pip \
python3-wheel \
git \
&& rm -rf /var/lib/apt/lists/*
# Set up the application
COPY . .
RUN pip3 install wheel \
&& pip3 wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements_devel.txt
# Build the necessary python wheels
COPY requirements* ./
RUN pip3 wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements_devel.txt
########
# Final
########
FROM wger/base:1.9
FROM wger/base:2.0-dev
LABEL maintainer="Roland Geider <roland@geider.net>"
ARG DOCKER_DIR=./extras/docker/development
EXPOSE 8000
# Set locale to UTF8, otherwise problems with the encoding can occur, e.g.
@@ -59,20 +55,17 @@ ENV LC_ALL en_US.UTF-8
# Set up the application
USER wger
COPY --chown=wger:wger . /home/wger/src
COPY --from=builder /usr/src/app/wheels /wheels
#RUN git clone https://github.com/wger-project/wger.git /home/wger/src
WORKDIR /home/wger/src
RUN python3 -m venv /home/wger/venv
RUN . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install --no-cache /wheels/* \
&& python setup.py develop \
RUN pip3 install --no-cache /wheels/* \
&& python3 setup.py develop \
&& npm install \
&& npm install bower \
&& wger create_settings \
&& npm install bower
USER wger
WORKDIR /home/wger/src
RUN wger create_settings \
--settings-path /home/wger/src/settings.py \
--database-path /home/wger/db/database.sqlite \
&& wger bootstrap \

View File

@@ -13,17 +13,21 @@ Installation
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 (vim and tmux are already installed):
development instance (vim and tmux are already installed)::
```docker run -ti --name wger.devel --publish 8000:8000 wger/devel```
docker run -ti \
-v /path/to/your/wger/checkout:/home/wger/src \
--name wger.devel \
--publish 8000:8000 wger/devel \
Then, within the docker image, activate the virtualenv
On the first run you might want to download the exercise images (might take
some time):
```source ~/venv/bin/activate```
```python3 manage.py download-exercise-images```
and start the development server
To start the development server
```python manage.py runserver 0.0.0.0:8000```
```python3 manage.py runserver 0.0.0.0:8000```
Then just open <http://localhost:8000> and log in as: **admin**, password **admin**
@@ -35,10 +39,6 @@ To start developing again:
```sudo docker container start --attach wger.devel```
You can also keep the code outside and just bind it into the container:
```docker run -ti -v /path/to/local/project/checkout:/home/wger/src --name wger.devel --publish 8000:8000 wger/devel```
Building
--------