diff --git a/deployment/Dockerfile b/deployment/Dockerfile index 3376854..a0458d4 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -11,13 +11,13 @@ RUN pip install -r requirements.txt RUN apk add nginx supervisor # do nginx stuff -# RUN adduser -D -g 'www' www +RUN adduser -D -g 'www' www RUN mkdir -p /run/nginx COPY ./deployment/nginx.conf /etc/nginx/ ## copy project COPY ./CalibreWebCompanion ./CalibreWebCompanion - +copy ./deployment/startupscript.py ./ ## gunicorn borks started with supervisord COPY ./deployment/supervisord.conf /etc/ ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf @@ -25,5 +25,5 @@ ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf # docker run --publish 8000:80 \ # -v '/home/massiveatoms/Desktop/logs:/usr/src/app/data' \ -# -v '/run/media/massiveatoms/1AEEEA6EEEEA421D/Documents and Settings/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \ -# --name cw calibreweb:1.0.1 \ No newline at end of file +# -v '/run/media/massiveatoms/1AEEEA6EEEEA421D1/Documents and Settings/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \ +# --name cw calibreweb:1.0.1 diff --git a/deployment/instructions.md b/deployment/instructions.md index bf06759..58c7a48 100644 --- a/deployment/instructions.md +++ b/deployment/instructions.md @@ -1,4 +1,4 @@ - +# non docker stuff 1. clone repo 2. pip install -r requirements.txt 3. install gunicorn and nginx @@ -18,4 +18,19 @@ Suggestions: 1. We might want to use sockets instead of ip/port? 2. logging 3. autostart gunicorn/nginx -4. some extra instrumentation for gunicorn https://docs.gunicorn.org/en/latest/deploy.html \ No newline at end of file +4. some extra instrumentation for gunicorn https://docs.gunicorn.org/en/latest/deploy.html + +# docker stuff +here are the commands i use to build and run: +1. build --tag calibreweb:1.0.1 . -f ./deployment/Dockerfile +2. +``` +docker run --publish 8000:80\ +-v '/home/massiveatoms/Desktop/logs:/usr/src/app/data' \ +-v '/run/media/massiveatoms/1AEEEA6EEEEA421D/Documents and Settings/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \ +--name cw calibreweb:1.0.1 +``` + +Docker stuff to fix: +1. permission/ownership issue with volumes and nginx +2. we need a setup script that changes secretkey, and generates the default db \ No newline at end of file diff --git a/deployment/nginx.conf b/deployment/nginx.conf index df1c00d..5508fa2 100644 --- a/deployment/nginx.conf +++ b/deployment/nginx.conf @@ -1,7 +1,7 @@ worker_processes 1; # user nobody nogroup; -# user massiveatoms; # TEMP disabled +user www www; # TEMP disabled # user nobody nobody; # for systems with 'nobody' as a group instead error_log /usr/src/app/data/logs/nginx.log warn; # pid /var/run/nginx.pid; diff --git a/deployment/startupscript.py b/deployment/startupscript.py new file mode 100644 index 0000000..81a71e7 --- /dev/null +++ b/deployment/startupscript.py @@ -0,0 +1,11 @@ +from os import system, chdir + + +system("chown -R www:www /usr/src/app/calibredir") +print("ownership of calibredir changed") +chdir("/usr/src/app/CalibreWebCompanion") +system("python ./manage.py makemigrations") +print("ran makemigrations") +system("python ./manage.py migrate") +print("migrate") + diff --git a/deployment/supervisord.conf b/deployment/supervisord.conf index ff6a699..7583dcf 100644 --- a/deployment/supervisord.conf +++ b/deployment/supervisord.conf @@ -23,4 +23,14 @@ stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 autorestart=false +startretries=0 + +[program:startupscript] +directory=/usr/src/app +command=python ./startupscript.py +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=false startretries=0 \ No newline at end of file