diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..26eb6a3 --- /dev/null +++ b/.github/workflows/integration.yml @@ -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 + \ No newline at end of file diff --git a/pnu-book-store-batch/Dockerfile b/pnu-book-store-batch/Dockerfile new file mode 100644 index 0000000..6f46ba6 --- /dev/null +++ b/pnu-book-store-batch/Dockerfile @@ -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"] \ No newline at end of file diff --git a/pnu-book-store-batch/build.gradle b/pnu-book-store-batch/build.gradle index 4a18578..624072b 100644 --- a/pnu-book-store-batch/build.gradle +++ b/pnu-book-store-batch/build.gradle @@ -38,3 +38,14 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + + +bootJar { + archiveBaseName = 'batch' + archiveFileName = 'batch.jar' + archiveVersion = "0.0.1" +} + +jar { + enabled = false +} \ No newline at end of file diff --git a/pnu-book-store-batch/src/main/resources/application-dev.yml b/pnu-book-store-batch/src/main/resources/application-dev.yml new file mode 100644 index 0000000..c725e5f --- /dev/null +++ b/pnu-book-store-batch/src/main/resources/application-dev.yml @@ -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 \ No newline at end of file diff --git a/pnu-book-store-batch/src/main/resources/application-prod.yml b/pnu-book-store-batch/src/main/resources/application-prod.yml new file mode 100644 index 0000000..b85e864 --- /dev/null +++ b/pnu-book-store-batch/src/main/resources/application-prod.yml @@ -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 \ No newline at end of file diff --git a/pnu-book-store-batch/src/main/resources/application.yml b/pnu-book-store-batch/src/main/resources/application.yml index c725e5f..3d7808a 100644 --- a/pnu-book-store-batch/src/main/resources/application.yml +++ b/pnu-book-store-batch/src/main/resources/application.yml @@ -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 \ No newline at end of file + profiles: + active: dev