Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: infra 디렉토리 생성 및 리팩터링 #208

Merged
merged 7 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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