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
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
pull_request:
branches: [ "dev" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up JDK 21
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '21'
cache: gradle

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

- name: Build with Gradle
run: ./gradlew clean build
47 changes: 47 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI/CD

on:
push:
branches: [ "dev" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker image
if: github.ref == 'refs/heads/dev'
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROD_IMAGE_NAME }}:latest
platforms: linux/amd64

deploy:
runs-on: ubuntu-latest
needs: build

steps:
- name: SSH to Server and Deploy
if: github.ref == 'refs/heads/dev'
uses: appleboy/[email protected]
with:
host: ${{ secrets.PROD_SERVER_HOST }}
port: ${{ secrets.PROD_SERVER_PORT }}
username: ${{ secrets.PROD_SERVER_USERNAME }}
key: ${{ secrets.PROD_SERVER_KEY }}
script: |
cd /home/ubuntu/dasom
mkdir -p ./env
echo "${{ secrets.ENV }}" > ./env/prodEnv
./deploy.sh
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM gradle:8.12.1-jdk21-alpine AS build
WORKDIR /home/gradle/project

COPY build.gradle settings.gradle ./
COPY gradle gradle/

COPY src src

RUN gradle clean build

FROM eclipse-temurin:21-jre-alpine
WORKDIR /app

COPY --from=build /home/gradle/project/build/libs/dmu-dasom-api.jar api.jar

ENTRYPOINT ["java", "-Dspring.profiles.active=default,credentials", "-jar", "api.jar"]
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.oracle.database.jdbc:ojdbc11'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/application-credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring:
datasource:
url: ${DB_URL}
driver-class-name: oracle.jdbc.OracleDriver
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
jpa:
hibernate:
ddl-auto: ${DDL_AUTO}
show-sql: ${SHOW_SQL}
properties:
hibernate:
dialect: org.hibernate.dialect.OracleDialect
9 changes: 0 additions & 9 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,3 @@ server:
spring:
application:
name: dasom-api
datasource:
url: ${DB_URL}
driver-class-name: oracle.jdbc.OracleDriver
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
jpa:
hibernate:
ddl-auto: update
show-sql: true