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: docker compose 적용 #31

Merged
merged 26 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
53cc0b7
chore: 워크플로 테스트 트리거 추가
uwoobeat Nov 29, 2023
abba177
chore: 서버로 컴포즈 파일을 전송하는 스텝 추가
uwoobeat Nov 29, 2023
bb54d1d
chore: 빌드 시 자바 이미지 eclipse-temurin으로 변경
uwoobeat Nov 29, 2023
a3190cc
chore: 컴포즈 파일 작성
uwoobeat Nov 29, 2023
c33f316
chore: 컴포즈 파일에 사용할 환경변수 설정
uwoobeat Nov 29, 2023
84509c7
Merge branch 'develop' into chore/15-docker-compose
uwoobeat Nov 29, 2023
3e24e17
chore: 시크릿을 사용하도록 변경
uwoobeat Nov 29, 2023
6d8d517
fix: 권한 문제 수정
uwoobeat Nov 29, 2023
9da4b49
chore: 도커 컴포즈를 실행하도록 변경
uwoobeat Nov 29, 2023
d803cf0
fix: scp action의 버전을 고정하도록 변경
uwoobeat Nov 29, 2023
24a9d3f
fix: 오타 수정
uwoobeat Nov 29, 2023
1fe9040
fix: 유저네임 변경
uwoobeat Nov 29, 2023
4f740a6
fix: 쉘에서 환경변수 전달하도록 수정
uwoobeat Nov 29, 2023
7969b21
fix: 사용할 환경변수 지정
uwoobeat Nov 29, 2023
fc7bd4b
chore: 도커 미사용 리소스 삭제 명령어 추가
uwoobeat Nov 29, 2023
f3ac0ea
fix: 이미지만 삭제하도록 수정
uwoobeat Nov 29, 2023
f785c1a
fix: 환경변수 수정
uwoobeat Nov 29, 2023
4d1bd48
chore: 호스트 모드 사용 시 포트 바인딩 옵션 제거
uwoobeat Nov 29, 2023
b910404
chore: 컴포즈가 전역 컨텍스트의 환경변수를 직접 참조하도록 수정 테스트
uwoobeat Nov 29, 2023
0e8f426
fix: 주석 수정
uwoobeat Nov 29, 2023
cc9e72e
Revert "fix: 주석 수정"
uwoobeat Nov 29, 2023
d336a3c
Revert "chore: 컴포즈가 전역 컨텍스트의 환경변수를 직접 참조하도록 수정 테스트"
uwoobeat Nov 29, 2023
c34772f
docs: 주석 추가
uwoobeat Nov 29, 2023
b7b8471
chore: 주석 처리한 명령어 제거
uwoobeat Nov 29, 2023
a39b472
chore: 워크플로 테스트 트리거 롤백
uwoobeat Nov 29, 2023
899c21c
chore: 배포 전용 워크플로에 변경사항 적용
uwoobeat Nov 29, 2023
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: 18 additions & 3 deletions .github/workflows/develop_build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,35 @@ jobs:
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ steps.github-sha-short.outputs.sha }}

# 서버로 docker-compose 파일 전송
- name: Copy docker-compose.yml to NCP Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.NCP_HOST }}
username: tenminute
key: ${{ secrets.NCP_PRIVATE_KEY }}
port: ${{ secrets.NCP_PORT }}
source: docker-compose.yaml
target: /home/tenminute/

deploy:
runs-on: ubuntu-latest
environment: DEV
needs: build
steps:
- name: Login to NCP Server
- name: Deploy to NCP Server
uses: appleboy/ssh-action@master
env:
NCP_CONTAINER_REGISTRY: ${{ secrets.NCP_CONTAINER_REGISTRY }}
NCP_IMAGE_TAG: ${{ needs.build.outputs.sha }}
with:
host: ${{ secrets.NCP_HOST }}
username: tenminute
key: ${{ secrets.NCP_PRIVATE_KEY }}
port: ${{ secrets.NCP_PORT }}
envs: NCP_CONTAINER_REGISTRY,NCP_IMAGE_TAG # docker-compose.yml 에서 사용할 환경 변수
script: |
echo "${{ secrets.NCP_SECRET_KEY }}" | docker login -u "${{ secrets.NCP_ACCESS_KEY }}" --password-stdin "${{ secrets.NCP_CONTAINER_REGISTRY }}"
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ needs.build.outputs.sha }}
docker stop server-spring && docker rm server-spring
docker run -d --name server-spring -p 8080:8080 -d ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ needs.build.outputs.sha }}
docker compose -f /home/tenminute/docker-compose.yaml up -d
docker image prune -a -f
16 changes: 9 additions & 7 deletions .github/workflows/develop_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ jobs:
deploy:
runs-on: ubuntu-latest
environment: DEV
needs: build
steps:
- name: checkout
uses: actions/checkout@master

- name: Login to NCP Server
- name: Deploy to NCP Server
uses: appleboy/ssh-action@master
env:
NCP_CONTAINER_REGISTRY: ${{ secrets.NCP_CONTAINER_REGISTRY }}
NCP_IMAGE_TAG: ${{ needs.build.outputs.sha }}
with:
host: ${{ secrets.NCP_HOST }}
username: tenminute
key: ${{ secrets.NCP_PRIVATE_KEY }}
port: ${{ secrets.NCP_PORT }}
envs: NCP_CONTAINER_REGISTRY,NCP_IMAGE_TAG # docker-compose.yml 에서 사용할 환경 변수
script: |
echo "${{ secrets.NCP_SECRET_KEY }}" | docker login -u "${{ secrets.NCP_ACCESS_KEY }}" --password-stdin "${{ secrets.NCP_CONTAINER_REGISTRY }}"
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ github.event.inputs.commit_hash }}
docker stop server-spring && docker rm server-spring
docker run -d --name server-spring -p 8080:8080 -d ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ github.event.inputs.commit_hash }}
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ needs.build.outputs.sha }}
docker compose -f /home/tenminute/docker-compose.yaml up -d
docker image prune -a -f
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amazoncorretto:17
FROM eclipse-temurin:17
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.8"

services:
backend:
image: ${NCP_CONTAINER_REGISTRY}/server-spring:${NCP_IMAGE_TAG}
container_name: server-spring
restart: always
network_mode: host
Loading