Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ci-cd수정 #29

Merged
merged 39 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fd8ee35
chore: 수정
qormoon Jun 24, 2024
4947ef8
chore: Copy jar file to remote수정
qormoon Jun 24, 2024
4400e18
chore:ssh키 수정
qormoon Jun 24, 2024
ed346fc
chore:ssh키 수정
qormoon Jun 24, 2024
30788f5
chore:username 수정
qormoon Jun 24, 2024
d7f58e0
chore:username 수정
qormoon Jun 24, 2024
47ad75b
chore:username 수정
qormoon Jun 24, 2024
2a26e86
chore:수정
qormoon Jun 24, 2024
94483cd
chore:수정
qormoon Jun 24, 2024
5504507
chore:수정
qormoon Jun 24, 2024
11a8015
chore:수정
qormoon Jun 24, 2024
cc27d5b
chore:수정
qormoon Jun 24, 2024
1df261b
chore:수정
qormoon Jun 24, 2024
ff9d977
chore: ci-cd 확인
qormoon Jun 24, 2024
a2bb288
chore: ci-cd 확인
qormoon Jun 24, 2024
7afa2a3
chore: ci-cd 확인
qormoon Jun 24, 2024
c5a4d08
chore: ci-cd 확인
qormoon Jun 24, 2024
6cf6103
chore: ci-cd 확인
qormoon Jun 24, 2024
4e791c0
chore: ci-cd 확인
qormoon Jun 24, 2024
6fc3aeb
chore: ci-cd 확인
qormoon Jun 24, 2024
e98d4d4
chore: redis 추가
qormoon Jun 24, 2024
325dca6
chore: redis 수정
qormoon Jun 24, 2024
b3c5666
Update dev_deploy.yml workflow
qormoon Jun 24, 2024
4261c0a
chore:compose 위치 수정
qormoon Jun 24, 2024
b32c2e4
chore:수정
qormoon Jun 24, 2024
2ad614b
chore:수정
qormoon Jun 24, 2024
d8672d2
chore:수정
qormoon Jun 24, 2024
e4d4b5d
chore:docker-compose.yml 위치 수정
qormoon Jun 24, 2024
8545f06
chore:docker-compose.yml 위치 수정
qormoon Jun 24, 2024
f2cb56c
chore:경로 수정
qormoon Jun 24, 2024
dfb3718
chore:env 경로 수정
qormoon Jun 24, 2024
3b4ee9c
chore:env 환경변수 추가
qormoon Jun 24, 2024
84997cd
chore:docker-compose 버전 수정
qormoon Jun 24, 2024
02cfc86
chore:docker-compose 버전 수정
qormoon Jun 24, 2024
53480f3
chore:ci-cd 확인
qormoon Jun 24, 2024
fe646cd
chore:ci-cd 확인
qormoon Jun 24, 2024
e6b5620
chore:ci-cd 확인
qormoon Jun 24, 2024
e7126d9
chore: ci-cd 확인
qormoon Jun 25, 2024
374aaa8
chore:redis 확인
qormoon Jun 25, 2024
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
21 changes: 0 additions & 21 deletions .github/script/deploy.sh

This file was deleted.

102 changes: 41 additions & 61 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ jobs:
- name: Build With Gradle
run: ./gradlew build -x test

# 디렉토리 생성
- name: Create deploy directory
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
mkdir -p /home/ubuntu/deploy

# docker-compose 복사
- name: Copy docker-compose.yml
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
source: "docker-compose.yml"
target: "/home/ubuntu/deploy/"


# Docker 이미지를 빌드합니다.
- name: docker image build
run: docker build -t qormoon/fiurinee_docker .
Expand All @@ -62,41 +83,32 @@ jobs:
run: docker push qormoon/fiurinee_docker


# 빌드된 JAR 파일을 원격 서버에 복사합니다.
- name: Copy jar file to remote
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_SSH_KEY }}
source: "./build/libs/*.jar"
target: "/home/ec2-user/cicd"
strip_components: 2

# 새로 빌드된 Docker 이미지를 EC2 서버에 배포하는 작업을 정의
deploy:
needs: build-docker-image # build-docker-image 작업이 완료된 후에 실행됩니다.
runs-on: ubuntu-latest # 워크플로우가 실행될 환경을 지정합니다.

# 배포 스크립트를 원격 서버에 복사합니다.
- name: Copy deploy script file to remote
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_SSH_KEY }}
source: ".github/scripts/deploy.sh"
target: "/home/ec2-user/cicd"
steps:

