From 0ce51938a0d338f7bf9cb3f2aa4a8e72796ad9d0 Mon Sep 17 00:00:00 2001 From: spelhate Date: Tue, 26 May 2020 14:31:49 +0200 Subject: [PATCH] Add docker composition for backend --- docker-compose.yml | 28 ++++++++++++++++++++++++++++ docker/Dockerfile-backend | 23 +++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile-backend diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ba9e273 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3' +volumes: + reports: + +services: + + # Select between the next 2 services the backend you want to use by + # commenting / uncommenting the 'volume' section & modify the links alias + # on the mviewer-studio service. + # + # You cannot use both backends at the same time, and you have to be wary if + # you switch from one to another, as each comes with a custom config.json + # file. + # + # If you want to switch, make sure either you modify the config.json, or + # reinitialize the docker volume. + + + # Python version + mreport-backend: + build: + context: . + dockerfile: docker/Dockerfile-backend + image: mreport/mreport:python-latest + volumes: + - "reports:/home/apprunner/backend/reports" + + \ No newline at end of file diff --git a/docker/Dockerfile-backend b/docker/Dockerfile-backend new file mode 100644 index 0000000..58f68e7 --- /dev/null +++ b/docker/Dockerfile-backend @@ -0,0 +1,23 @@ +FROM python:3.7-slim + +RUN useradd -r -m apprunner + +USER apprunner + +ENV HOME=/home/apprunner +ENV PATH=$HOME/.local/bin:$PATH + +WORKDIR /home/apprunner + +COPY requirements.txt . +COPY config.py . +RUN pip install --user -r requirements.txt + +COPY --chown=apprunner:apprunner backend backend +RUN pip install --user backend && pip install --user gunicorn + + +VOLUME [ "/home/apprunner/backend/reports" ] + + +CMD ["gunicorn", "-w 4", "-b 0.0.0.0:8000", "backend:app"]