Skip to content

Commit

Permalink
Add Boilerplate code
Browse files Browse the repository at this point in the history
  • Loading branch information
pingowl committed Apr 8, 2024
0 parents commit 0e7e0d0
Show file tree
Hide file tree
Showing 61 changed files with 2,580 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Feature issue template
about: 이슈 템플릿
title: "[Feature] "
labels: feature
assignees: ''

---

## 🔨 Describe
-

## ✅ Tasks
- [ ]

## ▪ Etc
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## #️⃣연관된 이슈
- close #

## 📝작업 내용
-
## 💬리뷰 요구사항
108 changes: 108 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Java CI with Gradle

# 동작 조건 설정 : main 브랜치에 push가 발생할 경우 동작한다.
on:
push:
branches: [ "deploy" ]

permissions:
contents: read

jobs:
# Spring Boot 애플리케이션을 빌드하여 도커허브에 푸시하는 과정
build-docker-image:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

# 1. Java 세팅
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'

- name: make application.properties
run: |
cd ./src/main/resources
touch ./application.properties
# GitHub-Actions 에서 설정한 값을 application.properties 파일에 쓰기
echo "${{ secrets.APPLICATION_PROPERTIES }}" >> ./application.properties
shell: bash

# 환경 변수 설정 (Firebase)
# - name: create-json
# id: create-json
# uses: jsdaniell/[email protected]
# with:
# name: ${{ secrets.FIREBASE_JSON_FILENAME }}
# json: ${{ secrets.FIREBASE_JSON }}
# dir: 'src/main/resources'


# 2. Spring Boot 애플리케이션 빌드
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew bootJar -x test
# 3. Docker 이미지 빌드
- name: docker image build
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/github-actions-demo .

# 4. DockerHub 로그인
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

# 5. Docker Hub 이미지 푸시
- name: docker Hub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/drugbox-grad


# Deploy Images with Docker compose
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
env:
APP: "drugbox-grad "
COMPOSE: "/home/ubuntu/compose/docker-compose.yml"
with:
username: ubuntu
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
port: ${{ secrets.EC2_SSH_PORT }}
envs: APP, COMPOSE
script_stop: true
script: |
sudo docker-compose -f $COMPOSE down
sudo docker pull ${{ secrets.DOCKER_REPO }}/drugbox-grad
sudo docker-compose -f $COMPOSE up -d

# 위 과정에서 푸시한 이미지를 ec2에서 풀받아서 실행시키는 과정
run-docker-image-on-ec2:
# build-docker-image (위)과정이 완료되어야 실행됩니다.
needs: build-docker-image
runs-on: self-hosted

steps:
# 1. 최신 이미지를 풀받습니다
- name: docker pull
run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/drugbox-grad

# 2. 기존의 컨테이너를 중지시킵니다
- name: docker stop container
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true

# 3. 최신 이미지를 컨테이너화하여 실행시킵니다
- name: docker run new container
run: sudo docker run --name drugbox-grad --rm -d -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/drugbox-grad

# 4. 미사용 이미지를 정리합니다
- name: delete old docker image
run: sudo docker system 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/

### classpath ###
application.properties
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM openjdk:11

WORKDIR /usr/src/app

ARG JAR_PATH=./build/libs

COPY ${JAR_PATH}/demo-0.0.1-SNAPSHOT.jar ${JAR_PATH}/demo-0.0.1-SNAPSHOT.jar

CMD ["java","-jar","./build/libs/DrugBox-0.0.1-SNAPSHOT.jar"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Drugbox - Backend
Our project is a service that assists in the management of various pharmaceuticals within households and helps properly dispose of expired medications.

We provide guidelines for managing the inventory and expiration dates of over-the-counter and prescription medicines, as well as instructions on how to dispose of waste pharmaceuticals according to prescribed methods.

By utilizing this service, we aim to address various issues caused by improper disposal methods and, ultimately, reduce unnecessary consumption of pharmaceuticals to promote the well-being and health of individuals and the environment.
<br/><br/>
75 changes: 75 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.1.4'
}

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

java {
sourceCompatibility = '11'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'

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

// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation("org.junit.vintage:junit-vintage-engine") {
exclude group: "org.hamcrest", module: "hamcrest-core"
}

// Swagger
implementation 'io.springfox:springfox-boot-starter:3.0.0'

// Google Cloud Platform (GCP)
implementation 'org.springframework.cloud:spring-cloud-gcp-starter:1.2.5.RELEASE'
implementation 'com.google.api-client:google-api-client:1.32.1'
implementation 'com.google.oauth-client:google-oauth-client:1.32.1'
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.32.1'

// AWS S3
implementation platform('software.amazon.awssdk:bom:2.20.56')
implementation 'software.amazon.awssdk:s3'

// json
implementation 'com.googlecode.json-simple:json-simple:1.1.1'

// csv
implementation 'com.opencsv:opencsv:5.5'

// jwt
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2'

//redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file added dump.rdb
Binary file not shown.
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.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 0e7e0d0

Please sign in to comment.