# 배포 스크립트를 원격 서버에서 실행합니다.
- name: Execute deploy script
# EC2 서버에 SSH로 접속하여 Docker 이미지를 pull하고 컨테이너를 재시작
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
username: ec2-user
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_SSH_KEY }}
script_stop: true
host: ${{ secrets.EC2_HOST }} # EC2 서버의 호스트 주소
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }} # EC2 서버에 접근하기 위한 SSH 개인 키
script: |
chmod +x /home/ec2-user/cicd/deploy.sh
sh /home/ec2-user/cicd/deploy.sh


echo "DB_URL=${{ secrets.DB_URL }}" >> ~/deploy/.env
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> ~/deploy/.env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> ~/deploy/.env
echo "AWS_ACCESSKEY=${{ secrets.AWS_ACCESSKEY }}" >> ~/deploy/.env
echo "AWS_SECRETKEY=${{ secrets.AWS_SECRETKEY }}" >> ~/deploy/.env
echo "AWS_BUCKET=${{ secrets.AWS_BUCKET }}" >> ~/deploy/.env
sudo docker-compose -f ~/deploy/docker-compose.yml pull
sudo docker-compose -f ~/deploy/docker-compose.yml up -d
sudo docker image prune -f


# # 배포
# - name: Deploy
Expand All @@ -111,35 +123,3 @@ jobs:
# sudo docker pull qormoon/fiurinee_docker
# sudo docker run -d -p 8080:8080 qormoon/fiurinee_docker
# sudo docker image prune -f

# # 새로 빌드된 Docker 이미지를 EC2 서버에 배포하는 작업을 정의합니다.
# deploy:
# needs: build-docker-image # build-docker-image 작업이 완료된 후에 실행됩니다.
# runs-on: ubuntu-latest # 워크플로우가 실행될 환경을 지정합니다.
#
# steps:
# # EC2 서버에 SSH로 접속하여 Docker 이미지를 pull하고 컨테이너를 재시작
# - name: Deploy to EC2
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.EC2_HOST }} # EC2 서버의 호스트 주소
# username: ubuntu
# key: ${{ secrets.EC2_SSH_KEY }} # EC2 서버에 접근하기 위한 SSH 개인 키
# script: |
# # Docker Hub에서 최신 이미지를 pull 합니다.
# sudo docker pull qormoon/fiurinee_docker
# # 기존 컨테이너를 중지합니다.
# sudo docker stop fiurinee || true
# # 기존 컨테이너를 제거합니다.
# sudo docker rm fiurinee || true
# # 새 컨테이너를 실행하면서 환경 변수를 전달합니다.
# sudo docker run -d -p 8080:8080 --name fiurinee \
# -e DB_URL=jdbc:postgresql://database-fiurinee.czyqweykwib4.ap-northeast-2.rds.amazonaws.com:5432/fiurinee \
# -e DB_USERNAME=${{ secrets.DB_USERNAME }} \
# -e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
# -e AWS_ACCESSKEY=${{ secrets.AWS_ACCESSKEY }} \
# -e AWS_SECRETKEY=${{ secrets.AWS_SECRETKEY }} \
# -e AWS_BUCKET=${{ secrets.AWS_BUCKET }} \
# -e hibernate_ddl_auto=update \
# -v fiurinee_data:/var/lib/postgresql/data \
# qormoon/fiurinee_docker
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
app:
image: qormoon/fiurinee_docker
ports:
- "8080:8080"
environment:
DB_URL: ${DB_URL}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
AWS_ACCESSKEY: ${AWS_ACCESSKEY}
AWS_SECRETKEY: ${AWS_SECRETKEY}
AWS_BUCKET: ${AWS_BUCKET}
hibernate_ddl_auto: update
REDIS_HOST: redis
depends_on:
- redis

redis:
image: "redis:latest"
ports:
- "6379:6379"

Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public interface AnniversaryApi {
@ApiResponse(responseCode = "401", description = "인증 실패")
@ApiResponse(responseCode = "404", description = "사용자를 찾을 수 없음")
@PostMapping("/member/{id}/anniversary")
ResponseEntity<Anniversary> addAnniversary(@PathVariable Long id, @RequestBody AnniversaryRequestDTO request);
ResponseEntity<Anniversary> addAnniversary(@Parameter(name = "id", description = "멤버아이디")@PathVariable Long id, @RequestBody AnniversaryRequestDTO request);

@Operation(
summary = "기념일 수정",
summary = "기념일 수정입니닷",
description = "사용자의 기념일을 수정합니다.",
security = @SecurityRequirement(name = "bearerAuth")
)
Expand Down
Loading