diff --git a/.github/workflows/gradle-dev.yml b/.github/workflows/gradle-dev.yml new file mode 100644 index 0000000..cddbbf2 --- /dev/null +++ b/.github/workflows/gradle-dev.yml @@ -0,0 +1,52 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle Docker + +on: + push: + branches: [ "develop" ] + +permissions: + contents: read + +jobs: + build: + runs-on: devserver + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.SUB_TOKEN }} + submodules: true + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Docker build + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t ${{ secrets.DOCKER_REPO }}/chwipoclovadocker -f Dockerfile.dev . + docker push ${{ secrets.DOCKER_REPO }}/chwipoclovadocker + + - name: Deploy + run: | + docker stop be-con || true + docker rm -f be-con || true + docker rmi $(docker images -f "dangling=true" -q) || true + docker pull ${{ secrets.DOCKER_REPO }}/chwipoclovadocker:latest + docker run -v /var/log/service:/var/log/service -v /var/upload:/var/upload --name be-con -p 8080:8080 -d ${{ secrets.DOCKER_REPO }}/chwipoclovadocker:latest \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle-real.yml similarity index 97% rename from .github/workflows/gradle.yml rename to .github/workflows/gradle-real.yml index 8c3921a..da1544e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle-real.yml @@ -16,7 +16,7 @@ permissions: jobs: build: - runs-on: self-hosted + runs-on: apiserver1 steps: - name: checkout @@ -40,7 +40,7 @@ jobs: - name: Docker build run: | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - docker build -t ${{ secrets.DOCKER_REPO }}/chwipoclovadocker . + docker build -t ${{ secrets.DOCKER_REPO }}/chwipoclovadocker -f Dockerfile.real . docker push ${{ secrets.DOCKER_REPO }}/chwipoclovadocker - name: Deploy diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..a53585a --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,5 @@ +FROM openjdk:17-jdk +ARG JAR_FILE=build/libs/*.jar +COPY ${JAR_FILE} chwipoClova-0.0.1-SNAPSHOT.jar +ENV TZ Asia/Seoul +ENTRYPOINT ["java", "-Dspring.profiles.active=dev", "-jar","/chwipoClova-0.0.1-SNAPSHOT.jar"] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile.real similarity index 100% rename from Dockerfile rename to Dockerfile.real