diff --git a/.github/workflows/backend-pull-request.yml b/.github/workflows/backend-pull-request.yml new file mode 100644 index 000000000..f7e467b40 --- /dev/null +++ b/.github/workflows/backend-pull-request.yml @@ -0,0 +1,32 @@ +name: backend-pull-request + +on: + pull_request: + branches: [ "main", "develop", "feature/#22" ] + paths: + - 'server/**' + +defaults: + run: + working-directory: ./server + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - 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 diff --git a/.github/workflows/backend-push.yml b/.github/workflows/backend-push.yml new file mode 100644 index 000000000..672f28ffc --- /dev/null +++ b/.github/workflows/backend-push.yml @@ -0,0 +1,66 @@ +name: backend-push + +on: + push: + branches: [ "main", "develop", "feature/#22" ] + paths: + - 'server/**' + +defaults: + run: + working-directory: ./server + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - 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 + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev + platforms: linux/arm64 + + 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 diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 000000000..38c565c85 --- /dev/null +++ b/server/Dockerfile @@ -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"] diff --git a/server/src/main/java/server/haengdong/domain/CiCd.java b/server/src/main/java/server/haengdong/domain/CiCd.java new file mode 100644 index 000000000..82aefe03b --- /dev/null +++ b/server/src/main/java/server/haengdong/domain/CiCd.java @@ -0,0 +1,4 @@ +package server.haengdong.domain; + +public class CiCd { +}