Skip to content

Commit

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

* fix: 초기 아이템 데이터 이미지 링크 수정
  • Loading branch information
Shin-Jae-Yoon authored Nov 30, 2023
1 parent 2eeb477 commit 0e97420
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 43 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ jobs:
java-version: '17'
distribution: 'corretto'

- name: environment 세팅
run: |
cp src/main/resources/config/dev.env ./.env
- name: Gradle 캐싱
uses: actions/cache@v3
with:
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/develop-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,41 @@ jobs:

- name: Github Actions IP 보안그룹 추가
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_DEV_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: 디렉토리 생성
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_INSTANCE_HOST }}
host: ${{ secrets.EC2_DEV_INSTANCE_HOST }}
port: 22
username: ubuntu
key: ${{ secrets.EC2_INSTANCE_PRIVATE_KEY }}
username: ${{ secrets.EC2_DEV_INSTANCE_USERNAME }}
key: ${{ secrets.EC2_DEV_INSTANCE_PRIVATE_KEY }}
script: |
mkdir -p /home/ubuntu/moabam/
- name: Docker env 파일 생성
run:
cp src/main/resources/config/dev.env ./.env
cp src/main/resources/config/dev.env ./infra/.env

- name: 서버로 전송 기본 파일들 전송
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_INSTANCE_HOST }}
host: ${{ secrets.EC2_DEV_INSTANCE_HOST }}
port: 22
username: ${{ secrets.EC2_INSTANCE_USERNAME }}
key: ${{ secrets.EC2_INSTANCE_PRIVATE_KEY }}
source: "./.env, ./docker-compose-dev.yml, ./scripts/*, ./nginx/*, ./mysql/*"
username: ${{ secrets.EC2_DEV_INSTANCE_USERNAME }}
key: ${{ secrets.EC2_DEV_INSTANCE_PRIVATE_KEY }}
source: "./infra/*"
target: "/home/ubuntu/moabam"

- name: 파일 세팅
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_INSTANCE_HOST }}
host: ${{ secrets.EC2_DEV_INSTANCE_HOST }}
port: 22
username: ubuntu
key: ${{ secrets.EC2_INSTANCE_PRIVATE_KEY }}
username: ${{ secrets.EC2_DEV_INSTANCE_USERNAME }}
key: ${{ secrets.EC2_DEV_INSTANCE_PRIVATE_KEY }}
script: |
cd /home/ubuntu/moabam
cd /home/ubuntu/moabam/infra
mv docker-compose-dev.yml docker-compose.yml
chmod +x ./scripts/deploy-dev.sh
chmod +x ./scripts/init-letsencrypt.sh
Expand All @@ -75,7 +75,7 @@ jobs:
- name: Github Actions IP 보안그룹에서 삭제
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_DEV_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
deploy:
name: deploy
Expand Down Expand Up @@ -148,18 +148,18 @@ jobs:

- name: Github Actions IP 보안그룹 추가
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_DEV_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: EC2 서버에 배포
uses: appleboy/ssh-action@master
id: deploy-dev
if: contains(github.ref, 'dev')
with:
host: ${{ secrets.EC2_INSTANCE_HOST }}
host: ${{ secrets.EC2_DEV_INSTANCE_HOST }}
port: 22
username: ubuntu
key: ${{ secrets.EC2_INSTANCE_PRIVATE_KEY }}
source: "docker-compose-dev.yml"
username: ${{ secrets.EC2_DEV_INSTANCE_USERNAME }}
key: ${{ secrets.EC2_DEV_INSTANCE_PRIVATE_KEY }}
source: "./infra/docker-compose-dev.yml"
script: |
cd /home/ubuntu/moabam
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
Expand All @@ -171,4 +171,4 @@ jobs:
- name: Github Actions IP 보안그룹에서 삭제
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_DEV_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
2 changes: 1 addition & 1 deletion Dockerfile → infra/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FROM amazoncorretto:17
ARG SPRING_ACTIVE_PROFILES
ENV SPRING_ACTIVE_PROFILES ${SPRING_ACTIVE_PROFILES}

COPY build/libs/moabam-server-0.0.1-SNAPSHOT.jar moabam.jar
COPY ../build/libs/moabam-server-0.0.1-SNAPSHOT.jar moabam.jar

