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

[CHORE] 스프링부트 배포 파이프라인 완료 #11

Merged
merged 8 commits into from
Aug 28, 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
31 changes: 7 additions & 24 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,16 @@ jobs:
- name: create application.yml in domain
run: touch ./q-domain/src/main/resources/application-prod.yml
&& echo "${{secrets.APPLICATION_DOMAIN}}" > ./q-domain/src/main/resources/application-prod.yml

- name: create application.yml in api
run: touch ./q-api/src/main/resources/application.yml
&& echo "${{secrets.APPLICATION_API}}" > ./q-api/src/main/resources/application.yml

- name: create application.yml in common
run: touch ./q-common/src/main/resources/application-common.yml
&& echo "${{secrets.APPLICATION_COMMON}}" > ./q-common/src/main/resources/application-common.yml

- name: create application.yml in admin
run: touch ./q-admin/src/main/resources/application-admin.yml
&& echo "${{secrets.APPLICATION_ADMIN}}" > ./q-admin/src/main/resources/application-admin.yml
&& echo "${{secrets.APPLICATION_ADMIN}}" > ./q-admin/src/main/resources/application-admin.yml

- uses: actions/upload-artifact@v2
with:
name: application-domain.yml
path: ./q-domain/src/main/resources/application-prod.yml

- uses: actions/upload-artifact@v2
with:
name: application.yml
path: ./q-api/src/main/resources/application.yml

- uses: actions/upload-artifact@v2
with:
name: application.yml
path: ./q-common/src/main/resources/application-common.yml

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -96,9 +79,9 @@ jobs:
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ secrets.S3_BUCKET_NAME }}/deploy-spring/$GITHUB_SHA.zip --source .

#- name: Code Deploy
# run: aws deploy create-deployment --application-name ${{ secrets.CODE_DEPLOY_APP_NAME }}
# --deployment-config-name CodeDeployDefault.OneAtATime
# --deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }}
# --s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=deploy/$GITHUB_SHA.zip
- name: Code Deploy
run: aws deploy create-deployment --application-name ${{ secrets.CODE_DEPLOY_APP_NAME }}
--deployment-config-name CodeDeployDefault.OneAtATime
--deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }}
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=deploy-spring/$GITHUB_SHA.zip

9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM azul/zulu-openjdk:17

ARG JAR_FILE=./q-api/build/libs/*.jar

COPY ${JAR_FILE} app.jar

EXPOSE 8080

ENTRYPOINT ["java","-jar","app.jar"]
32 changes: 32 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 0.0

# 서버의 운영 체제
os: linux

# 코드 파일 전송과 관련된 설정
files:
# 코드 파일의 소스 경로
- source: /
# 코드 파일의 대상 경로
destination: /home/ubuntu/qcard
# 덮어쓰기 허용
overwrite: yes

# 파일 및 디렉토리 권한에 관련된 설정
permissions:
# 권한을 설정할 대상 경로
- object: /
# 모든 파일 및 디렉토리를 의미
pattern: "**"
owner: ubuntu
group: ubuntu

hooks:
AfterInstall:
- location: scripts/stop.sh
timeout: 180
runas: ubuntu
ApplicationStart:
- location: scripts/deploy.sh
timeout: 180
runas: ubuntu
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ repositories {
mavenCentral()
}

bootJar.enabled = false

subprojects {
group = 'com.qcard'
version = '0.0.1-SNAPSHOT'
Expand Down
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion q-admin/src/main/java/com/qcard/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
auth.requestMatchers(antMatcher("/h2-dev/**")).permitAll()
.requestMatchers(antMatcher("/questions/**")).permitAll()
.requestMatchers(antMatcher("/accounts/signup"), antMatcher("/accounts/signin")).permitAll()
.anyRequest().authenticated()
.anyRequest().permitAll()
)
.apply(new JwtSecurityConfig(jwtUtil));

Expand Down
10 changes: 10 additions & 0 deletions q-admin/src/main/resources/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>

</body>
</html>
2 changes: 1 addition & 1 deletion q-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
spring:
profiles:
active:
- devs
- prods
- admin
group:
devs:
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
REPOSITORY=/home/ubuntu/qcard
cd $REPOSITORY

echo "> 도커 이미지 빌드"
sudo docker build -t qcard-image .

echo "> 도커 컨테이너 올리기"
sudo docker run -d --name qcard -p 80:8080 qcard-image
9 changes: 9 additions & 0 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CURRENT_CONTAINER=$(sudo docker ps -f "name=qcard")

if [ -z $CURRENT_CONTAINER ]
then
echo "> 현재 실행중인 도커 컨테이너가 없습니다."
else
echo "> kill -15 $CURRENT_CONTAINER"
sudo docker rm -f qcard
fi
Loading