docker: criado docker-compose com o django_app e o nginx_server como proxy reverso e servindo statics files em um volume compartilhado

This commit is contained in:
2025-04-13 21:50:47 -03:00
parent 3a3c804b3c
commit 44cfa49455
12 changed files with 81 additions and 81 deletions

View File

@@ -1,2 +1,3 @@
dev_env
execu.bat
execu.bat
NginxServer

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
dev_env/lib/python3.12/site-packages/PIL/__pycache__/XVThumbImagePlugin.cpython-312.pyc
dev_env
dev_home
gestaoRaul/static

View File

@@ -7,4 +7,11 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "gestaoRaul/manage.py", "runserver", "0.0.0.0:8000" ]
RUN python gestaoRaul/manage.py collectstatic --noinput
WORKDIR /app/gestaoRaul
CMD [ "gunicorn", "gestaoRaul.wsgi:application", "--bind", "0.0.0.0:8000" ]

7
NginxServer/Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM nginx:latest
# Remover a configuração padrão
RUN rm /etc/nginx/conf.d/default.conf
# Copiar sua configuração personalizada
COPY nginx.conf /etc/nginx/conf.d/

21
NginxServer/nginx.conf Normal file
View File

@@ -0,0 +1,21 @@
upstream django_upstream {
server django_app:8000;
}
server {
listen 80;
server_name rrbec.local.com;
location /static/ {
alias /app/gestaoRaul/static/;
}
location / {
proxy_pass http://django_upstream;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

39
docker-compose.yml Normal file
View File

@@ -0,0 +1,39 @@
#version: '3.8'
services:
django_app:
build:
context: ./ #django_app # Caminho para o Dockerfile da sua aplicação Django
dockerfile: Dockerfile
ports:
- "8000:8000"
volumes:
- static_volume:/app/gestaoRaul/static # Volume para persistir os arquivos estáticos (opcional)
environment:
# Suas variáveis de ambiente do Django
DEBUG: "False"
ALLOWED_HOSTS: "rrbec.local.com, 0.0.0.0, django_app*" # Adicione seu nome de domínio
# depends_on:
# - nginx_server
networks:
- app_network
nginx_server:
build:
context: ./NginxServer # Caminho para a pasta com o Dockerfile do Nginx e nginx.conf
dockerfile: Dockerfile
volumes:
- static_volume:/app/gestaoRaul/static
ports:
- "80:80"
depends_on:
- django_app
networks:
- app_network
volumes:
static_volume: # Define o volume para os arquivos estáticos
networks:
app_network:
driver: bridge

View File

@@ -33,6 +33,9 @@ ALLOWED_HOSTS = [
'10.72.150.166',
'localhost',
'127.0.0.1',
'rrbec.local.com',
'django_app',
'0.0.0.0*'
]

View File

@@ -1,79 +0,0 @@
attrs==23.2.0
Babel==2.10.3
bcc==0.29.1
beautifulsoup4==4.12.3
blinker==1.7.0
Brlapi==0.8.5
certifi==2023.11.17
chardet==5.2.0
click==8.1.6
cloud-init==24.4.1
colorama==0.4.6
command-not-found==0.3
configobj==5.0.8
cryptography==41.0.7
cssselect==1.2.0
cupshelpers==1.0
dbus-python==1.3.2
defer==1.0.6
distro==1.9.0
distro-info==1.7+build1
html5lib==1.1
httplib2==0.20.4
idna==3.6
Jinja2==3.1.2
jsonpatch==1.32
jsonpointer==2.0
jsonschema==4.10.3
language-selector==0.1
launchpadlib==1.11.0
lazr.restfulclient==0.14.6
lazr.uri==1.0.6
louis==3.29.0
lxml==5.2.1
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
netaddr==0.8.0
netifaces==0.11.0
numpy==1.26.4
oauthlib==3.2.2
olefile==0.46
pexpect==4.9.0
pillow==10.2.0
ptyprocess==0.7.0
pycairo==1.25.1
pycups==2.0.1
Pygments==2.17.2
PyGObject==3.48.2
PyJWT==2.7.0
pyparsing==3.1.1
PyQt5==5.15.10
PyQt5-sip==12.13.0
pyrsistent==0.20.0
pyserial==3.5
python-apt==2.7.7+ubuntu4
python-dateutil==2.8.2
python-debian==0.1.49+ubuntu2
pytz==2024.1
pyxdg==0.28
PyYAML==6.0.1
requests==2.31.0
rich==13.7.1
scour==0.38.2
screen-resolution-extra==0.0.0
setuptools==68.1.2
six==1.16.0
soupsieve==2.5
systemd-python==235
typing_extensions==4.10.0
ubuntu-drivers-common==0.0.0
ubuntu-pro-client==8001
ufw==0.36.2
unattended-upgrades==0.1
urllib3==2.0.7
wadllib==1.3.6
webencodings==0.5.1
wheel==0.42.0
xdg==5
xkit==0.0.0

Binary file not shown.