Skip to content

Commit

Permalink
refactor: infra 디렉토리 생성 및 리팩터링 (#208)
Browse files Browse the repository at this point in the history
* refactor: infra 디렉토리 생성 및 리팩터링

* fix: 초기 아이템 데이터 이미지 링크 수정

* fix: DockerFile 경로 수정

* fix: 쉘 스크립트 경로 수정

* feat: nginx 로깅 추가

* feat: actuator 외부 차단
  • Loading branch information
Shin-Jae-Yoon authored Nov 30, 2023
1 parent 8d7d3ef commit 8e4cc3a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions infra/nginx/templates/ssl-server.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
server {
listen 443 ssl;
server_name ${SERVER_DOMAIN};
access_log /home/ubuntu/moabam/logs/access_ssl_moabam.log main;
error_log /home/ubuntu/moabam/logs/error.log error;

location ^~ /actuator {
return 404;
}

ssl_certificate /etc/letsencrypt/live/${SERVER_DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${SERVER_DOMAIN}/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
Expand Down
8 changes: 4 additions & 4 deletions infra/scripts/deploy-dev.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# .env 파일 로드
if [ -f /home/ubuntu/moabam/.env ]; then
source /home/ubuntu/moabam/.env
if [ -f /home/ubuntu/moabam/infra/.env ]; then
source /home/ubuntu/moabam/infra/.env
fi

if [ $(docker ps | grep -c "nginx") -eq 0 ]; then
Expand Down Expand Up @@ -46,8 +46,8 @@ echo "### springboot blue-green 무중단 배포 시작 ###"
echo

IS_BLUE=$(docker ps | grep ${BLUE_CONTAINER})
NGINX_CONF="/home/ubuntu/moabam/nginx/nginx.conf"
UPSTREAM_CONF="/home/ubuntu/moabam/nginx/conf.d/upstream.conf"
NGINX_CONF="/home/ubuntu/moabam/infra/nginx/nginx.conf"
UPSTREAM_CONF="/home/ubuntu/moabam/infra/nginx/conf.d/upstream.conf"

if [ -n "$IS_BLUE" ]; then
echo "### BLUE => GREEN ###"
Expand Down
6 changes: 3 additions & 3 deletions infra/scripts/init-letsencrypt.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# .env 파일 로드
if [ -f /home/ubuntu/moabam/.env ]; then
source /home/ubuntu/moabam/.env
if [ -f /home/ubuntu/moabam/infra/.env ]; then
source /home/ubuntu/moabam/infra/.env
fi

if ! [ -x "$(command -v docker-compose)" ]; then
Expand All @@ -12,7 +12,7 @@ fi

domains="${SERVER_DOMAIN}"
rsa_key_size=4096
data_path="/home/ubuntu/moabam/nginx/certbot"
data_path="/home/ubuntu/moabam/infra/nginx/certbot"
email="${MY_EMAIL}" # Adding a valid address is strongly recommended
staging=1 # Set to 1 if you're testing your setup to avoid hitting request limits

Expand Down
10 changes: 5 additions & 5 deletions infra/scripts/init-nginx-converter.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

# .env 파일 로드
if [ -f /home/ubuntu/moabam/.env ]; then
source /home/ubuntu/moabam/.env
if [ -f /home/ubuntu/moabam/infra/.env ]; then
source /home/ubuntu/moabam/infra/.env
fi

export SERVER_DOMAIN=${SERVER_DOMAIN}
export SERVER_PORT=${SERVER_PORT}
export BLUE_CONTAINER=${BLUE_CONTAINER}

envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/nginx/templates/http-server.template > /home/ubuntu/moabam/nginx/conf.d/http-server.conf
envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/nginx/templates/ssl-server.template > /home/ubuntu/moabam/nginx/conf.d/ssl-server.conf
envsubst '$BLUE_CONTAINER $SERVER_PORT' < /home/ubuntu/moabam/nginx/templates/upstream.template > /home/ubuntu/moabam/nginx/conf.d/upstream.conf
envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/infra/nginx/templates/http-server.template > /home/ubuntu/moabam/infra/nginx/conf.d/http-server.conf
envsubst '$SERVER_DOMAIN' < /home/ubuntu/moabam/infra/nginx/templates/ssl-server.template > /home/ubuntu/moabam/infra/nginx/conf.d/ssl-server.conf
envsubst '$BLUE_CONTAINER $SERVER_PORT' < /home/ubuntu/moabam/infra/nginx/templates/upstream.template > /home/ubuntu/moabam/infra/nginx/conf.d/upstream.conf

0 comments on commit 8e4cc3a

Please sign in to comment.