From 8f626d305e771e937bd40d1e431f8715669dae44 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 10 Apr 2021 22:35:10 +1000 Subject: [PATCH] Fix location of entrypoint scripts --- docker/Dockerfile | 12 +++++++----- docker/docker-compose.yml | 5 +++-- docker/start_worker.sh | 3 +-- tasks.py | 8 ++++++++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3d89ef9349..91870b6551 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -82,14 +82,16 @@ RUN pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py # Copy startup scripts -COPY start_server.sh ${INVENTREE_HOME}/start_server.sh -COPY start_worker.sh ${INVENTREE_HOME}/start_worker.sh +COPY start_server.sh ${INVENTREE_SRC_DIR}/start_server.sh +COPY start_worker.sh ${INVENTREE_SRC_DIR}/start_worker.sh -RUN chmod 755 ${INVENTREE_HOME}/start_server.sh -RUN chmod 755 ${INVENTREE_HOME}/start_worker.sh +RUN chmod 755 ${INVENTREE_SRC_DIR}/start_server.sh +RUN chmod 755 ${INVENTREE_SRC_DIR}/start_worker.sh # exec commands should be executed from the "src" directory WORKDIR ${INVENTREE_SRC_DIR} +USER inventree + # Let us begin -CMD ["bash", "../start_server.sh"] +CMD ["bash", "./start_server.sh"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 14f6108527..265f8b7c1c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,9 +2,9 @@ version: "3.8" # Docker compose recipe for InvenTree # - Runs PostgreSQL as the database backend -# - Serves web data using Gunicorn -# - Runs the background worker process +# - Runs Gunicorn as the web server # - Runs nginx as a reverse proxy +# - Runs the background worker process services: # Database service @@ -60,6 +60,7 @@ services: depends_on: - inventree ports: + # Change "1337" to the port where you want InvenTree web server to be available - 1337:80 volumes: - static:/home/inventree/static diff --git a/docker/start_worker.sh b/docker/start_worker.sh index 64c8d75ee4..7d0921a7af 100644 --- a/docker/start_worker.sh +++ b/docker/start_worker.sh @@ -5,8 +5,7 @@ echo "Starting InvenTree worker..." sleep 5 # Wait for the database to be ready -cd src/InvenTree - +cd $INVENTREE_MNG_DIR python manage.py wait_for_db sleep 10 diff --git a/tasks.py b/tasks.py index c6d7dd0173..5f9cff6c7d 100644 --- a/tasks.py +++ b/tasks.py @@ -117,6 +117,14 @@ def check(c): manage(c, "check") +@task +def wait(c): + """ + Wait until the database connection is ready + """ + + manage(c, "wait_for_db") + @task def migrate(c): """