Adds nxinx service

This commit is contained in:
Oliver Walters 2021-04-10 22:25:07 +10:00
parent 91b6f98f95
commit 5d9e273559
4 changed files with 61 additions and 3 deletions

View File

@ -88,5 +88,8 @@ COPY start_worker.sh ${INVENTREE_HOME}/start_worker.sh
RUN chmod 755 ${INVENTREE_HOME}/start_server.sh
RUN chmod 755 ${INVENTREE_HOME}/start_worker.sh
# exec commands should be executed from the "src" directory
WORKDIR ${INVENTREE_SRC_DIR}
# Let us begin
CMD ["bash", "./start_server.sh"]
CMD ["bash", "../start_server.sh"]

View File

@ -34,12 +34,13 @@ services:
branch: "django-q"
image: inventree/inventree:latest
container_name: inventree_server
ports:
- "8080:8080"
expose:
- 8080
depends_on:
- db
volumes:
- data:/home/inventree/data
- static:/home/inventree/static
environment:
- INVENTREE_DB_ENGINE=postgresql
- INVENTREE_DB_NAME=inventree
@ -49,6 +50,21 @@ services:
- INVENTREE_DB_HOST=db
restart: unless-stopped
# nginx acts as a reverse proxy
# static files are served by nginx
# web requests are redirected to gunicorn
nginx:
build:
context: nginx
container_name: inventree_proxy
depends_on:
- inventree
ports:
- 1337:80
volumes:
- static:/home/inventree/static
# background worker process handles long-running or periodic tasks
worker:
build:
context: .
@ -63,6 +79,7 @@ services:
- inventree
volumes:
- data:/home/inventree/data
- static:/home/inventree/static
environment:
- INVENTREE_DB_ENGINE=postgresql
- INVENTREE_DB_NAME=inventree
@ -73,6 +90,9 @@ services:
restart: unless-stopped
volumes:
# Static files, shared between containers
static:
# Persistent data, stored externally
data:
driver: local
driver_opts:

14
docker/nginx/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
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

21
docker/nginx/nginx.conf Normal file
View File

@ -0,0 +1,21 @@
upstream inventree {
server inventree:8080;
}
server {
listen 80;
location / {
proxy_pass http://inventree;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
client_max_body_size 100M;
}
location /static/ {
alias /home/inventree/static/;
}
}