diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5b56e67 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +bin +cache +CHANGELOG.md +DEV.md +docker-compose.yml +Dockerfile +.dockerignore +.git +.gitignore +.gitlab-ci.yml +heliopropa.wsgi +.idea +LICENSE +__pycache__ +pytest.ini +README.md +requirements-dev.txt +requirements-stable.txt +requirements-tests.txt +resources +resources-tests +SPACEWEATHERONLINE.md +spec +tests +TODO.md +venv +VISITS diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7789b19 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.9-slim-bullseye + +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +# Install dependencies: +COPY requirements.txt . + +RUN pip install --upgrade pip &&\ + pip install wheel &&\ + pip install -r requirements.txt + +# Build the whole stuff +COPY . . + +# Allow running outside compose +CMD flask --app heliopropa:application run --host=0.0.0.0 \ No newline at end of file diff --git a/README.md b/README.md index bdd9324..fbd9adb 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ It also gathers NetCDF data from AMDA, and serves it as CSV to the plotter. - `web/view/home.html.jinja2` : the HTML template. - `web/static/js/swapp.ls` : most of the javascript client-side. +## Quick Start + + docker compose build + docker compose up ### Python venv diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5e24aae --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.3' + +services: + web: + build: + context: . + dockerfile: Dockerfile + command: gunicorn --bind 0.0.0.0:5000 heliopropa:application + volumes: + - helio_cache:/cache:rw + expose: + - 5000 + nginx: + image: nginx + volumes: + - ./resources/heliopropa.nginx.docker:/etc/nginx/conf.d/default.conf + ports: + - "8080:80" + depends_on: + - web + +volumes: + helio_cache: diff --git a/heliopropa.py b/heliopropa.py new file mode 100644 index 0000000..b88b6c8 --- /dev/null +++ b/heliopropa.py @@ -0,0 +1,3 @@ +# simply use application already set in main app file +# +from web.run import app as application diff --git a/resources/heliopropa.nginx.docker b/resources/heliopropa.nginx.docker new file mode 100644 index 0000000..39e0852 --- /dev/null +++ b/resources/heliopropa.nginx.docker @@ -0,0 +1,19 @@ +upstream heliopropa { + server web:5000; +} + +server { + + listen 80; + + location / { + proxy_pass http://heliopropa; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_redirect off; + proxy_read_timeout 600; + proxy_connect_timeout 600; + proxy_send_timeout 600; + } + +} diff --git a/resources/web_nginx.docker.conf b/resources/web_nginx.docker.conf new file mode 100644 index 0000000..0f30eb5 --- /dev/null +++ b/resources/web_nginx.docker.conf @@ -0,0 +1,19 @@ +upstream hello_flask { + server web:5000; +} + +server { + + listen 80; + + location / { + proxy_pass http://hello_flask; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_redirect off; + proxy_read_timeout 600; + proxy_connect_timeout 600; + proxy_send_timeout 600; + } + +} -- libgit2 0.21.2