Skip to content

Commit

Permalink
Merge pull request #4 from Dongguk-ICE/dev
Browse files Browse the repository at this point in the history
🚀 [Deploy] - 프로젝트 초기 설정 배포
  • Loading branch information
JeongHeumChoi authored Apr 29, 2024
2 parents c4c99db + b8e0a0f commit 68536e5
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 106 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: deploy-actions

on:
push:
branches: [ "main" ]

jobs:
ci:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
submodules: true

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

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

- name: Build with Gradle
run: ./gradlew clean build -x test

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_PROD_REPONAME }}:0.0.1

cd:
needs: [ci]
runs-on: ubuntu-20.04

steps:
- name: Docker Image Pull And Container Run
uses: appleboy/[email protected]
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
port: ${{ 22 }}
script: |
sh /home/ubuntu/deploy.sh
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# Credentials
src/main/resources/application-prod.yml
src/main/resources/application-local.yml

.idea
HELP.md

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "startup-valley-properties"]
path = startup-valley-properties
url = https://github.com/JeongHeumChoi/spot-server-properties.git
branch = main
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/compiler.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/jarRepositories.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17-alpine
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar", "--spring.profiles.active=prod"]
28 changes: 0 additions & 28 deletions HELP.md

This file was deleted.

33 changes: 29 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,39 @@ repositories {
}

dependencies {
//database
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
runtimeOnly 'com.mysql:mysql-connector-j'

// spring security
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'

// spring boot
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.mysql:mysql-connector-j'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-validation'

// jwt
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'

//json
implementation 'net.minidev:json-smart:2.4.7'
}

task copyGitSubmodule(type: Copy) {
copy {
from './spot-server-properties'
include '*.yml'
into './src/main/resources'
}
}

tasks.named('test') {
Expand Down
5 changes: 5 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
./gradlew clean build -x test
docker buildx build --platform linux/amd64 --load --tag jeongheumchoi/spot-server:0.0.1 .
docker push jeongheumchoi/spot-server:0.0.1

1 change: 1 addition & 0 deletions spot-server-properties
Submodule spot-server-properties added at 6bf7ff
27 changes: 13 additions & 14 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
spring:
datasource:
url: "jdbc:mysql://localhost/spot"
username: "root"
password: "0731"
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
show_sql: true
format_sql: true
dialect: org.hibernate.dialect.MySQL8Dialect
spring.profiles.default: local

---

spring.config.activate.on-profile: local

---

spring.config.activate.on-profile: dev

---

spring.config.activate.on-profile: prod

0 comments on commit 68536e5

Please sign in to comment.