From 48443d9855f1e6bc35039971f2115282f72a2b81 Mon Sep 17 00:00:00 2001 From: Shaquille Soekhlal Date: Mon, 15 Feb 2021 11:13:30 +0100 Subject: [PATCH] initial commit --- .../CalibreWebCompanion/uwsgi.ini | 20 ++++++++++ deployment/Dockerfile | 4 +- deployment/docker/Dockerfile | 37 +++++++++++++++++++ deployment/docker/nginx.conf | 20 ++++++++++ deployment/docker/start.sh | 0 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 CalibreWebCompanion/CalibreWebCompanion/uwsgi.ini create mode 100644 deployment/docker/Dockerfile create mode 100644 deployment/docker/nginx.conf create mode 100644 deployment/docker/start.sh diff --git a/CalibreWebCompanion/CalibreWebCompanion/uwsgi.ini b/CalibreWebCompanion/CalibreWebCompanion/uwsgi.ini new file mode 100644 index 0000000..fe22f92 --- /dev/null +++ b/CalibreWebCompanion/CalibreWebCompanion/uwsgi.ini @@ -0,0 +1,20 @@ +[uwsgi] +base = /cwebcomp +chdir = %(base) +home = %(base) +pidfile= %(base)/cwebcomp.pid +pythonpath= /usr/local +uid = www-data +gid = www-data +module = wsgi:application # path to wsgy.py file +socket = :8000 +processes = 8 +threads = 4 +master = true +chmod-socket = 660 +vacuum = true +die-on-term = true +harakiri = 20 +max-requests = 5000 +logs = %(base)/uwsgi_info.logs +daemonize = %(base)/uwsgi.logs \ No newline at end of file diff --git a/deployment/Dockerfile b/deployment/Dockerfile index a0458d4..2ff4084 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -1,6 +1,6 @@ ## pull official base image -FROM python:3.8.3-alpine +FROM python:slim-buster EXPOSE 8080 ## set work directory WORKDIR /usr/src/app @@ -17,7 +17,7 @@ COPY ./deployment/nginx.conf /etc/nginx/ ## copy project COPY ./CalibreWebCompanion ./CalibreWebCompanion -copy ./deployment/startupscript.py ./ +COPY ./deployment/startupscript.py ./ ## gunicorn borks started with supervisord COPY ./deployment/supervisord.conf /etc/ ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf diff --git a/deployment/docker/Dockerfile b/deployment/docker/Dockerfile new file mode 100644 index 0000000..f3d9534 --- /dev/null +++ b/deployment/docker/Dockerfile @@ -0,0 +1,37 @@ +FROM python:3.9.1-slim-buster + +RUN apt-get clean && \ + apt-get update && \ + apt-get install -y nginx smbclient default-libmysqlclient-dev \ + gcc python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 \ + libgdk-pixbuf2.0-0 libffi-dev shared-mime-info + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +RUN mkdir /cwebcomp +WORKDIR /cwebcomp +ADD . /cwebcomp/ +# only add this next one if yoi have static files +RUN mkdir static + +RUN pip install -r requirements/requirements.txt +RUN python manage.py collectstatic + +# only if you need celery +RUN useradd -ms /bin/bash celery +COPY broker/init.d_celeryd /etc/init.d/celeryd +COPY broker/celeryd /etc/default/celeryd + +# nginx config and script to be run +COPY docker/nginx.conf /etc/nginx/sites-available/default +COPY docker/start.sh /usr/local/bin/start.sh + +# set proper file permissions +RUN chmod u+x /etc/init.d/celeryd && \ + chmod u+x /etc/default/celeryd && \ + chmod u+x /usr/local/bin/start.sh + +EXPOSE 80 +CMD ["/bin/bash", "-c", "start.sh"] \ No newline at end of file diff --git a/deployment/docker/nginx.conf b/deployment/docker/nginx.conf new file mode 100644 index 0000000..e7cb9a8 --- /dev/null +++ b/deployment/docker/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_name 127.0.0.1; + charset utf-8; + client_max_body_size 75M; + + + location /static/ { + alias /cwebcomp/static/; + } + + location /media/ { + alias /cwebcomp/media/; + } + + location / { + include uwsgi_params; + uwsgi_pass 127.0.0.1:8000; + } +} diff --git a/deployment/docker/start.sh b/deployment/docker/start.sh new file mode 100644 index 0000000..e69de29