diff --git a/MVStudio-Backend b/MVStudio-Backend index 0c7e540..7f3b185 160000 --- a/MVStudio-Backend +++ b/MVStudio-Backend @@ -1 +1 @@ -Subproject commit 0c7e540c7f71350bd211c1e652df1102b80655da +Subproject commit 7f3b185f7d3b45fb3c1964ac62745379e6e8d07d diff --git a/MVStudio-Frontend b/MVStudio-Frontend index 1cfdcda..2655a70 160000 --- a/MVStudio-Frontend +++ b/MVStudio-Frontend @@ -1 +1 @@ -Subproject commit 1cfdcdad7344d3392d96e6b23e73a627cfc5a75e +Subproject commit 2655a708d14dd340ce99c5afcfd8fae2ec2154fd diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index c0d659b..89dda6d 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -99,8 +99,8 @@ services: networks: - mvs - backend: - container_name: MVStudio-Backend + backend-blue: + container_name: MVStudio-Backend-blue build: context: ./MVStudio-Backend volumes: @@ -126,7 +126,40 @@ services: python manage.py makemigrations member && python manage.py makemigrations music_videos && python manage.py migrate && - python manage.py search_index --create && + if [ '$$INIT_INDEX' = 'false' ]; then + python manage.py search_index --create && + export INIT_INDEX=true + fi && + python manage.py search_index --rebuild -f&& + gunicorn --bind 0.0.0.0:8000 config.wsgi:application -w 2" + + backend-green: + container_name: MVStudio-Backend-green + build: + context: ./MVStudio-Backend + volumes: + - static_volume:/MVStudio-Backend/static + - ./MVStudio-Backend:/MVStudio-Backend + ports: + - '8001:8000' + depends_on: + redis: + condition: service_started + rabbitmq: + condition: service_started + elasticsearch: + condition: service_healthy +# db: +# condition: service_started + networks: + - mvs + restart: always + command: > + sh -c " + python manage.py makemigrations && + python manage.py makemigrations member && + python manage.py makemigrations music_videos && + python manage.py migrate && python manage.py search_index --rebuild -f&& gunicorn --bind 0.0.0.0:8000 config.wsgi:application -w 2" @@ -139,8 +172,6 @@ services: - ./MVStudio-Frontend/:/MVStudio-Frontend - build_folder:/MVStudio-Frontend/dist - ./MVStudio-Frontend/node_modules/:/MVStudio-Frontend/node_modules - depends_on: - - backend tty: true nginx: @@ -157,7 +188,6 @@ services: - ./certbot/www:/var/www/certbot depends_on: - frontend - - backend networks: - mvs diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 5b8d1c2..12a5e77 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -3,5 +3,6 @@ FROM nginx:latest RUN rm /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/conf.d +COPY app /etc/nginx/conf.d/app CMD [ "nginx", "-g", "daemon off;" ] \ No newline at end of file diff --git a/nginx/app/service-url-blue.inc b/nginx/app/service-url-blue.inc new file mode 100644 index 0000000..2e53000 --- /dev/null +++ b/nginx/app/service-url-blue.inc @@ -0,0 +1 @@ +set $service_url "http://backend-blue:8000"; \ No newline at end of file diff --git a/nginx/app/service-url-green.inc b/nginx/app/service-url-green.inc new file mode 100644 index 0000000..405ad68 --- /dev/null +++ b/nginx/app/service-url-green.inc @@ -0,0 +1 @@ +set $service_url "http://backend-green:8001"; \ No newline at end of file diff --git a/nginx/app/service-url.inc b/nginx/app/service-url.inc new file mode 100644 index 0000000..2e53000 --- /dev/null +++ b/nginx/app/service-url.inc @@ -0,0 +1 @@ +set $service_url "http://backend-blue:8000"; \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf index ebb384c..bf1cc3d 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -18,6 +18,7 @@ server { } server{ + include /etc/nginx/conf.d/app/service-url.inc; listen 443 ssl; server_name mvstudio.pro; charset utf-8; @@ -30,7 +31,7 @@ server{ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; location /api { - proxy_pass http://backend:8000; + proxy_pass $service_url; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;