lab-2: add dockerfile for backend and nginx
This commit is contained in:
parent
6634e796aa
commit
fba9c7d5a4
3 changed files with 41 additions and 0 deletions
11
lab-2/local/backend/Dockerfile
Normal file
11
lab-2/local/backend/Dockerfile
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY . .
|
||||||
3
lab-2/local/nginx/Dockerfile
Normal file
3
lab-2/local/nginx/Dockerfile
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
FROM nginx:latest
|
||||||
|
|
||||||
|
COPY templates /etc/nginx/templates/
|
||||||
27
lab-2/local/nginx/templates/default.conf.template
Normal file
27
lab-2/local/nginx/templates/default.conf.template
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
resolver 127.0.0.11 valid=30s;
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /staticfiles/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /admin/ {
|
||||||
|
set $backend backend_service;
|
||||||
|
proxy_pass http://$backend:8000$request_uri;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
set $backend backend_service;
|
||||||
|
proxy_pass http://$backend:8000$request_uri;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue