-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- act시 사용한 시크릿 정보 .gitignore에 추가 - 배포 시 사용할 Procfile, .ebextensions, nginx.conf 파일 추가 - build.gradle.kts에 배포를 위한 설정들 변경 (jar 파일) - 그 외 PR Workflow 추가 - gradle build, test
- Loading branch information
Showing
7 changed files
with
191 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
files: | ||
"/sbin/appstart" : | ||
mode: "000755" | ||
owner: webapp | ||
group: webapp | ||
content: | | ||
#!/usr/bin/env bash | ||
JAR_PATH=/var/app/current/application.jar | ||
|
||
# run app | ||
killall java | ||
java -Dfile.encoding=UTF-8 -jar $JAR_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Deploy | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '21' | ||
distribution: 'adopt' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
shell: bash | ||
|
||
- name: Get current time | ||
uses: 1466587594/get-current-time@v2 | ||
id: current-time | ||
with: | ||
format: YYYY-MM-DDTHH-mm-ss | ||
utcOffset: "+09:00" | ||
|
||
- name: Get Tag Name | ||
id: get_tag_name | ||
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
|
||
- name: Get Short SHA | ||
id: get_short_sha | ||
run: echo "SHA=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | ||
|
||
# NOTE: jar task를 비활성화 했기 때문에, plain jar가 생성되지 않아 cp *.jar 실행 시 app.jar 파일이 생성된다. | ||
- name: Generate deployment package | ||
run: | | ||
mkdir -p deploy | ||
cp build/libs/*.jar deploy/application.jar | ||
cp Procfile deploy/Procfile | ||
cp -r .ebextensions deploy/.ebextensions | ||
cp -r .platform deploy/.platform | ||
cd deploy && zip -r deploy.zip . | ||
- name: Deploy to EB | ||
uses: einaregilsson/beanstalk-deploy@v21 | ||
with: | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
application_name: ${{ secrets.EB_APP_NAME }} | ||
environment_name: ${{ secrets.EB_ENV_NAME }} | ||
version_label: github-action-${{steps.current-time.outputs.formattedTime}}-${{ steps.get_tag_name.outputs.TAG }}-${{ steps.get_short_sha.outputs.SHA }} | ||
region: ap-northeast-2 # 한국으로 region 변경 | ||
deployment_package: deploy/deploy.zip | ||
wait_for_environment_recovery: 300 # 30초는 너무 짧아 300초로 변경 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Pull Request Workflow | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'adopt' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
shell: bash | ||
|
||
- name: Test with Gradle | ||
run: ./gradlew test | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,6 @@ out/ | |
|
||
### Http Client ENVS ### | ||
http-client.private.env.json | ||
|
||
### Act Env File ### | ||
my.secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
user nginx; | ||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
worker_processes auto; | ||
worker_rlimit_nofile 33282; | ||
|
||
events { | ||
use epoll; | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
include conf.d/*.conf; | ||
|
||
map $http_upgrade $connection_upgrade { | ||
default "upgrade"; | ||
} | ||
|
||
upstream springboot { | ||
server 127.0.0.1:8080; | ||
keepalive 1024; | ||
} | ||
|
||
server { | ||
listen 80 default_server; | ||
|
||
location / { | ||
proxy_pass http://springboot; | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection $connection_upgrade; | ||
proxy_set_header Upgrade $http_upgrade; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
client_header_timeout 60; | ||
client_body_timeout 60; | ||
keepalive_timeout 60; | ||
gzip off; | ||
gzip_comp_level 4; | ||
|
||
# Include the Elastic Beanstalk generated locations | ||
include conf.d/elasticbeanstalk/healthd.conf; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: appstart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,50 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
id("org.springframework.boot") version "3.3.0" | ||
id("io.spring.dependency-management") version "1.1.5" | ||
kotlin("jvm") version "1.9.24" | ||
kotlin("plugin.spring") version "1.9.24" | ||
id("org.springframework.boot") version "3.3.0" | ||
id("io.spring.dependency-management") version "1.1.5" | ||
kotlin("jvm") version "1.9.24" | ||
kotlin("plugin.spring") version "1.9.24" | ||
} | ||
|
||
group = "dev.jxmen" | ||
version = "0.0.1-SNAPSHOT" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_21 | ||
sourceCompatibility = JavaVersion.VERSION_21 | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf") | ||
implementation("org.springframework.boot:spring-boot-starter-web") | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf") | ||
implementation("org.springframework.boot:spring-boot-starter-web") | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
|
||
developmentOnly("org.springframework.boot:spring-boot-devtools") | ||
developmentOnly("org.springframework.boot:spring-boot-devtools") | ||
|
||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
} | ||
|
||
kotlin { | ||
compilerOptions { | ||
freeCompilerArgs.addAll("-Xjsr305=strict") | ||
jvmTarget = JvmTarget.JVM_21 | ||
} | ||
compilerOptions { | ||
freeCompilerArgs.addAll("-Xjsr305=strict") | ||
jvmTarget = JvmTarget.JVM_21 | ||
} | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
useJUnitPlatform() | ||
} | ||
|
||
tasks.jar { | ||
enabled = false // plain jar 파일 생성 비활성화 | ||
} | ||
|
||
tasks.bootJar { | ||
archiveFileName.set("app.jar") | ||
} |