Skip to content

Commit

Permalink
Merge pull request #30 from KNU-HAEDAL-Website/chore-dockerhub-cicd-i…
Browse files Browse the repository at this point in the history
…ssue-23

chore: main에 push시 build및 docker-hub push
  • Loading branch information
tfer2442 authored May 9, 2024
2 parents 3a6b99e + ace3e69 commit 606cc69
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 14 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docker-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Backend CI

on:
push:
branches: [ main ]

jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

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

- name: Spring Boot Build
run: ./gradlew clean build

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/haedal-web
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
application-db.properties
application-jwt.properties
.env

.idea
*.iws
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:17
ARG JAR_FILE=*.jar
ARG JAR_FILE=./build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ repositories {
}

dependencies {

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
implementation 'io.jsonwebtoken:jjwt-impl:0.12.3'
Expand Down
23 changes: 13 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ services:
- haedal-mysql
- haedal-redis
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://haedal-mysql:3306/haedal?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true
SPRING_DATASOURCE_USERNAME: user
SPRING_DATASOURCE_PASSWORD: 7854
SPRING_DATA_REDIS_HOST: haedal-redis
SPRING_DATA_REDIS_PORT: 6379
SPRING_DATA_REDIS_PASSWORD: 7854
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL}
SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME}
SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD}
SPRING_DATA_REDIS_HOST: ${SPRING_DATA_REDIS_HOST}
SPRING_DATA_REDIS_PORT: ${SPRING_DATA_REDIS_PORT}
SPRING_DATA_REDIS_PASSWORD: ${SPRING_DATA_REDIS_PASSWORD}
SPRING_JWT_SECRET_KEY: ${SPRING_JWT_SECRET_KEY}
haedal-mysql:
image: mysql:8.0.36
volumes:
- db-data:/var/lib/mysql
environment:
MYSQL_DATABASE: haedal
MYSQL_USER: user
MYSQL_PASSWORD: 7854
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
TZ: Asia/Seoul
ports:
- "3306:3306"
haedal-redis:
image: redis:7.2-alpine
command: redis-server --requirepass ${SPRING_DATA_REDIS_PASSWORD} --port 6379
ports:
- "6379:6379"

Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/application-db.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spring.data.redis.host=${SPRING_DATA_REDIS_HOST}
spring.data.redis.port=${SPRING_DATA_REDIS_PORT}
spring.data.redis.password=${SPRING_DATA_REDIS_PASSWORD}

spring.datasource.url=${SPRING_DATASOURCE_URL}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
spring.jpa.hibernate.ddl-auto=update


1 change: 1 addition & 0 deletions src/main/resources/application-jwt.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spring.jwt.secret=${SPRING_JWT_SECRET_KEY}
5 changes: 4 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
spring.profiles.include=db, jwt
spring.profiles.include=db, jwt

#logging.level.org.springframework=DEBUG
#spring.mvc.log-request-details=true

0 comments on commit 606cc69

Please sign in to comment.