Skip to content
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
71 changes: 71 additions & 0 deletions .github/workflows/_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: deploy-template

on:
workflow_call:
inputs:
ocir_repository:
required: true
type: string
dockerfile:
required: true
type: string
description: "Dockerfile path (e.g., Dockerfile, batch/Dockerfile)"
gradle_task:
required: true
type: string
description: "Gradle task to build the jar (e.g., :bootJar, :batch:bootJar)"
platform:
required: false
type: string
default: "linux/arm64"
secrets:
OCI_AUTH_TOKEN:
required: true
DEPLOYER_APP_ID:
required: true
DEPLOYER_APP_PRIVATE_KEY:
required: true

jobs:
deploy:
name: Build and Push
runs-on: ubuntu-24.04-arm

env:
IMAGE_TAG: ${{ github.run_number }}
BUILD_NUMBER: ${{ github.run_number }}
OCIR_REGISTRY: yny.ocir.io
OCIR_NAMESPACE: ax1dvc8vmenm
OCIR_USERNAME: ax1dvc8vmenm/members/waffle-deployer
OCIR_REPOSITORY: ${{ inputs.ocir_repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: gradle

- name: Build Jar
working-directory: hangsha
run: ./gradlew ${{ inputs.gradle_task }}

- name: Login to OCIR
run: echo "${{ secrets.OCI_AUTH_TOKEN }}" | docker login $OCIR_REGISTRY -u $OCIR_USERNAME --password-stdin

- name: Docker build, tag, and push image to OCIR
id: build-push-image
working-directory: hangsha
run: |
docker build \
-f ${{ inputs.dockerfile }} \
-t $OCIR_REGISTRY/$OCIR_NAMESPACE/$OCIR_REPOSITORY:$IMAGE_TAG \
. \
--platform ${{ inputs.platform }}
docker push $OCIR_REGISTRY/$OCIR_NAMESPACE/$OCIR_REPOSITORY:$IMAGE_TAG
echo "image=$OCIR_REGISTRY/$OCIR_NAMESPACE/$OCIR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
17 changes: 17 additions & 0 deletions .github/workflows/deploy-api-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy-api-dev

on:
push:
branches: [ develop ]

jobs:
deploy:
uses: ./.github/workflows/_deploy.yml
with:
ocir_repository: hangsha-dev/hangsha-server
dockerfile: Dockerfile
gradle_task: :bootJar
secrets:
OCI_AUTH_TOKEN: ${{ secrets.OCI_AUTH_TOKEN }}
DEPLOYER_APP_ID: ${{ secrets.DEPLOYER_APP_ID }}
DEPLOYER_APP_PRIVATE_KEY: ${{ secrets.DEPLOYER_APP_PRIVATE_KEY }}
17 changes: 17 additions & 0 deletions .github/workflows/deploy-api-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy-api-prod

on:
push:
branches: [ main ]

jobs:
deploy:
uses: ./.github/workflows/_deploy.yml
with:
ocir_repository: hangsha-prod/hangsha-server
dockerfile: Dockerfile
gradle_task: :bootJar
secrets:
OCI_AUTH_TOKEN: ${{ secrets.OCI_AUTH_TOKEN }}
DEPLOYER_APP_ID: ${{ secrets.DEPLOYER_APP_ID }}
DEPLOYER_APP_PRIVATE_KEY: ${{ secrets.DEPLOYER_APP_PRIVATE_KEY }}
17 changes: 17 additions & 0 deletions .github/workflows/deploy-batch-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy-batch-dev

on:
push:
branches: [ develop ]

jobs:
deploy:
uses: ./.github/workflows/_deploy.yml
with:
ocir_repository: hangsha-dev/hangsha-batch
dockerfile: batch/Dockerfile
gradle_task: :batch:bootJar
secrets:
OCI_AUTH_TOKEN: ${{ secrets.OCI_AUTH_TOKEN }}
DEPLOYER_APP_ID: ${{ secrets.DEPLOYER_APP_ID }}
DEPLOYER_APP_PRIVATE_KEY: ${{ secrets.DEPLOYER_APP_PRIVATE_KEY }}
17 changes: 17 additions & 0 deletions .github/workflows/deploy-batch-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy-batch-prod

on:
push:
branches: [ main ]

jobs:
deploy:
uses: ./.github/workflows/_deploy.yml
with:
ocir_repository: hangsha-prod/hangsha-batch
dockerfile: batch/Dockerfile
gradle_task: :batch:bootJar
secrets:
OCI_AUTH_TOKEN: ${{ secrets.OCI_AUTH_TOKEN }}
DEPLOYER_APP_ID: ${{ secrets.DEPLOYER_APP_ID }}
DEPLOYER_APP_PRIVATE_KEY: ${{ secrets.DEPLOYER_APP_PRIVATE_KEY }}
99 changes: 0 additions & 99 deletions .github/workflows/deploy.yml

This file was deleted.

12 changes: 7 additions & 5 deletions hangsha/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM eclipse-temurin:17-jdk-alpine
FROM eclipse-temurin:17-jdk

WORKDIR /app

# 컨테이너 기본 타임존을 KST로 맞추기
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
&& echo "Asia/Seoul" > /etc/timezone
RUN apt-get update \
&& apt-get install -y --no-install-recommends tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
&& echo "Asia/Seoul" > /etc/timezone \
&& rm -rf /var/lib/apt/lists/*

ENV TZ=Asia/Seoul

ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-jar", "/app/app.jar"]
ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-jar", "/app/app.jar"]
17 changes: 17 additions & 0 deletions hangsha/batch/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ java {

repositories {
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/wafflestudio/spring-waffle")
credentials {
username = "wafflestudio"
password = findProperty("gpr.key") as String?
?: System.getenv("GITHUB_TOKEN")
?: runCatching {
ProcessBuilder("gh", "auth", "token")
.start()
.inputStream
.bufferedReader()
.readText()
.trim()
}.getOrDefault("")
}
}
}

dependencies {
implementation(project(":common"))
implementation("com.wafflestudio.spring:spring-boot-starter-waffle-oci-vault:1.1.0")

implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.team1.hangsha.batch

import com.team1.hangsha.config.DatabaseConfig
import com.team1.hangsha.config.TestValueLogger
import com.team1.hangsha.com.team1.hangsha.config.JacksonConfig
import com.team1.hangsha.event.service.EventSyncService
import org.springframework.boot.WebApplicationType
Expand All @@ -13,7 +14,8 @@ import org.springframework.context.annotation.Import
DatabaseConfig::class,
JacksonConfig::class,
EventSyncService::class,
)
TestValueLogger::class,
) // for explicit bean import
class BatchApplication

fun main(args: Array<String>) {
Expand Down
4 changes: 3 additions & 1 deletion hangsha/batch/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
jackson:
time-zone: Asia/Seoul
time-zone: Asia/Seoul

test:
19 changes: 19 additions & 0 deletions hangsha/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,29 @@ configurations {

repositories {
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/wafflestudio/spring-waffle")
credentials {
username = "wafflestudio"
password = findProperty("gpr.key") as String?
?: System.getenv("GITHUB_TOKEN")
?: runCatching {
ProcessBuilder("gh", "auth", "token")
.start()
.inputStream
.bufferedReader()
.readText()
.trim()
}.getOrDefault("")
}
}
}

dependencies {
implementation(project(":common"))
implementation("com.wafflestudio.spring:spring-boot-starter-waffle-oci-vault:1.1.0")
implementation("com.oracle.oci.sdk:oci-java-sdk-objectstorage:3.80.1")
// TODO: common의 dependency를 root api, batch에 공유하는 과정에서 문제 -> 나중에 해결하기.

implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework.boot:spring-boot-starter-validation")
Expand Down
6 changes: 6 additions & 0 deletions hangsha/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ repositories {
mavenCentral()
}



dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework:spring-web")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation(kotlin("stdlib"))

// oci sdk for storage service
implementation("com.oracle.oci.sdk:oci-java-sdk-objectstorage:3.80.1")
implementation("com.oracle.oci.sdk:oci-java-sdk-common-httpclient-jersey3:3.80.1")

}

kotlin {
Expand Down
Loading
Loading