Merge pull request #63 from SamR1/add-docker
Add docker for evaluation purposes
This commit is contained in:
commit
ca8b1b61e8
11
.dockerignore
Normal file
11
.dockerignore
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.idea
|
||||||
|
.git
|
||||||
|
.mypy_cache
|
||||||
|
.pytest_cache
|
||||||
|
.venv
|
||||||
|
.env
|
||||||
|
.coverage
|
||||||
|
.eslintcache
|
||||||
|
docker-compose-dev.yml
|
||||||
|
Makefile.custom.config
|
||||||
|
*.log
|
28
.env.docker
Normal file
28
.env.docker
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Custom variables initialisation
|
||||||
|
|
||||||
|
# Application
|
||||||
|
export FLASK_APP=fittrackee/__main__.py
|
||||||
|
# export HOST=
|
||||||
|
# export PORT=
|
||||||
|
export APP_SETTINGS=fittrackee.config.DevelopmentConfig
|
||||||
|
export APP_SECRET_KEY='just for test'
|
||||||
|
# export APP_WORKERS=
|
||||||
|
export APP_LOG=fittrackee.log
|
||||||
|
export UPLOAD_FOLDER=/usr/src/app/uploads
|
||||||
|
|
||||||
|
# Database
|
||||||
|
export DATABASE_URL=postgres://fittrackee:fittrackee@fittrackee-db:5432/fittrackee
|
||||||
|
export DATABASE_TEST_URL=postgres://fittrackee:fittrackee@fittrackee-db:5432/fittrackee_test
|
||||||
|
export DATABASE_DISABLE_POOLING=
|
||||||
|
|
||||||
|
# Emails
|
||||||
|
export UI_URL=http://0.0.0.0:5000
|
||||||
|
export EMAIL_URL=smtp://none:none@mail:1025
|
||||||
|
export SENDER_EMAIL=fittrackee@example.com
|
||||||
|
export REDIS_URL=redis://redis:6379
|
||||||
|
export WORKERS_PROCESSES=2
|
||||||
|
|
||||||
|
# Activities
|
||||||
|
#export TILE_SERVER_URL=
|
||||||
|
#export MAP_ATTRIBUTION=
|
||||||
|
#export WEATHER_API_KEY=
|
22
Dockerfile
Normal file
22
Dockerfile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
FROM python:3.9
|
||||||
|
|
||||||
|
MAINTAINER SamR1@users.noreply.github.com
|
||||||
|
|
||||||
|
# set working directory
|
||||||
|
RUN mkdir -p /usr/src/app
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# copy source files
|
||||||
|
COPY . /usr/src/app
|
||||||
|
|
||||||
|
# install requirements
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
RUN pip install poetry
|
||||||
|
RUN poetry config virtualenvs.create false
|
||||||
|
RUN poetry install --no-interaction --quiet
|
||||||
|
|
||||||
|
# create uploads folder
|
||||||
|
CMD mkdir /usr/src/app/uploads
|
||||||
|
|
||||||
|
# run fittrackee server
|
||||||
|
CMD flask run --with-threads -h 0.0.0.0
|
35
Makefile
35
Makefile
@ -21,6 +21,41 @@ clean-install: clean
|
|||||||
rm -rf *.egg-info
|
rm -rf *.egg-info
|
||||||
rm -rf dist/
|
rm -rf dist/
|
||||||
|
|
||||||
|
## Docker commands for evaluation purposes
|
||||||
|
docker-build:
|
||||||
|
docker-compose -f docker-compose-dev.yml build
|
||||||
|
|
||||||
|
docker-init: docker-init-db docker-restart docker-run-workers
|
||||||
|
|
||||||
|
docker-init-db:
|
||||||
|
docker-compose -f docker-compose-dev.yml exec fittrackee docker/init-database.sh
|
||||||
|
|
||||||
|
docker-logs:
|
||||||
|
docker-compose -f docker-compose-dev.yml logs --follow
|
||||||
|
|
||||||
|
docker-rebuild:
|
||||||
|
docker-compose -f docker-compose-dev.yml build --no-cache
|
||||||
|
|
||||||
|
docker-restart:
|
||||||
|
docker-compose -f docker-compose-dev.yml restart fittrackee
|
||||||
|
|
||||||
|
docker-run-all: docker-run docker-run-workers
|
||||||
|
|
||||||
|
docker-run:
|
||||||
|
docker-compose -f docker-compose-dev.yml up -d
|
||||||
|
|
||||||
|
docker-run-workers:
|
||||||
|
docker-compose -f docker-compose-dev.yml exec -d fittrackee docker/run-workers.sh
|
||||||
|
|
||||||
|
docker-shell:
|
||||||
|
docker-compose -f docker-compose-dev.yml exec fittrackee docker/shell.sh
|
||||||
|
|
||||||
|
docker-stop:
|
||||||
|
docker-compose -f docker-compose-dev.yml stop
|
||||||
|
|
||||||
|
docker-up:
|
||||||
|
docker-compose -f docker-compose-dev.yml up
|
||||||
|
|
||||||
downgrade-db:
|
downgrade-db:
|
||||||
$(FLASK) db downgrade --directory $(MIGRATIONS)
|
$(FLASK) db downgrade --directory $(MIGRATIONS)
|
||||||
|
|
||||||
|
5
db/Dockerfile
Normal file
5
db/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
FROM postgres:13
|
||||||
|
|
||||||
|
MAINTAINER SamR1@users.noreply.github.com
|
||||||
|
|
||||||
|
COPY create.sql /docker-entrypoint-initdb.d
|
43
docker-compose-dev.yml
Normal file
43
docker-compose-dev.yml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
fittrackee-db:
|
||||||
|
container_name: fittrackee-db
|
||||||
|
build: ./db
|
||||||
|
ports:
|
||||||
|
- 5435:5432
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
|
||||||
|
fittrackee:
|
||||||
|
container_name: fittrackee
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
env_file:
|
||||||
|
- .env.docker
|
||||||
|
depends_on:
|
||||||
|
- fittrackee-db
|
||||||
|
- redis
|
||||||
|
- mail
|
||||||
|
links:
|
||||||
|
- fittrackee-db
|
||||||
|
- redis
|
||||||
|
- mail
|
||||||
|
|
||||||
|
redis:
|
||||||
|
container_name: fittrackee-redis
|
||||||
|
image: "redis:latest"
|
||||||
|
hostname: redis
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
|
||||||
|
mail:
|
||||||
|
container_name: fittrackee-mailhog
|
||||||
|
image: "mailhog/mailhog"
|
||||||
|
ports:
|
||||||
|
- 1025:1025
|
||||||
|
- 8025:8025
|
||||||
|
|
9
docker/init-database.sh
Executable file
9
docker/init-database.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd /usr/src/app
|
||||||
|
|
||||||
|
source .env.docker
|
||||||
|
|
||||||
|
flask drop-db
|
||||||
|
flask db upgrade --directory fittrackee/migrations
|
||||||
|
flask init-data
|
7
docker/run-workers.sh
Executable file
7
docker/run-workers.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd /usr/src/app
|
||||||
|
|
||||||
|
source .env.docker
|
||||||
|
|
||||||
|
flask worker --processes=$WORKERS_PROCESSES >> dramatiq.log 2>&1
|
7
docker/shell.sh
Executable file
7
docker/shell.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd /usr/src/app
|
||||||
|
|
||||||
|
source .env.docker
|
||||||
|
|
||||||
|
/bin/bash
|
@ -26,7 +26,7 @@ Prerequisites
|
|||||||
- API key from `Dark Sky <https://darksky.net/dev>`__ [not mandatory]
|
- API key from `Dark Sky <https://darksky.net/dev>`__ [not mandatory]
|
||||||
- SMTP provider
|
- SMTP provider
|
||||||
- `Yarn <https://yarnpkg.com>`__ (for development only)
|
- `Yarn <https://yarnpkg.com>`__ (for development only)
|
||||||
- Docker (for development only, to start `MailHog <https://github.com/mailhog/MailHog>`__)
|
- Docker (for development only, to start `MailHog <https://github.com/mailhog/MailHog>`__ or evaluation purposes)
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
| The following steps describe an installation on Linux systems (tested
|
| The following steps describe an installation on Linux systems (tested
|
||||||
@ -636,3 +636,43 @@ Examples (to update depending on your application configuration and given distri
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
More information on `Gunicorn documentation <https://docs.gunicorn.org/en/stable/deploy.html>`__
|
More information on `Gunicorn documentation <https://docs.gunicorn.org/en/stable/deploy.html>`__
|
||||||
|
|
||||||
|
|
||||||
|
Docker
|
||||||
|
~~~~~~
|
||||||
|
|
||||||
|
.. versionadded:: 0.x.x
|
||||||
|
|
||||||
|
For evaluation purposes (at least for now), docker files are available,
|
||||||
|
installing **FitTrackee** from **sources**.
|
||||||
|
|
||||||
|
- To install **FitTrackee** with database initialisation and run the application and dramatiq workers:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ git clone https://github.com/SamR1/FitTrackee.git
|
||||||
|
$ cd FitTrackee
|
||||||
|
$ make docker-build docker-run docker-init
|
||||||
|
|
||||||
|
Open http://localhost:5000, log in as admin (the email is `admin@example.com` and the password `mpwoadmin`) or register.
|
||||||
|
|
||||||
|
Open http://localhost:8025 to access `MailHog interface <https://github.com/mailhog/MailHog>`_ (email testing tool)
|
||||||
|
|
||||||
|
- To stop **Fittrackee**:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ make docker-stop
|
||||||
|
|
||||||
|
- To start **Fittrackee** (application and dramatiq workers):
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ make docker-run-all
|
||||||
|
|
||||||
|
|
||||||
|
- To run shell inside **Fittrackee** container:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ make docker-shell
|
@ -159,6 +159,7 @@ Map</a>.</div>
|
|||||||
<li class="toctree-l2"><a class="reference internal" href="installation.html#from-pypi">From PyPI</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="installation.html#from-pypi">From PyPI</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="installation.html#from-sources">From sources</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="installation.html#from-sources">From sources</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="installation.html#deployment">Deployment</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="installation.html#deployment">Deployment</a></li>
|
||||||
|
<li class="toctree-l2"><a class="reference internal" href="installation.html#docker">Docker</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="features.html">Features</a><ul>
|
<li class="toctree-l1"><a class="reference internal" href="features.html">Features</a><ul>
|
||||||
|
@ -103,6 +103,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference internal" href="#deployment">Deployment</a></li>
|
<li><a class="reference internal" href="#deployment">Deployment</a></li>
|
||||||
|
<li><a class="reference internal" href="#docker">Docker</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -188,7 +189,7 @@
|
|||||||
<li><p>API key from <a class="reference external" href="https://darksky.net/dev">Dark Sky</a> [not mandatory]</p></li>
|
<li><p>API key from <a class="reference external" href="https://darksky.net/dev">Dark Sky</a> [not mandatory]</p></li>
|
||||||
<li><p>SMTP provider</p></li>
|
<li><p>SMTP provider</p></li>
|
||||||
<li><p><a class="reference external" href="https://yarnpkg.com">Yarn</a> (for development only)</p></li>
|
<li><p><a class="reference external" href="https://yarnpkg.com">Yarn</a> (for development only)</p></li>
|
||||||
<li><p>Docker (for development only, to start <a class="reference external" href="https://github.com/mailhog/MailHog">MailHog</a>)</p></li>
|
<li><p>Docker (for development only, to start <a class="reference external" href="https://github.com/mailhog/MailHog">MailHog</a> or evaluation purposes)</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="admonition note">
|
<div class="admonition note">
|
||||||
<p class="admonition-title">Note</p>
|
<p class="admonition-title">Note</p>
|
||||||
@ -899,6 +900,42 @@ server {
|
|||||||
<p>More information on <a class="reference external" href="https://docs.gunicorn.org/en/stable/deploy.html">Gunicorn documentation</a></p>
|
<p>More information on <a class="reference external" href="https://docs.gunicorn.org/en/stable/deploy.html">Gunicorn documentation</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="section" id="docker">
|
||||||
|
<h2>Docker<a class="headerlink" href="#docker" title="Permalink to this headline">¶</a></h2>
|
||||||
|
<div class="versionadded">
|
||||||
|
<p><span class="versionmodified added">New in version 0.x.x.</span></p>
|
||||||
|
</div>
|
||||||
|
<p>For evaluation purposes (at least for now), docker files are available,
|
||||||
|
installing <strong>FitTrackee</strong> from <strong>sources</strong>.</p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li><p>To install <strong>FitTrackee</strong> with database initialisation and run the application and dramatiq workers:</p></li>
|
||||||
|
</ul>
|
||||||
|
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ git clone https://github.com/SamR1/FitTrackee.git
|
||||||
|
$ <span class="nb">cd</span> FitTrackee
|
||||||
|
$ make docker-build docker-run docker-init
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
<p>Open <a class="reference external" href="http://localhost:5000">http://localhost:5000</a>, log in as admin (the email is <cite>admin@example.com</cite> and the password <cite>mpwoadmin</cite>) or register.</p>
|
||||||
|
<p>Open <a class="reference external" href="http://localhost:8025">http://localhost:8025</a> to access <a class="reference external" href="https://github.com/mailhog/MailHog">MailHog interface</a> (email testing tool)</p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li><p>To stop <strong>Fittrackee</strong>:</p></li>
|
||||||
|
</ul>
|
||||||
|
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ make docker-stop
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
<ul class="simple">
|
||||||
|
<li><p>To start <strong>Fittrackee</strong> (application and dramatiq workers):</p></li>
|
||||||
|
</ul>
|
||||||
|
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ make docker-run-all
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
<ul class="simple">
|
||||||
|
<li><p>To run shell inside <strong>Fittrackee</strong> container:</p></li>
|
||||||
|
</ul>
|
||||||
|
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ make docker-shell
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -26,7 +26,7 @@ Prerequisites
|
|||||||
- API key from `Dark Sky <https://darksky.net/dev>`__ [not mandatory]
|
- API key from `Dark Sky <https://darksky.net/dev>`__ [not mandatory]
|
||||||
- SMTP provider
|
- SMTP provider
|
||||||
- `Yarn <https://yarnpkg.com>`__ (for development only)
|
- `Yarn <https://yarnpkg.com>`__ (for development only)
|
||||||
- Docker (for development only, to start `MailHog <https://github.com/mailhog/MailHog>`__)
|
- Docker (for development only, to start `MailHog <https://github.com/mailhog/MailHog>`__ or evaluation purposes)
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
| The following steps describe an installation on Linux systems (tested
|
| The following steps describe an installation on Linux systems (tested
|
||||||
@ -636,3 +636,43 @@ Examples (to update depending on your application configuration and given distri
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
More information on `Gunicorn documentation <https://docs.gunicorn.org/en/stable/deploy.html>`__
|
More information on `Gunicorn documentation <https://docs.gunicorn.org/en/stable/deploy.html>`__
|
||||||
|
|
||||||
|
|
||||||
|
Docker
|
||||||
|
~~~~~~
|
||||||
|
|
||||||
|
.. versionadded:: 0.x.x
|
||||||
|
|
||||||
|
For evaluation purposes (at least for now), docker files are available,
|
||||||
|
installing **FitTrackee** from **sources**.
|
||||||
|
|
||||||
|
- To install **FitTrackee** with database initialisation and run the application and dramatiq workers:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ git clone https://github.com/SamR1/FitTrackee.git
|
||||||
|
$ cd FitTrackee
|
||||||
|
$ make docker-build docker-run docker-init
|
||||||
|
|
||||||
|
Open http://localhost:5000, log in as admin (the email is `admin@example.com` and the password `mpwoadmin`) or register.
|
||||||
|
|
||||||
|
Open http://localhost:8025 to access `MailHog interface <https://github.com/mailhog/MailHog>`_ (email testing tool)
|
||||||
|
|
||||||
|
- To stop **Fittrackee**:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ make docker-stop
|
||||||
|
|
||||||
|
- To start **Fittrackee** (application and dramatiq workers):
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ make docker-run-all
|
||||||
|
|
||||||
|
|
||||||
|
- To run shell inside **Fittrackee** container:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ make docker-shell
|
Loading…
Reference in New Issue
Block a user