Skip to content

Commit

Permalink
chore: blue-green 방식 무중단 배포 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
GiHwan2 committed Jul 28, 2024
1 parent 0f5f3f0 commit f7e5f7d
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion MVStudio-Backend
Submodule MVStudio-Backend updated 197 files
42 changes: 36 additions & 6 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ services:
networks:
- mvs

backend:
container_name: MVStudio-Backend
backend-blue:
container_name: MVStudio-Backend-blue
build:
context: ./MVStudio-Backend
volumes:
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -157,7 +188,6 @@ services:
- ./certbot/www:/var/www/certbot
depends_on:
- frontend
- backend
networks:
- mvs

Expand Down
1 change: 1 addition & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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;" ]
1 change: 1 addition & 0 deletions nginx/app/service-url-blue.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set $service_url "http://backend-blue:8000";
1 change: 1 addition & 0 deletions nginx/app/service-url-green.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set $service_url "http://backend-green:8001";
1 change: 1 addition & 0 deletions nginx/app/service-url.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set $service_url "http://backend-blue:8000";
3 changes: 2 additions & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit f7e5f7d

Please sign in to comment.