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
103 changes: 91 additions & 12 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,91 @@
## github repository actions νŽ˜μ΄μ§€μ— λ‚˜νƒ€λ‚  이름
#name: EatPic CI/CD (using github actions & docker)
#
#on:
# pull_request:
# types: [closed]
# workflow_dispatch: # (2).μˆ˜λ™ 싀행도 κ°€λŠ₯ν•˜λ„λ‘
#
#jobs:
# build:
# runs-on: ubuntu-latest # (3).OSν™˜κ²½
# if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop'
# github repository actions νŽ˜μ΄μ§€μ— λ‚˜νƒ€λ‚  이름
name: EatPic CI/CD (using github actions & docker)

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

permissions:
contents: read

jobs:
CI-CD:
runs-on: ubuntu-latest
permissions:
contents: read

steps:

## jdk setting
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'


## gradle caching
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

## create application.yml
- name: make application.yml
if: contains(github.ref, 'main')
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
touch application.yml
echo "${{ secrets.YML_DEV }}" > application.yml
shell: bash

- name: Grant Execute Permission For Gradlew
run: chmod +x gradlew

## docker build & push
- name: docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/eatpic .
docker push ${{ secrets.DOCKER_USERNAME }}/eatpic:latest

## docker deploy
- name: Deploy to dev
uses: appleboy/ssh-action@master
id: deploy-dev
# if: contains(github.ref, 'develop')
if : contains(github.ref,'main')
with:
key: ${{ secrets.PRIVATE_KEY }}
host: ${{ secrets.HOST_DEV }}
username: ${{ secrets.USERNAME }}
port: 22
script: |
docker rm -f $(docker ps -qa)
docker pull ${{ secrets.DOCKER_USERNAME }}/eatpic
docker-compose up -d
docker image prune -f

## time
current-time:
needs: CI-CD
runs-on: ubuntu-latest
steps:
- name: Get Current Time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH:mm:ss
utcOffset: "+09:00"
- name: Print Current Time
run: echo "Current Time=${{steps.current-time.outputs.formattedTime}}"
shell: bash
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ out/

### VS Code ###
.vscode/

*/application.yml
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# λΉŒλ“œ 단계
FROM openjdk:17-jdk-slim as build
WORKDIR /app
COPY . .
RUN ./gradlew clean build
FROM openjdk:17-jdk-slim
WORKDIR /app

# νƒ€μž„μ‘΄ μ„€μ •
ENV TZ=Asia/Seoul
RUN apt-get update && apt-get install -y tzdata && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
apt-get clean

COPY --from=build /app/build/libs/*.jar app.jar
EXPOSE 8080

# JVM νƒ€μž„μ‘΄ μ„€μ • μΆ”κ°€
ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-jar", "app.jar"]
1 change: 1 addition & 0 deletions src/main/java/EatPic/spring/domain/card/entity/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class Card extends BaseEntity {
private List<CardHashtag> cardHashtags = new ArrayList<>();

// μ‚­μ œ μ—¬λΆ€ (Soft Delete μš©λ„)
@Builder.Default
@Column(name = "is_deleted", nullable = false)
private boolean isDeleted = false;

Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/application-jwt.yml

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

15 changes: 9 additions & 6 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
spring:
application:
name: backend
name: spring
jpa:
show-sql: false
generate-ddl: true
properties:
hibernate:
hbm2ddl:
auto: update
auto: update # 계속 update μœ μ§€
format_sql: false
use_sql_comments: true
default_batch_fetch_size: 1000
dialect: org.hibernate.dialect.MySQLDialect
database: mysql
datasource:
url: jdbc:mysql://localhost:3306/eatpic_db
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
url: jdbc:mysql://eatpic-database.cxg2668gsj4t.ap-northeast-2.rds.amazonaws.com:3306/eatpic_db?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
username: eatpic
password: eatpic123***
driver-class-name: com.mysql.cj.jdbc.Driver
jwt:
secret: EatPic2025@JWTToken!SecureKey
access-token-validity: 3600000
profiles:
include:
- database
- swagger
- jwt
- s3
- s3
1 change: 1 addition & 0 deletions src/test/java/EatPic/spring/ApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest
class ApplicationTests {
Expand Down
Loading