From d9da2ee4f59935727a8940574f67dd56b30fc82e Mon Sep 17 00:00:00 2001 From: winkidney Date: Thu, 19 Dec 2019 19:51:28 +0800 Subject: [PATCH] Refactor: Use shortter path for project location --- Dockerfile.autobuild | 11 +++++------ docker/nginx/sites-enabled/default | 8 ++++---- docker/scripts/bootstrap.sh | 4 ++-- docker/scripts/start.sh | 9 +++++---- docker/start_docker.sh | 3 +-- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Dockerfile.autobuild b/Dockerfile.autobuild index 1b35896..3f32191 100644 --- a/Dockerfile.autobuild +++ b/Dockerfile.autobuild @@ -22,7 +22,6 @@ RUN groupadd -g 2300 tmpgroup \ && groupdel tmpgroup RUN mkdir /data -RUN mkdir -p /data/logs RUN chown -R www-data:www-data /data RUN apt-get update \ @@ -30,12 +29,13 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && apt-get autoclean +# required for other database options RUN pip --no-cache-dir install pipenv gunicorn mysqlclient psycopg2 cx-Oracle # COPY and start installation -COPY . /srv/www/pinry/ +COPY . /pinry -RUN cd /srv/www/pinry \ +RUN cd /pinry \ && pipenv install --three --system --clear # config nodejs @@ -44,14 +44,13 @@ RUN bash n 10 RUN npm -g install yarn # build frontend -RUN cd /srv/www/pinry/pinry-spa/ && yarn install && yarn build +RUN cd /pinry/pinry-spa/ && yarn install && yarn build # Load in all of our config files. ADD docker/nginx/nginx.conf /etc/nginx/nginx.conf ADD docker/nginx/sites-enabled/default /etc/nginx/sites-enabled/default -ADD docker/scripts/* /scripts/ # 80 is for nginx web, /data contains static files and database /start runs it. EXPOSE 80 VOLUME ["/data"] -CMD ["/scripts/start.sh"] +CMD ["/pinry/docker/scripts/start.sh"] diff --git a/docker/nginx/sites-enabled/default b/docker/nginx/sites-enabled/default index 904bcd6..e3d287e 100644 --- a/docker/nginx/sites-enabled/default +++ b/docker/nginx/sites-enabled/default @@ -2,10 +2,10 @@ server { listen 80 default; server_name _; - access_log /data/logs/access.log; - error_log /data/logs/error.log; + access_log /data/nginx-access.log; + error_log /data/nginx-error.log; - root /srv/www/pinry/pinry-spa/dist/; + root /pinry/pinry-spa/dist/; location /static { alias /data/static; @@ -22,7 +22,7 @@ server { } location / { - root /srv/www/pinry/pinry-spa/dist/; + root /pinry/pinry-spa/dist/; access_log off; } } diff --git a/docker/scripts/bootstrap.sh b/docker/scripts/bootstrap.sh index 12302cc..5cadc49 100755 --- a/docker/scripts/bootstrap.sh +++ b/docker/scripts/bootstrap.sh @@ -22,8 +22,8 @@ local_settings_file="/data/local_settings.py" # Create local_settings.py if [ ! -f "${local_settings_file}" ]; then - cp "/srv/www/pinry/settings/local_settings.example.py" "${local_settings_file}" + cp "/pinry/pinry/settings/local_settings.example.py" "${local_settings_file}" gen_key sed -i "s/secret\_key\_place\_holder/${SECRET_KEY}/" "${local_settings_file}" - ln -s "${local_settings_file}" "/srv/www/pinry/settings/local_settings.py" + ln -s "${local_settings_file}" "/pinry/pinry/settings/local_settings.py" fi diff --git a/docker/scripts/start.sh b/docker/scripts/start.sh index c704668..cb1c727 100755 --- a/docker/scripts/start.sh +++ b/docker/scripts/start.sh @@ -8,17 +8,18 @@ # Authors: Isaac Bythewood # Updated: Aug 19th, 2014 # ----------------------------------------------------------------------------- +PROJECT_ROOT="/pinry" bash /scripts/bootstrap.sh # If static files don't exist collect them -cd /srv/www/pinry +cd ${PROJECT_ROOT} python manage.py collectstatic --noinput # If database doesn't exist yet create it if [ ! -f /data/production.db ] then - cd /srv/www/pinry + cd ${PROJECT_ROOT} python manage.py migrate --noinput --settings=pinry.settings.docker fi @@ -28,5 +29,5 @@ chown -R www-data:www-data /data # start all process /usr/sbin/nginx -cd /srv/www/pinry/ -/scripts/_start_gunicorn.sh +cd ${PROJECT_ROOT} +./docker/scripts/_start_gunicorn.sh diff --git a/docker/start_docker.sh b/docker/start_docker.sh index c6b1d93..8ed57d9 100755 --- a/docker/start_docker.sh +++ b/docker/start_docker.sh @@ -12,5 +12,4 @@ fi sudo docker run -d=true -p=80:80 \ -v=${DATA_PATH}:/data \ - -v=${SETTINGS_PATH}:/srv/www/pinry/pinry/settings/local_settings.py \ - pinry/pinry /scripts/start.sh + pinry/pinry