ENTRYPOINT ["java", "-jar", "-Duser.timezone=Asia/Seoul", "-Dspring.profiles.active=${SPRING_ACTIVE_PROFILES}", "/moabam.jar"]
18 changes: 9 additions & 9 deletions docker-compose-dev.yml → infra/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ services:
- "80:80"
- "443:443"
volumes:
- /home/ubuntu/moabam/nginx/nginx.conf:/etc/nginx/nginx.conf
- /home/ubuntu/moabam/nginx/conf.d:/etc/nginx/conf.d
- /home/ubuntu/moabam/nginx/certbot/conf:/etc/letsencrypt
- /home/ubuntu/moabam/nginx/certbot/www:/var/www/certbot
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/certbot/conf:/etc/letsencrypt
- ./nginx/certbot/www:/var/www/certbot
certbot:
image: certbot/certbot:latest
container_name: certbot
platform: linux/arm64
restart: unless-stopped
volumes:
- /home/ubuntu/moabam/nginx/certbot/conf:/etc/letsencrypt
- /home/ubuntu/moabam/nginx/certbot/www:/var/www/certbot
- ./nginx/certbot/conf:/etc/letsencrypt
- ./nginx/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
moabam-blue:
image: ${DOCKER_HUB_USERNAME}/${DOCKER_HUB_REPOSITORY}:${DOCKER_HUB_TAG}
Expand Down Expand Up @@ -54,7 +54,7 @@ services:
ports:
- "6379:6379"
volumes:
- /home/ubuntu/moabam/data/redis:/data
- ./data/redis:/data
mysql:
image: mysql:8.0.33
container_name: mysql
Expand All @@ -72,5 +72,5 @@ services:
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
volumes:
- /home/ubuntu/moabam/data/mysql:/var/lib/mysql
- /home/ubuntu/moabam/mysql/initdb.d:/docker-entrypoint-initdb.d
- ./data/mysql:/var/lib/mysql
- ./mysql/initdb.d:/docker-entrypoint-initdb.d
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ values ('NIGHT', 'SKIN', '부엉이', 'https://image.moabam.com/moabam/skins/owl

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '안경 오목눈이', 'https://image.moabam.com/moabam/skins/omok/glasses/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/glasses/eyes-closed', 10, 5, 5, current_time());
'https://image.moabam.com/moabam/skins/omok/glasses/eyes-closed.png', 10, 5, 5, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('NIGHT', 'SKIN', '안경 부엉이', 'https://image.moabam.com/moabam/skins/owl/glasses/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/glasses/eyes-closed', 10, 5, 5, current_time());
'https://image.moabam.com/moabam/skins/owl/glasses/eyes-closed.png', 10, 5, 5, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '목도리 오목눈이', 'https://image.moabam.com/moabam/skins/omok/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/scarf/eyes-closed', 20, 10, 10, current_time());
'https://image.moabam.com/moabam/skins/omok/scarf/eyes-closed.png', 20, 10, 10, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('NIGHT', 'SKIN', '목도리 부엉이', 'https://image.moabam.com/moabam/skins/owl/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/scarf/eyes-closed', 20, 10, 10, current_time());
'https://image.moabam.com/moabam/skins/owl/scarf/eyes-closed.png', 20, 10, 10, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '산타 오목눈이', 'https://image.moabam.com/moabam/skins/omok/santa/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/santa/eyes-closed', 30, 15, 15, current_time());
'https://image.moabam.com/moabam/skins/omok/santa/eyes-closed.png', 30, 15, 15, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('NIGHT', 'SKIN', '산타 부엉이', 'https://image.moabam.com/moabam/skins/owl/santa/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/santa/eyes-closed', 30, 15, 15, current_time());
'https://image.moabam.com/moabam/skins/owl/santa/eyes-closed.png', 30, 15, 15, current_time());

insert into product (id, type, name, price, quantity, created_at, updated_at)
values (null, 'BUG', '황금벌레x5', 3300, 5, current_time(), null);
values (null, 'BUG', '황금벌레x5', 3000, 5, current_time(), null);

insert into product (id, type, name, price, quantity, created_at, updated_at)
values (null, 'BUG', '황금벌레x10', 6600, 10, current_time(), null);
values (null, 'BUG', '황금벌레x10', 7000, 10, current_time(), null);

insert into product (id, type, name, price, quantity, created_at, updated_at)
values (null, 'BUG', '황금벌레x15', 9900, 15, current_time(), null);
values (null, 'BUG', '황금벌레x25', 9900, 25, current_time(), null);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0e97420

Please sign in to comment.