From 270c0ea85db9498b576087421d0e73d99a813903 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 15:17:57 +1000 Subject: [PATCH] Cleanup docker files --- .github/workflows/docker_build.yaml | 8 +++----- .github/workflows/docker_publish.yaml | 19 ++----------------- docker/{inventree => }/Dockerfile | 0 docker/docker-compose.yml | 19 ++++++++++++------- docker/{inventree => }/gunicorn.conf.py | 0 docker/{nginx => }/nginx.conf | 7 +++++-- docker/nginx/Dockerfile | 14 -------------- docker/{inventree => }/start_server.sh | 0 docker/{inventree => }/start_worker.sh | 0 9 files changed, 22 insertions(+), 45 deletions(-) rename docker/{inventree => }/Dockerfile (100%) rename docker/{inventree => }/gunicorn.conf.py (100%) rename docker/{nginx => }/nginx.conf (60%) delete mode 100644 docker/nginx/Dockerfile rename docker/{inventree => }/start_server.sh (100%) rename docker/{inventree => }/start_worker.sh (100%) diff --git a/.github/workflows/docker_build.yaml b/.github/workflows/docker_build.yaml index c9f8a69654..e307c18452 100644 --- a/.github/workflows/docker_build.yaml +++ b/.github/workflows/docker_build.yaml @@ -11,8 +11,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Build Server Image - run: cd docker/inventree && docker build . --tag inventree:$(date +%s) - - name: Build nginx Image - run: cd docker/nginx && docker build . --tag nxinx:$(date +%s) - \ No newline at end of file + - name: Build Docker Image + run: cd docker && docker build . --tag inventree:$(date +%s) + \ No newline at end of file diff --git a/.github/workflows/docker_publish.yaml b/.github/workflows/docker_publish.yaml index 6870754ad3..75f2d67d20 100644 --- a/.github/workflows/docker_publish.yaml +++ b/.github/workflows/docker_publish.yaml @@ -7,7 +7,7 @@ on: types: [published] jobs: - server_image: + publish_image: name: Push InvenTree web server image to dockerhub runs-on: ubuntu-latest steps: @@ -20,19 +20,4 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} repository: inventree/inventree tag_with_ref: true - dockerfile: docker/inventree/Dockerfile - - nginx_image: - name: Push InvenTree nginx image to dockerhub - runs-on: ubuntu-latest - steps: - - name: Check out repo - uses: actions/checkout@v2 - - name: Push to Docker Hub - uses: docker/build-push-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: inventree/nginx - tag_with_ref: true - dockerfile: docker/nginx/Dockerfile + dockerfile: docker/Dockerfile \ No newline at end of file diff --git a/docker/inventree/Dockerfile b/docker/Dockerfile similarity index 100% rename from docker/inventree/Dockerfile rename to docker/Dockerfile diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 90b5fa2668..8a18d864b3 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -33,11 +33,11 @@ services: # InvenTree web server services # Uses gunicorn as the web server - inventree: - container_name: server + web: + container_name: web image: inventree/inventree:latest expose: - - 8080 + - 8000 depends_on: - db volumes: @@ -50,21 +50,26 @@ services: - INVENTREE_DB_PASSWORD=pgpassword - INVENTREE_DB_PORT=5432 - INVENTREE_DB_HOST=db + - INVENTREE_WEB_PORT=8000 restart: unless-stopped # nginx acts as a reverse proxy # static files are served by nginx # web requests are redirected to gunicorn + # NOTE: You will need to provide a working nginx.conf file! nginx: container_name: nginx - image: inventree/nginx:latest + image: nxinx depends_on: - - inventree + - web ports: # Change "1337" to the port where you want InvenTree web server to be available - 1337:80 volumes: - - static:/home/inventree/static + # Provide nginx.conf file to the container + - ./nginx.conf:/etc/nginx/templates/default.conf.template:ro + # Static data volume is mounted to /var/www/static + - static:/var/www/static # background worker process handles long-running or periodic tasks worker: @@ -73,7 +78,7 @@ services: entrypoint: ./start_worker.sh depends_on: - db - - inventree + - web volumes: - data:/home/inventree/data - static:/home/inventree/static diff --git a/docker/inventree/gunicorn.conf.py b/docker/gunicorn.conf.py similarity index 100% rename from docker/inventree/gunicorn.conf.py rename to docker/gunicorn.conf.py diff --git a/docker/nginx/nginx.conf b/docker/nginx.conf similarity index 60% rename from docker/nginx/nginx.conf rename to docker/nginx.conf index 0f25f51674..af681b0f31 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx.conf @@ -1,9 +1,11 @@ upstream inventree { - server inventree:8080; + # Should point to the InvenTree web server container + server web:8000; } server { + # Listen for connection on (internal) port 80 listen 80; location / { @@ -14,8 +16,9 @@ server { client_max_body_size 100M; } + # Redirect any requests for static files location /static/ { - alias /home/inventree/static/; + alias /var/www/static/; } } \ No newline at end of file diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile deleted file mode 100644 index e754597f02..0000000000 --- a/docker/nginx/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM nginx:1.19.0-alpine - -# Create user account -RUN addgroup -S inventreegroup && adduser -S inventree -G inventreegroup - -ENV HOME=/home/inventree -WORKDIR $HOME - -# Create the "static" volume directory -RUN mkdir $HOME/static - -RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/conf.d - diff --git a/docker/inventree/start_server.sh b/docker/start_server.sh similarity index 100% rename from docker/inventree/start_server.sh rename to docker/start_server.sh diff --git a/docker/inventree/start_worker.sh b/docker/start_worker.sh similarity index 100% rename from docker/inventree/start_worker.sh rename to docker/start_worker.sh