diff --git a/.github/workflows/continuous-delivery.yaml b/.github/workflows/continuous-delivery.yaml new file mode 100644 index 0000000..705960a --- /dev/null +++ b/.github/workflows/continuous-delivery.yaml @@ -0,0 +1,133 @@ +name: Continuous Delivery (CD) +on: + # "Build and publish" on merged + # Actually, there's no "merged" event. + # A "push" event is occurred after the pull request "close" event with "merged" true condition. + # The "push" event could replace "merged" event. + push: + branches: + - main + - testcicd + tags: + - "v*.*.*" + paths-ignore: + - "**.md" + - ".gitignore" + - ".git/**" + - "CODE_OF_CONFUCT.md" + - "CONTRIBUTING.md" + - "LICENSE" + - "README.md" + +env: + DOCKER_REGISTRY_NAME: cloudbaristaorg + GHCR_REGISTRY_NAME: ${{ github.repository_owner }} + IMAGE_NAME: ${{ github.event.repository.name }} + +jobs: + # The job key is "publish-container-image" + publish-container-image: + # Job name is "Publish a container image" + name: Publish a container image + + #if: github.repository_owner == 'cloud-barista' + + runs-on: ubuntu-22.04 + + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Extract metadata from Git reference and GitHub events + id: meta + uses: docker/metadata-action@v5 + with: + images: | + # image name for Docker Hub + ${{env.DOCKER_REGISTRY_NAME}}/${{env.IMAGE_NAME}} + # image name for GitHub Container Registry (GHCR) + ghcr.io/${{env.GHCR_REGISTRY_NAME}}/${{env.IMAGE_NAME}} + tags: | + # See `tags` input: https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input + ## Tags for a push tag event + # minimal (e.g., 1.2.3) + type=semver,enable=true,pattern={{version}} + # type=semver,pattern={{major}}.{{minor}} + ## Tags for a push branch event + # Tags to reflect the last commit of the active branch + type=edge,enable=true,branch=main + ## Other types (currently the followings may be out of scope in this project) + ## Tags for a push branch event + # minimal (short sha) + # type=sha,enable=true,format=short + ## Tags for a push or pull_request event + # type=ref,event=branch + # type=ref,event=tag + # type=ref,event=pr + ## Tags for a schedule event - handlebars with timezone (e.g. 20200110-093000) + # type=schedule,enable=true,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: grant execute permission for gradlew + run: chmod +x gradlew + shell: bash + + - name: Build with Gradle Wrapper + run: ./gradlew clean build --stacktrace + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + + + + # TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT` + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Build and publish + id: docker_build + uses: docker/build-push-action@v6 + with: + builder: ${{ steps.buildx.outputs.name }} + context: ./ + file: ./Dockerfile + #target: prod + platforms: linux/amd64 # linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x,linux/arm/v6 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + #tags: tempcicd + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml new file mode 100644 index 0000000..ac18889 --- /dev/null +++ b/.github/workflows/continuous-integration.yaml @@ -0,0 +1,77 @@ +name: Continuous Integration (CI) +on: + push: + branches: ["main", "dev"] + pull_request: + branches: + - main + paths-ignore: + - "**.md" + - ".gitignore" + - ".git/**" + - "CODE_OF_CONFUCT.md" + - "CONTRIBUTING.md" + - "LICENSE" + - "README.md" +jobs: + build-source-chk: + name: Check source code + strategy: + matrix: + os: [ubuntu-22.04] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Test build & image create + run: echo 'gradle build & docker build' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + + - name: grant execute permission for gradlew + run: chmod +x gradlew + shell: bash + + - name: Build with Gradle Wrapper + run: ./gradlew test + + build-source-and-container-image: + name: Build a container image + runs-on: ubuntu-22.04 + needs: build-source-chk + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: grant execute permission for gradlew + run: chmod +x gradlew + shell: bash + + - name: Build with Gradle Wrapper + run: ./gradlew clean build --stacktrace + + - name: chk directory + run: ls -al + + - name: Build image + env: + IMAGE_NAME: ${{ github.event.repository.name }} + run: docker build . --file ./script/Dockerfile --tag $IMAGE_NAME + + + + diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..c4f2061 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,57 @@ +# temp docker-compose +networks: + internal_network: + internal: true + external_network: + driver: bridge + + # jenkins - for workflow manager + jenkins: + image: jenkins/jenkins:jdk17 + container_name: jenkins + platform: linux/amd64 + networks: + - internal_network + - external_network + ports: + - target: 8080 + published: 9800 + protocol: tcp + volumes: + - ./:/var/jenkins_home # -v $HOME/mcmp/oss/jenkins:/var/jenkins_home + - /var/run/docker.sock:/var/run/docker.sock + - /usr/bin/docker:/usr/bin/docker # -v $(which docker):/usr/bin/docker + environment: + - PROJECT=mcmp + healthcheck: # for workflow-manager + test: [ "CMD", "curl", "-f", "http://localhost:1024/catalog/software" ] + interval: 1m + timeout: 5s + retries: 3 + start_period: 10s + + # workflow-manager + mc-workflow-manager: + image: 이미지경로 + container_name: workflow-manager + build: + context: ./script + dockerfile: Dockerfile + networks: + - external_network + - external_network + ports: + - target: 18083 + published: 18083 + protocol: tcp + environment: + - DB_INIT_YN=create + - DB_ID=workflow + - DB_PW=workflow!23 + - SQL_DATA_INIT=always + healthcheck: # for cb-workflow-manager + test: ["CMD", "nc", "-vz", "localhost", "1324"] + interval: 1m + timeout: 5s + retries: 3 + start_period: 10s \ No newline at end of file diff --git a/script/run-mc-workflow.sh b/script/run-mc-workflow.sh index d28cd5f..9f4a071 100644 --- a/script/run-mc-workflow.sh +++ b/script/run-mc-workflow.sh @@ -8,7 +8,7 @@ echo "========================================================================== PROJECT_PATH=${PROJECT_ROOT} #DB 볼륨 생성 mkdir ${PROJECT_PATH}/DB -DB_VOLUME_PATH=${PROJECT_PATH/DB} +DB_VOLUME_PATH=${PROJECT_PATH}/DB # Application 명 APP_NAME=mc-workflow-manager @@ -46,7 +46,7 @@ sudo docker run -itd \ -e DB_ID=$DB_ID \ -e DB_PW=$DB_PW \ -e SQL_DATA_INIT=$SQL_DATA_INIT \ - -v DB_VOLUME_PATH=$DB_VOLUME_PATH \ + -v $DB_VOLUME_PATH=/document \ --name mc-workflow-manager \ $APP_IMAGE diff --git a/src/main/java/kr/co/mcmp/config/WebConfig.java b/src/main/java/kr/co/mcmp/config/WebConfig.java index ec50511..a8f095f 100644 --- a/src/main/java/kr/co/mcmp/config/WebConfig.java +++ b/src/main/java/kr/co/mcmp/config/WebConfig.java @@ -6,14 +6,14 @@ @Configuration public class WebConfig implements WebMvcConfigurer { - @Override public void addViewControllers(ViewControllerRegistry registry) { - registry.addViewController("/web/{spring:[a-zA-Z\\-]+}") - .setViewName("forward:/index.html"); - registry.addViewController("/web/**/{spring:[a-zA-Z\\-]+}") - .setViewName("forward:/index.html"); - registry.addViewController("/web/{spring:[a-zA-Z\\-]+}/**{spring:?!(\\.js|\\.css)$}") - .setViewName("forward:/index.html"); + // 모든 경로를 index.html로 리다이렉트 + registry.addViewController("/web/{spring:[\\w\\-]+}") + .setViewName("forward:/index.html"); + registry.addViewController("/web/**/{spring:[\\w\\-]+}") + .setViewName("forward:/index.html"); + registry.addViewController("/web/{spring:[\\w\\-]+}/**{spring:[\\w\\-]+}") + .setViewName("forward:/index.html"); } }