Skip to content

Commit

Permalink
refactor : 머지 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
GaBaljaintheroom committed Jul 11, 2024
2 parents a18ee4e + 893e183 commit 3b1809f
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 7 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/showpot-dev-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: ShowPot-Dev-CD

on:
push:
branches:
- develop

jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'liberica'
cache: gradle

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Copy Secrets
env:
ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
run:
echo $ACCESS_KEY > ./app/src/main/resources/application-dev.yml
echo $SECRET_KEY > ./app/src/main/resources/application-dev.yml

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

- name: Prepare File for Deployment
run: |
mkdir -p deployment
cp Dockerfile docker-compose.yml deployment/
cp -r ./app/build/libs deployment/
- name: Get Github Actions IP
id: ip
uses: haythem/[email protected]

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

- name: Add Github Actions IP on Security Group
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_DEV_SECURITY_GROUP_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Upload files to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_DEV_HOST }}
username: ec2-user
key: ${{ secrets.EC2_DEV_SSH_PRIVATE_KEY }}
source: "deployment/*"
target: "/home/ec2-user/"

- name: Deploy using Docker Compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_DEV_HOST }}
username: ec2-user
key: ${{ secrets.EC2_DEV_SSH_PRIVATE_KEY }}
script: |
cd /home/ec2-user/deployment/
docker-compose down
docker-compose up -d --build
- name: Remove Github Actions IP from Security Group
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_DEV_SECURITY_GROUP_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Backend CD for Dev Server Discord Notification
uses: sarisia/actions-status-discord@v1
if: success()
with:
title: ✅ 개발 서버 배포 프로세스가 완료되었습니다! ✅
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: "<@1084774841460215839> <@281597829636423682> 배포가 정상적으로 이뤄졌는지 확인해주세요!"
color: 00FF00
username: showPot-Bot
avatar_url: ${{ secrets.DISCORD_NOTIFICATION_SUCCESS_AVATAR_URL }}

- name: Backend CD for Dev Server Discord Notification
uses: sarisia/actions-status-discord@v1
if: failure()
with:
title: ❗️개발 서버 배포 프로세스가 실패했습니다! ❗️
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
color: FF0000
username: showPot-Bot
avatar_url: ${{ secrets.DISCORD_NOTIFICATION_FAILED_AVATAR_URL }}
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:21-jdk-slim
ARG JAR_FILE_PATH=libs/*.jar
COPY ${JAR_FILE_PATH} app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
17 changes: 17 additions & 0 deletions app/api/src/main/java/org/example/health/HealthController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.example.health;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "서버 상태")
public class HealthController {

@GetMapping("/health")
@Operation(summary = "서버 상태 체크")
public String health() {
return "OK";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spring:
jpa:
hibernate:
ddl-auto: create
show-sql: true
open-in-view: false
generate-ddl: true
9 changes: 9 additions & 0 deletions app/infrastructure/s3/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bootJar.enabled = false
jar.enabled = true

dependencies {
implementation project(":app:api:common-api")

//aws s3
implementation 'io.awspring.cloud:spring-cloud-aws-s3:3.1.1'
}
14 changes: 13 additions & 1 deletion app/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ spring:
enabled: true
docker:
compose:
enabled: false
enabled: true
lifecycle-management: start_and_stop
stop:
command: down
timeout: 1m
security:
user:
name: user
password: password
data:
redis:
host: localhost
port: 6379

cloud:
aws:
Expand Down
36 changes: 30 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
version: '3'

services:
postgresql:
container_name: yapp_postgresql
image: postgres:14
environment:
- 'POSTGRES_DATABASE=yapp'
- 'POSTGRES_USER=local'
- 'POSTGRES_PASSWORD=local'
POSTGRES_DB: yapp
POSTGRES_USER: yapp
POSTGRES_PASSWORD: yapp
ports:
- '5432:5432'
restart: always
networks:
- app-network

redis:
container_name: yapp_redis
image: redis:alpine
ports:
- '6379:6379'
- '6379:6379'
networks:
- app-network

app:
image: yapp
build:
context: .
dockerfile: Dockerfile
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgresql:5432/yapp
SPRING_DATASOURCE_USERNAME: yapp
SPRING_DATASOURCE_PASSWORD: yapp
SPRING_REDIS_HOST: redis
SPRING_REDIS_PORT: 6379
ports:
- '8080:8080'
depends_on:
- postgresql
- redis
networks:
- app-network

networks:
app-network:
11 changes: 11 additions & 0 deletions start-develop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Git 리포지토리에서 최신 코드를 가져옵니다.
git pull origin develop

# 애플리케이션 빌드
./gradlew app:build

# Docker Compose를 사용하여 컨테이너 실행
docker-compose down
docker-compose up -d --build

0 comments on commit 3b1809f

Please sign in to comment.