Skip to content

Commit

Permalink
feat: walking-traffic 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 committed Sep 3, 2024
0 parents commit 331078f
Show file tree
Hide file tree
Showing 56 changed files with 2,074 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset=utf-8
end_of_line=lf
indent_style=space
indent_size=4
insert_final_newline=true
disabled_rules=no-wildcard-imports,import-ordering,comment-spacing

[*.{kt,kts}]
insert_final_newline=false
# enable trailing_comma
ij_kotlin_allow_trailing_comma=true
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
🎫 연관 티켓
---
#연관티켓이슈번호

🙏 작업
----
- 작업1
- 작업2

💁‍♂️ 어떻게?
----
- 작업1 어떻게?
- 작업2 어떻게?

🙈 PR 참고 사항
----
- 질문?
- 추가 티켓

📸 스크린샷
----

🤖 테스트 체크리스트
----
- [ ] 체크 미완료
- [x] 체크 완료
80 changes: 80 additions & 0 deletions .github/workflows/ecs_cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: DEV - Deploy to Amazon ECS

on:
push:
branches:
- main
- traffic
workflow_dispatch:
env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: tf-ecr
ECS_SERVICE: tf-ecs-service
ECS_CLUSTER: tf-ecs-cluster
ECS_TASK_DEFINITION: task-definition.json
TASK_DEFINITION_NAME: tf-ecs-task
CONTAINER_NAME: tf-container

jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: gradle

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle bootBuildImage, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
GIT_HASH=$(git rev-parse --short HEAD)
./gradlew buildDockerImage -PimageName=${ECR_REGISTRY}/${ECR_REPOSITORY}:latest
docker tag ${ECR_REGISTRY}/${ECR_REPOSITORY}:latest ${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH}
docker push ${ECR_REGISTRY}/${ECR_REPOSITORY} --all-tags
- name: Get ECR Repository image path
id: get-docker-image-path
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
GIT_HASH=$(git rev-parse --short HEAD)
echo ${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH}
echo "::set-output name=image::${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH}"
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition ${TASK_DEFINITION_NAME} --query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.get-docker-image-path.outputs.image }}

- name: Deploy Amazon ECS task definition
id: ecs-deployment
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-definition.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: lint

on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Test with Spotless
run: ./gradlew --info spotlessJavaCheck
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Kotlin ###
.kotlin
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM openjdk:18-oracle

RUN mkdir -p /logs

ENV PROFILE default
ENV TZ=Asia/Seoul
EXPOSE 8080

ARG JAVA_OPTS

ARG RELEASE_VERSION
ENV DD_VERSION=${RELEASE_VERSION}

ARG JAR_FILE="build/libs/walking-traffic-0.0.1-SNAPSHOT.jar"
COPY ${JAR_FILE} app.jar

ENTRYPOINT java -XX:MaxGCPauseMillis=100 -XX:InitialRAMPercentage=50.0 -XX:MaxRAMPercentage=80.0 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 $JAVA_OPTS -jar app.jar
115 changes: 115 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import java.util.*

plugins {
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.6"

kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
kotlin("plugin.jpa") version "1.9.25"
kotlin("plugin.allopen") version "1.9.25"
kotlin("kapt") version "1.9.25"
idea

id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
}

group = "com.walking"
version = "0.0.1-SNAPSHOT"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
}

/**
* https://kotlinlang.org/docs/reference/compiler-plugins.html#spring-support
* automatically supported annotation
* @Component, @Async, @Transactional, @Cacheable, @SpringBootTest,
* @Configuration, @Controller, @RestController, @Service, @Repository.
* jpa meta-annotations not automatically opened through the default settings of the plugin.spring
*/
allOpen {
annotation("javax.persistence.Entity")
annotation("javax.persistence.Embeddable")
annotation("javax.persistence.MappedSuperclass")
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-batch")
implementation("org.springframework.boot:spring-boot-starter-quartz")

implementation("com.mysql:mysql-connector-j")
implementation("org.hibernate:hibernate-spatial:6.6.0.Final")

implementation("org.quartz-scheduler:quartz")

implementation("org.apache.httpcomponents.client5:httpclient5")

implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")

implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.core:jackson-core")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.fasterxml.jackson.module:jackson-module-parameter-names")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
}

tasks.withType<Test> {
useJUnitPlatform()
}

val imageName = project.hasProperty("imageName").let {
if (it) {
project.property("imageName") as String
} else {
"app:local"
}
}
val releaseVersion = project.hasProperty("releaseVersion").let {
if (it) {
project.property("releaseVersion") as String
} else {
Random().nextInt(90000) + 10000
}
}

tasks.register("buildDockerImage") {
dependsOn("bootJar")

doLast {
exec {
workingDir(".")
commandLine(
"docker",
"build",
"-t",
imageName,
"--build-arg",
"RELEASE_VERSION=$releaseVersion",
'.'
)
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 331078f

Please sign in to comment.