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
79 changes: 79 additions & 0 deletions .github/workflows/develop_build_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: develop push Build and deploy

on:
push:
branches: [ "develop" ]

env:
DOCKERHUB_USERNAME: ject4tserver
DOCKERHUB_IMAGE_NAME: studytrip-server

jobs:
build-deploy:
runs-on: ubuntu-latest
environment: DEV

strategy:
matrix:
java-version: [ 17 ]
distribution: [ 'temurin' ]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.distribution }}

- name: Grant Execute Permission for Gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
id: gradle
uses: gradle/gradle-build-action@v2
with:
arguments: |
bootJar
--scan

- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_KEY }}

- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v5.5.0
env:
DOCKERHUB_IMAGE_FULL_NAME: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}
with:
images: ${{ env.DOCKERHUB_IMAGE_FULL_NAME }}
tags: |
type=sha,prefix=

- name: Build and Push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}

- name: Deploy to EC2 Server
uses: appleboy/ssh-action@1.0.3
env:
DOCKERHUB_IMAGE_FULL_PATH: ${{ steps.metadata.outputs.tags }}
DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: DOCKERHUB_IMAGE_FULL_PATH, DOCKERHUB_IMAGE_NAME
debug: true
script: |
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
docker compose up -d
docker image prune -a -f
35 changes: 35 additions & 0 deletions .github/workflows/develop_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: develop Deploy

on:
# 워크플로우를 수동으로 트리거, 수동 배포
workflow_dispatch:
inputs:
commit_hash:
description: "commit hash"
required: true

env:
DOCKERHUB_USERNAME: ject4tserver
DOCKERHUB_IMAGE_NAME: studytrip-server

jobs:
deploy:
runs-on: ubuntu-latest
environment: DEV

steps:
- name: Deploy to EC2 Server
uses: appleboy/ssh-action@1.0.3
env:
DOCKERHUB_IMAGE_FULL_PATH: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.event.inputs.commit_hash }}
DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: DOCKERHUB_IMAGE_FULL_PATH, DOCKERHUB_IMAGE_NAME
debug: true
script: |
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
docker compose up -d
docker image prune -a -f
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ out/
.vscode/

###
.DS_Store
**/.DS_Store

### ENV
*.env
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM amazoncorretto:17-alpine-jdk
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ dependencies {
testImplementation 'org.mockito:mockito-junit-jupiter'
}

jar.enabled = false // 일반 JAR 파일 생성 비활성화

tasks.named('test') {
useJUnitPlatform()
}
Expand Down