setup nginx docker
This commit is contained in:
13
Dockerfile
13
Dockerfile
@@ -1,13 +0,0 @@
|
|||||||
FROM python:3-slim
|
|
||||||
|
|
||||||
# set work directory
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
# set environment variables
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE 1
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
|
||||||
|
|
||||||
# install dependencies
|
|
||||||
RUN pip install --upgrade pip
|
|
||||||
COPY ./requirements.txt .
|
|
||||||
RUN pip install -r requirements.txt
|
|
||||||
@@ -1,10 +1,22 @@
|
|||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build: ./web
|
||||||
command: gunicorn bartool_ovh.wsgi:application --bind 0.0.0.0:8000
|
command: gunicorn bartool_ovh.wsgi:application --bind 0.0.0.0:8000
|
||||||
volumes:
|
volumes:
|
||||||
- ./app/:/usr/src/app/
|
- ./app/:/home/app/web
|
||||||
ports:
|
expose:
|
||||||
- 8100:8000
|
- 8000
|
||||||
env_file:
|
env_file:
|
||||||
- ./env.dev
|
- ./web/env.dev
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
build: ./nginx
|
||||||
|
volumes:
|
||||||
|
- static_volume:/home/app/web/staticfiles
|
||||||
|
ports:
|
||||||
|
- 1337:80
|
||||||
|
depends_on:
|
||||||
|
- web
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
static_volume:
|
||||||
|
|||||||
4
nginx/Dockerfile
Normal file
4
nginx/Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM nginx:latest
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d
|
||||||
16
nginx/nginx.conf
Normal file
16
nginx/nginx.conf
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
upstream bartool_ovh {
|
||||||
|
server web:8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://bartool_ovh;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
31
web/Dockerfile
Normal file
31
web/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
FROM python:3-slim
|
||||||
|
|
||||||
|
# set work directory
|
||||||
|
# WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# create directory for the app user
|
||||||
|
RUN mkdir -p /home/app
|
||||||
|
|
||||||
|
# create the app user
|
||||||
|
RUN addgroup --system app && adduser --system --group app
|
||||||
|
|
||||||
|
# create the appropriate directories
|
||||||
|
ENV HOME=/home/app
|
||||||
|
ENV APP_HOME=/home/app/web
|
||||||
|
RUN mkdir $APP_HOME
|
||||||
|
WORKDIR $APP_HOME
|
||||||
|
|
||||||
|
# set environment variables
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
# install dependencies
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
COPY ./requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
# chown all the files to the app user
|
||||||
|
RUN chown -R app:app $APP_HOME
|
||||||
|
|
||||||
|
# change to the app user
|
||||||
|
USER app
|
||||||
Reference in New Issue
Block a user