Skip to content

Commit

Permalink
Feat: Implment CI Code For Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Train0303 committed May 30, 2024
1 parent f161922 commit 50e83c7
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 25 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Make Image

on:
push:
branches:
- main

env:
IMAGE_TAG: latest

defaults:
run:
working-directory: pnu-book-store-batch
jobs:
deploy:
runs-on: ubuntu-latest

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

- name: Login to NCP Registry
id: login_registry
run: |
docker login ${{ secrets.REGISTRY }} --username ${{ secrets.ACCESS_TOKEN }} --password ${{ secrets.SECRET_TOKEN }}
- name: Docker Build
run: |
docker build -t ${{ secrets.REGISTRY }}/${{secrets.REPOSITORY}}:$IMAGE_TAG .
docker push ${{ secrets.REGISTRY }}/${{secrets.REPOSITORY}}:$IMAGE_TAG
18 changes: 18 additions & 0 deletions pnu-book-store-batch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 1. build
FROM gradle:7.5.1-jdk17 as build

WORKDIR /home/gradle/project

COPY . .

RUN gradle wrapper
RUN ./gradlew clean build -x test

# 2. Run the application
FROM eclipse-temurin:17-jdk-jammy

WORKDIR /opt/batch

COPY --from=build /home/gradle/project/build/libs/batch.jar .

CMD ["java", "-Dspring.profiles.active=prod", "-jar", "batch.jar"]
11 changes: 11 additions & 0 deletions pnu-book-store-batch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}


bootJar {
archiveBaseName = 'batch'
archiveFileName = 'batch.jar'
archiveVersion = "0.0.1"
}

jar {
enabled = false
}
26 changes: 26 additions & 0 deletions pnu-book-store-batch/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
spring:
datasource:
url: jdbc:mysql://localhost:3306/cloudteam18?use_ssl=false
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: qwer1234

jpa:
hibernate:
ddl-auto: validate
show-sql: true
database-platform: org.hibernate.dialect.MySQLDialect
properties:
hibernate:
format_sql: true
default_batch_fetch_size: 100
open-in-view: false

application:
name: PnuBookStoreBatchApplication

batch:
jdbc:
initialize-schema: always
job:
enabled: false
26 changes: 26 additions & 0 deletions pnu-book-store-batch/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
spring:
datasource:
url: ${DATABASE_URI}
driver-class-name: com.mysql.cj.jdbc.Driver
username: ${DATABASE_USERNAME}
password: ${DATABASE_PASSWORD}

jpa:
hibernate:
ddl-auto: none
show-sql: false
database-platform: org.hibernate.dialect.MySQLDialect
properties:
hibernate:
format_sql: false
default_batch_fetch_size: 100
open-in-view: false

application:
name: PnuBookStoreBatchApplication

batch:
jdbc:
initialize-schema: always
job:
enabled: false
27 changes: 2 additions & 25 deletions pnu-book-store-batch/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
spring:
datasource:
url: jdbc:mysql://localhost:3306/cloudteam18?use_ssl=false
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: qwer1234

jpa:
hibernate:
ddl-auto: validate
show-sql: true
database-platform: org.hibernate.dialect.MySQLDialect
properties:
hibernate:
format_sql: true
default_batch_fetch_size: 100
open-in-view: false

application:
name: PnuBookStoreBatchApplication

batch:
jdbc:
initialize-schema: always
job:
enabled: false
profiles:
active: dev

0 comments on commit 50e83c7

Please sign in to comment.