forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #23 from kookmin-sw/feature/21
Feature/21
- Loading branch information
Showing
5 changed files
with
129 additions
and
3 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,47 @@ | ||
name: Build for feature branch | ||
|
||
on: | ||
push: | ||
branches: | ||
- feature/* | ||
pull_request: | ||
branches: | ||
- feature/* | ||
|
||
permissions: | ||
contents: read | ||
|
||
|
||
jobs: | ||
build_only: | ||
runs-on: ubuntu-latest # ubuntu 최신 버전에서 script를 실행 | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: "adopt" | ||
|
||
- name: Make application.properties | ||
run: | | ||
cd ./server/src/main/resources | ||
touch ./application.properties | ||
echo "${{ secrets.PROPERTIES }}" > ./application.properties | ||
shell: bash | ||
|
||
# gradle을 통해 소스를 빌드. | ||
- name: Build with Gradle | ||
run: | | ||
cd server | ||
chmod +x ./gradlew | ||
./gradlew clean build -x test | ||
- name: Docker build | ||
run: | | ||
cd server | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }}:latest . |
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 for main branch | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: "adopt" | ||
|
||
- name: Make application.properties | ||
run: | | ||
cd ./server/src/main/resources | ||
touch ./application.properties | ||
echo "${{ secrets.PROPERTIES }}" > ./application.properties | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: | | ||
cd server | ||
chmod +x ./gradlew | ||
./gradlew clean build -x test | ||
- name: Docker build & push to docker repo | ||
run: | | ||
cd server | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }}:latest . | ||
docker push ${{ secrets.DOCKER_REPO }}:latest | ||
pull-and-deploy: | ||
needs: build-and-push | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Pull & Deploy to server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_PUBLIC_IP }} | ||
username: ubuntu | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
envs: GITHUB_SHA | ||
script: | | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull ${{ secrets.DOCKER_REPO }}:latest | ||
sudo docker image prune -f | ||
sudo docker run -d --name server -p 80:8080 suhwani/capstone |
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,5 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
server/src/main/resources/*.properties |
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 @@ | ||
FROM bellsoft/liberica-openjdk-alpine:17 | ||
|
||
# Gradle 빌드 명령 실행 | ||
CMD ["./gradlew", "clean", "build"] | ||
|
||
# 빌드된 JAR 파일 복사 | ||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["java","-jar","/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