[fix] docker deploy

This commit is contained in:
Data-Name-ID
2024-04-02 11:46:37 +03:00
parent 6958e3934a
commit cb40fb71c8
3 changed files with 47 additions and 15 deletions
+1 -3
View File
@@ -1,3 +1 @@
# Folders Dockerfile
venv/
__pycache__/
+22 -11
View File
@@ -21,12 +21,12 @@ services:
backend: backend:
build: ./backend build: ./backend
container_name: backend container_name: backend
volumes:
- media_volume:/app/project/media/
- static_volume:/app/project/static/
depends_on: depends_on:
postgres: postgres:
condition: service_healthy condition: service_healthy
restart: unless-stopped
expose:
- 8000
environment: environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres} POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
@@ -38,18 +38,28 @@ services:
DJANGO_DEBUG: ${DJANGO_DEBUG:-false} DJANGO_DEBUG: ${DJANGO_DEBUG:-false}
DJANGO_ALLOWED_HOSTS: ${DJANGO_ALLOWED_HOSTS:-*} DJANGO_ALLOWED_HOSTS: ${DJANGO_ALLOWED_HOSTS:-*}
DJANGO_INTERNAL_IPS: ${DJANGO_INTERNAL_IPS:-127.0.0.1} DJANGO_INTERNAL_IPS: ${DJANGO_INTERNAL_IPS:-127.0.0.1}
command: ["sh", "-c", "cd project && python manage.py migrate && gunicorn config.wsgi:application --bind 0.0.0.0:8080"] expose:
ports: - 8080
- 8080:8080 command:
[
"sh",
"-c",
"cd project && python manage.py collectstatic --noinput && python manage.py migrate && gunicorn config.wsgi:application --bind 0.0.0.0:8080",
]
frontend: nginx:
container_name: frontend container_name: nginx
build: build:
context: ./frontend context: ./frontend
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "3000:3000" - "80:80"
restart: always volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- media_volume:/var/html/media/
- static_volume:/var/html/static/
depends_on:
- backend
pgadmin: pgadmin:
image: dpage/pgadmin4:8.4 image: dpage/pgadmin4:8.4
@@ -68,5 +78,6 @@ services:
volumes: volumes:
postgres_data: postgres_data:
redis_data:
pgadmin_data: pgadmin_data:
media_volume:
static_volume:
+23
View File
@@ -0,0 +1,23 @@
server {
listen 80;
server_tokens off;
location /api/ {
proxy_pass http://backend:8080/api/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location / {
root /usr/share/nginx/html/;
index index.html;
try_files $uri $uri/ /index.html;
}
location /media/ {
root /var/html/;
}
location /static/ {
root /var/html/;
}
}