-
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.
- Loading branch information
1 parent
a8f62d8
commit aa5ef83
Showing
2 changed files
with
66 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,55 @@ | ||
name: Java CI/CD with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build-docker-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# 1. Java 17 세팅 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
# 2. Spring Boot 애플리케이션 빌드 | ||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: clean bootJar | ||
|
||
# 3. Docker 이미지 빌드 | ||
- name: docker image build | ||
run: docker buildx build --platform=linux/arm64 -t ${{ secrets.DOCKERHUB_USERNAME }}/attachit:latest . | ||
|
||
# 4. Dockerhub 로그인 | ||
- name: docker login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# 5. Dockerhub push | ||
- name: docker hub push | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/attachit:latest | ||
|
||
- name: Connect to WAS & Execute Application | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.WAS_HOST }} | ||
username: ${{ secrets.WAS_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.WAS_SSH_PORT }} | ||
script: | | ||
cd ~/attachit | ||
docker-compose down | ||
docker-compose pull | ||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM openjdk:17-oracle | ||
|
||
WORKDIR /app | ||
|
||
ARG JAR_FILE=build/libs/*.jar | ||
|
||
COPY ${JAR_FILE} app.jar | ||
|
||
EXPOSE 8082 | ||
|
||
CMD ["java", "-jar", "app.jar"] |