-
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.
* feat: ci/cd 구축 * fix: ci/cd 디폴트 경로 변경 * fix: ci/cd 디폴트 경로 변경 * fix: ci/cd 디폴트 경로 변경 * fix: ci/cd 디폴트 경로 변경 * fix: ci/cd 디폴트 경로 변경 * fix: ci/cd 디폴트 경로 변경 * feat: cicd 테스트 객체 제거 * feat: cicd 테스트 객체 제거
- Loading branch information
Showing
3 changed files
with
119 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,34 @@ | ||
name: backend-pull-request | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
paths: | ||
- 'server/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: ./server | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: CheckOut | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Test with Gradle Wrapper | ||
run: ./gradlew clean build |
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,68 @@ | ||
name: backend-push | ||
|
||
on: | ||
push: | ||
branches: [ "main", "develop" ] | ||
paths: | ||
- 'server/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./server | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: CheckOut | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Test with Gradle Wrapper | ||
run: ./gradlew test | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Set up Docker BuildX | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push | ||
run: | | ||
docker buildx build --platform linux/arm64 -t \ | ||
${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev --push . | ||
deploy: | ||
needs: build | ||
runs-on: self-hosted | ||
steps: | ||
- name: Docker remove | ||
run: | | ||
CONTAINER_IDS=$(sudo docker ps -qa) | ||
if [ -n "$CONTAINER_IDS" ]; then | ||
sudo docker rm -f $CONTAINER_IDS | ||
else | ||
echo "No running containers found." | ||
fi | ||
- name: Docker Image pull | ||
run: sudo docker pull ${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev | ||
|
||
- name: Docker run | ||
run: sudo docker run -d -p 80:8080 --name haengdong-backend-dev haengdong/haengdong-backend-dev |
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,17 @@ | ||
FROM gradle:7.6.1-jdk17 AS build | ||
|
||
WORKDIR /app | ||
|
||
COPY . /app | ||
|
||
RUN gradle clean build -x test | ||
|
||
FROM openjdk:17-jdk-slim | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app/build/libs/*.jar /app/haengdong-0.0.1-SNAPSHOT.jar | ||
|
||
EXPOSE 8080 | ||
ENTRYPOINT ["java"] | ||
CMD ["-jar", "haengdong-0.0.1-SNAPSHOT.jar"] |