-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* chore: Dockerfile 및 CD 설정 추가 * chore: gitignore에 docker-compose 추가 * fix: actions 중복 제거 * refactor: 도커 이미지 태깅 Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * refactor: 수동 트리거로 변경 * refactor: 일부 네이밍 수정 --------- Co-authored-by: 이한음 <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: LeeHanEum <[email protected]>
- Loading branch information
1 parent
1d4fd47
commit c866ded
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Build and Deploy to Dev Server | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-docker-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: get repo from github | ||
uses: actions/checkout@v3 | ||
|
||
# JDK setting | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
# gradle 빌드 | ||
- name: Setup Gradle | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew clean build -p aics-api -x test | ||
|
||
# DockerHub 로그인 | ||
- name: Docker login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
# Docker 이미지 빌드 | ||
- name: Docker image build | ||
env: | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG . | ||
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest | ||
# Docker Hub 이미지 푸시 | ||
- name: docker Hub push | ||
run: | | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:$IMAGE_TAG | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest | ||
deploy-to-dev: | ||
runs-on: ubuntu-latest | ||
needs: build-docker-image | ||
steps: | ||
- name: Deploy to dev | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USERNAME }} | ||
password: ${{ secrets.SERVER_PASSWORD }} | ||
port: ${{ secrets.SERVER_PORT }} | ||
script: | | ||
sudo docker-compose pull ${{ secrets.DOCKERHUB_USERNAME }}/aics-api:latest | ||
sudo docker-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,6 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Docker ### | ||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Dockerfile | ||
# Java 17 사용 | ||
FROM openjdk:17-jdk-slim | ||
|
||
# 작업 디렉토리 설정 | ||
WORKDIR /app | ||
|
||
# 빌드된 JAR 파일을 이미지에 복사 | ||
COPY aics-api/build/libs/*.jar app.jar | ||
|
||
# 실행 | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |