From 3add8842d27a4ddff053c2237dc1efb7e1f055d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sun, 9 Feb 2020 04:39:18 +0100 Subject: [PATCH] Rework Dockerfile to be production ready --- .dockerignore | 6 ++++++ Dockerfile | 26 +++++++++++++++++--------- wsgi.py | 9 +++++++++ 3 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 .dockerignore create mode 100755 wsgi.py diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b1efacc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.idea/ + +dashmachine/user_data/ +dashmachine/static/images/icons +dashmachine/static/images/backgrounds diff --git a/Dockerfile b/Dockerfile index 012367b..e706048 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,19 @@ -FROM python:3.8.0-slim -RUN rm /bin/sh && ln -s /bin/bash /bin/sh -RUN apt-get update \ -&& apt-get install gcc git iputils-ping -y \ -&& apt-get clean +FROM python:3.8-slim -COPY ./ DashMachine -WORKDIR DashMachine -RUN pip install -r requirements.txt +RUN apt-get update -q \ + && apt-get install --no-install-recommends -qy \ + inetutils-ping \ + && rm -rf /var/lib/apt/lists/* + +COPY [ "requirements.txt", "/dashmachine/" ] + +WORKDIR /dashmachine + +RUN pip install --no-cache-dir --progress-bar off -r requirements.txt + +COPY [ ".", "/dashmachine/" ] + +ENV PRODUCTION=true EXPOSE 5000 -CMD ["python", "run.py"] \ No newline at end of file +VOLUME /dashmachine/dashmachine/user_data +CMD [ "gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app" ] diff --git a/wsgi.py b/wsgi.py new file mode 100755 index 0000000..b07021d --- /dev/null +++ b/wsgi.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +from dashmachine import app +from dashmachine.main.utils import dashmachine_init + +dashmachine_init() + +if __name__ == "__main__": + app.run()