-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from win-luck/feature/11-cicd
[infra] 배포 및 CI/CD 환경 구축 (#11)
- Loading branch information
Showing
4 changed files
with
101 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,35 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
types: [closed] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
if: github.event.pull_request.merged == true | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Pull Docker Image | ||
run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/puang | ||
|
||
- name: Remove Old Docker Container | ||
run: sudo docker rm -f puang || true | ||
|
||
- name: Run Updated Docker Container | ||
run: sudo docker run -t -d --name puang -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/puang |
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,51 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 | ||
|
||
- name: make application.yml | ||
run: | | ||
mkdir -p ./src/main/resources | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
touch ./application-prod.yml | ||
echo "${{ secrets.APPLICATION }}" > ./application.yml | ||
echo "${{ secrets.PROD }}" > ./application-prod.yml | ||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build Docker Image | ||
run: docker build --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/puang . | ||
|
||
- name: Push Docker Image | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/puang |
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,11 @@ | ||
# Use OpenJDK 17 as the base image | ||
FROM openjdk:17 | ||
|
||
# Specify the build argument for the JAR file | ||
ARG JAR_FILE=build/libs/*.jar | ||
|
||
# Copy the JAR file into the container | ||
COPY ${JAR_FILE} app.jar | ||
|
||
# Set the entry point to run the JAR file | ||
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/app.jar"] |
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 |
---|---|---|
|
@@ -66,3 +66,7 @@ tasks.named('test') { | |
bootJar { | ||
archiveFileName = 'app.jar' | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} |