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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: "🛠Feat Template"
about: 신규 기능 구현을 위한 이슈 템플릿입니다.
title: "[Feat]: "
labels: ""
assignees: ''
---

**Issue**
- 이슈 내용: `ex) 로그인 관련 기능`

**Branch Name**
- 생성 브랜치 이름 : `ex) feat/login`

**To-Do List**
- [ ] `ex) 로그인 구현`
- [ ] `ex) 회원가입 구현`
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: "🔨Fix Template"
about: 버그 수정을 위한 이슈 템플릿입니다.
title: "[Fix]: "
labels: ""
assignees: ''
---

**Issue**
- 이슈 내용: `ex) 로그인 버그 수정`

**Branch Name**
- 생성 브랜치 이름 : `ex) fix/login`

**To-Do List**
- [ ] `ex) 로그인 버그 수정`
- [ ] `ex) 회원가입 버그 수정`
25 changes: 25 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## ✅ 이슈 번호

<!--이슈 태스크를 모두 완료하고 닫는다면 Resolves #번호-->
<!--이슈 태스크를 모두 완료하지는 못 했지만 닫는다면 Closes #번호-->
<!--이슈 태스크를 일부 완료하고 열어둔다면 Fixes #번호-->

## 👩‍💻 구현 내용

<!--빠른 리뷰를 위해 이해를 도울 만한 설명이 있다면 적어주세요-->

- [ ] `구현 사항`

## ✍ 테스트 방법

<!--진행한 테스트를 작성해주세요-->

- [ ] `테스트 사항`

## 💬 코멘트

<!--PR 올리면서 팀원들에게 공유할 사항 및 리뷰 받고 싶은 부분이 있다면 적어주세요-->

## 💭 고려한 점

<!--개발하면서 고려한 부분이 있다면 작성해주세요, 없다면 지우고 PR 남겨주세요-->
84 changes: 84 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: 대피로 Docker Image CI/CD

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: 🧾 Checkout source
uses: actions/checkout@v4

- name: ☕ Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: ⚙️ Create application.yml
run: |
mkdir -p src/main/resources
cat <<EOF > src/main/resources/application.yml
spring:
profiles:
active: \${PROFILES_ACTIVE}
EOF

- name: 🛠 Grant gradle permission
run: chmod +x gradlew

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

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

- name: 📦 Build & Push Docker Image
run: |
docker build -t ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }}:latest .
docker push ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }}:latest

- name: 🚚 Upload deploy.sh to EC2
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.AWS_HOST }}
username: ubuntu
key: ${{ secrets.AWS_KEY }}
port: ${{ secrets.AWS_PORT }}
source: "scripts/deploy.sh"
target: "/home/ubuntu/"

- name: 🚚 Upload docker-compose.yml to EC2
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.AWS_HOST }}
username: ubuntu
key: ${{ secrets.AWS_KEY }}
port: ${{ secrets.AWS_PORT }}
source: "docker-compose.yml"
target: "/home/ubuntu/"

- name: 🚀 Deploy on EC2
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.AWS_HOST }}
username: ubuntu
key: ${{ secrets.AWS_KEY }}
port: ${{ secrets.AWS_PORT }}
script: |
sudo docker pull ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }}:latest
chmod +x /home/ubuntu/deploy.sh
sudo /home/ubuntu/deploy.sh
sudo docker image prune -f
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Secret ###
src/main/resources/application.properties
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ===============================
# 대피로 Spring Boot Dockerfile
# Java 21 / Spring Boot 3.3.3
# ===============================
FROM eclipse-temurin:21-jdk-jammy
ENV TZ=Asia/Seoul
WORKDIR /app
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
50 changes: 50 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com.numberone'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

repositories {
mavenCentral()
}

dependencies {

// ====================================== prod ======================================
// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'

// db
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation "com.mysql:mysql-connector-j"

// web
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

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

// junit
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
}
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3.8"

services:
daepiro:
image: ${DOCKER_REPOSITORY}/${DOCKER_IMAGE}:latest
container_name: daepiro
restart: always
ports:
- "8080:8080"
env_file:
- .env
environment:
PROFILES_ACTIVE: ${PROFILES_ACTIVE}

DB_URL: ${DB_URL}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}

JAVA_OPTS: >
-Xms256m
-Xmx512m
-Dfile.encoding=UTF-8

command: >
java $JAVA_OPTS -jar /app/app.jar
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading