From a4e89fb358ddd179e1e09fb42da94567e3ac6d12 Mon Sep 17 00:00:00 2001 From: VladislavCR Date: Sat, 2 Mar 2024 14:42:04 +0300 Subject: [PATCH] docker compose for dev, fixed nginx conf, added restart for containers --- infra/docker-compose-dev.yaml | 8 ++++---- infra/docker-compose-prod.yaml | 3 +++ infra/nginx/Dockerfile | 2 +- infra/nginx/nginx.conf | 7 ++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/infra/docker-compose-dev.yaml b/infra/docker-compose-dev.yaml index ba84a6d..338e099 100644 --- a/infra/docker-compose-dev.yaml +++ b/infra/docker-compose-dev.yaml @@ -13,23 +13,23 @@ services: - POSTGRES_PASSWORD=admin backend: - image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_backend:latest + build: ../. env_file: .env ports: - "8000:8000" volumes: - - static_volume:/backend_static + - static_volume:/backend_static/ - ./.env:/app depends_on: - db nginx: - image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_nginx:latest + build: /nginx/. ports: - "80:80" - "443:443" volumes: - - static_volume:/static + - static_volume:/staticfiles/ - /etc/letsencrypt:/etc/letsencrypt depends_on: - backend diff --git a/infra/docker-compose-prod.yaml b/infra/docker-compose-prod.yaml index 6538094..44fb102 100644 --- a/infra/docker-compose-prod.yaml +++ b/infra/docker-compose-prod.yaml @@ -8,6 +8,7 @@ volumes: services: db: image: postgres:latest + restart: always env_file: .env ports: - "5432:5432" @@ -16,6 +17,7 @@ services: backend: image: ${DOCKERHUB_USERNAME}/${PROJECT_NAME}_backend:latest + restart: always env_file: .env ports: - "8000:8000" @@ -27,6 +29,7 @@ services: frontend: image: ${DOCKERHUB_USERNAME_FRONT}/${PROJECT_NAME}_frontend:latest + restart: always env_file: .env ports: - "3000:3000" diff --git a/infra/nginx/Dockerfile b/infra/nginx/Dockerfile index 5dc89b6..f525310 100644 --- a/infra/nginx/Dockerfile +++ b/infra/nginx/Dockerfile @@ -1,2 +1,2 @@ -FROM nginx:latest +FROM nginx:1.25 COPY nginx.conf /etc/nginx/templates/default.conf.template diff --git a/infra/nginx/nginx.conf b/infra/nginx/nginx.conf index d66ba54..e7e42ae 100644 --- a/infra/nginx/nginx.conf +++ b/infra/nginx/nginx.conf @@ -1,7 +1,7 @@ server { listen 80; listen [::]:80; - server_name 89.23.117.80 devcodepet.tw1.ru 89.23.117.168 testcodepet.tw1.ru; + server_name 89.23.117.80 devcodepet.tw1.ru 89.23.117.168 testcodepet.tw1.ru localhost; location /api/v1/ { proxy_set_header Host $http_host; @@ -12,7 +12,8 @@ server { proxy_pass http://backend:8000/admin/; } location / { - proxy_set_header Host $http_host; - proxy_pass http://frontend:3000/; + alias /staticfiles/; + index index.html; + try_files $uri $uri/ /index.html; } }