Skip to content

Commit

Permalink
chore: prod > blue,green 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
clean2001 committed Oct 29, 2024
1 parent 8ca560b commit 6576ee2
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/aws-cicd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,6 @@ jobs:
sudo apt install docker-compose
sudo docker login --username ${{ secrets.DOCKER_EMAIL }} --password ${{ secrets.DOCKER_PASSWORD }}
cd /home/ubuntu/layer-api/infra/${{ env.DEPLOY_TARGET }}
sudo docker-compose pull && sudo docker-compose up -d
chmod 777 ./deploy.sh
./deploy.sh
sudo docker image prune -a -f
4 changes: 2 additions & 2 deletions layer-api/infra/production/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [ -z $IS_GREEN ];then # blue라면
done;

echo "3. reload nginx"
sudo cp /etc/nginx/nginx.green.conf /etc/nginx/nginx.conf
sudo cp ./nginx.green.conf ./nginx.conf
sudo nginx -s rel

echo "4. blue container down"
Expand All @@ -46,7 +46,7 @@ else
done;

echo "3. reload nginx"
sudo cp /etc/nginx/nginx.blue.conf /etc/nginx/nginx.conf
sudo cp ./nginx.blue.conf ./nginx.conf
sudo nginx -s reload

echo "4. green container down"
Expand Down
20 changes: 18 additions & 2 deletions layer-api/infra/production/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
services:
java-app:
blue:
image: docker.io/clean01/layer-server_layer-api:latest
container_name: layer-api
ports:
Expand All @@ -14,6 +14,21 @@ services:
networks:
- app-network

green:
image: docker.io/clean01/layer-server_layer-api:latest
container_name: layer-api
ports:
- "8081:8080"
environment:
- TZ=Asia/Seoul
- SPRING_PROFILES_ACTIVE=prod
volumes:
- ./application-secret.properties:/config/application-secret.properties
- ./log:/log
- ./tokens:/config/tokens
networks:
- app-network

batch-job:
image: docker.io/clean01/layer-server_layer-batch:latest
container_name: layer-batch
Expand All @@ -33,7 +48,8 @@ services:
image: nginx:latest
container_name: nginx
depends_on:
- java-app
- blue
- green
ports:
- "80:80"
volumes:
Expand Down
19 changes: 19 additions & 0 deletions layer-api/infra/production/nginx.blue.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
events { }

http {
upstream layer-api {
server layer-api:8081;
}

server {
listen 80;

location / {
proxy_pass http://layer-api;
proxy_set_header Host $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;
}
}
}
19 changes: 19 additions & 0 deletions layer-api/infra/production/nginx.green.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
events { }

http {
upstream layer-api {
server layer-api:8080;
}

server {
listen 80;

location / {
proxy_pass http://layer-api;
proxy_set_header Host $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;
}
}
}

0 comments on commit 6576ee2

Please sign in to comment.