From e4c719be27ae8767f4ba1c9e13d1e838a876a999 Mon Sep 17 00:00:00 2001 From: xuannnnnn03 Date: Mon, 28 Apr 2025 00:32:50 +0800 Subject: [PATCH 01/51] J --- Jenkins | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Jenkins diff --git a/Jenkins b/Jenkins new file mode 100644 index 00000000..9c2577e2 --- /dev/null +++ b/Jenkins @@ -0,0 +1,51 @@ +pipeline { + agent any + + tools { + jdk 'Java 17' // must match the JDK name you configured + } + + environment { + GRADLE_OPTS = "-Dorg.gradle.jvmargs='-Xmx1024m'" + } + + stages { + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Build') { + steps { + sh './gradlew clean build' + } + } + + stage('Test') { + steps { + sh './gradlew test' + } + post { + always { + junit 'build/test-results/test/*.xml' + } + } + } + + stage('Assemble') { + steps { + sh './gradlew assemble' + } + } + } + + post { + success { + echo 'Gradle build and tests succeeded!' + } + failure { + echo 'Gradle build or tests failed.' + } + } +} From 29c98f237c9afd1b666c396747af65a79d17405b Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:31:39 +0800 Subject: [PATCH 02/51] Update ci.yml --- .github/workflows/ci.yml | 43 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dcdf5b6..5e5a2a75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,10 @@ -name: CI +name: Java DDD Example CI on: push: - branches: - - main + branches: [ main ] pull_request: + branches: [ main ] jobs: build: @@ -12,20 +12,23 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: 🐳 Start all the environment - run: make start - - - name: 🔦 Lint - run: make lint - - - name: 🦭 Wait for the environment to get up - run: | - while ! make ping-mysql &>/dev/null; do - echo "Waiting for database connection..." - sleep 2 - done - - - name: ✅ Run the tests - run: make test + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '21' + + - name: Build with Gradle + run: ./gradlew clean build -x test + + - name: Run tests + run: ./gradlew test + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: build/libs/** From 0882c0dbc03730f0c7d8b40d8c609befdcd458c9 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:32:41 +0800 Subject: [PATCH 03/51] Update ci.yml --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e5a2a75..fbeb165b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: @@ -32,3 +33,6 @@ jobs: with: name: build-artifacts path: build/libs/** + + + From ec9cd5d72dc75be1d2e748e0dff31598914e193f Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:36:45 +0800 Subject: [PATCH 04/51] Update docker-compose.yml --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3da6fcb7..6d548137 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3' services: shared_mysql: From 4a2d972cd8a52475e74af3f6cb1e2112fe27fb8b Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:36:56 +0800 Subject: [PATCH 05/51] Update docker-compose.ci.yml --- docker-compose.ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 654ffd12..fe1c8113 100755 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -1,5 +1,3 @@ -version: '3' - services: shared_mysql: container_name: codely-java_ddd_example-mysql From 20d3622e3e7fc5490abc96360934a0c01d785810 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:40:17 +0800 Subject: [PATCH 06/51] Update ci.yml --- .github/workflows/ci.yml | 69 ++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbeb165b..4b4e9bdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Java DDD Example CI +name: Java DDD Example CI (Docker) on: push: @@ -7,32 +7,47 @@ on: branches: [ main ] jobs: - build: - + build-and-test: runs-on: ubuntu-latest + timeout-minutes: 20 steps: - - name: Checkout code - uses: actions/checkout@v4 - - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'adopt' - java-version: '21' - - - name: Build with Gradle - run: ./gradlew clean build -x test - - - name: Run tests - run: ./gradlew test - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - path: build/libs/** - - - + - name: 🛒 Checkout code + uses: actions/checkout@v4 + + - name: 🐳 Set up Docker + run: | + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + sudo systemctl start docker + + - name: 🏗️ Start containers + run: docker compose -f docker-compose.ci.yml up -d + env: + COMPOSE_DOCKER_CLI_BUILD: 1 + DOCKER_BUILDKIT: 1 + + - name: ⏳ Wait for services + timeout-minutes: 3 + run: | + until docker inspect -f '{{.State.Health.Status}}' java_ddd_example-mysql | grep -q "healthy"; do + echo "Waiting for MySQL..." + sleep 5 + done + until docker inspect -f '{{.State.Health.Status}}' java_ddd_example-elasticsearch | grep -q "healthy"; do + echo "Waiting for Elasticsearch..." + sleep 5 + done + + - name: ✨ Code formatting check + run: docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck + + - name: 🏭 Build project + run: docker exec codely-java_ddd_example-test_server ./gradlew build --warning-mode all + + - name: 🧪 Run tests + run: docker exec codely-java_ddd_example-test_server ./gradlew test --warning-mode all + + - name: 🧹 Clean up + if: always() + run: docker compose -f docker-compose.ci.yml down From 1d59293d3b3aa10fd11aa24238b8f98cc49552f4 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:45:47 +0800 Subject: [PATCH 07/51] Update ci.yml --- .github/workflows/ci.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b4e9bdd..0ba55ff3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,14 +27,26 @@ jobs: COMPOSE_DOCKER_CLI_BUILD: 1 DOCKER_BUILDKIT: 1 - - name: ⏳ Wait for services + - name: ⏳ Wait for MySQL timeout-minutes: 3 run: | - until docker inspect -f '{{.State.Health.Status}}' java_ddd_example-mysql | grep -q "healthy"; do + until docker inspect -f '{{.State.Health.Status}}' codely-java_ddd_example-mysql | grep -q "healthy"; do echo "Waiting for MySQL..." sleep 5 done - until docker inspect -f '{{.State.Health.Status}}' java_ddd_example-elasticsearch | grep -q "healthy"; do + + - name: ⏳ Wait for RabbitMQ + timeout-minutes: 2 + run: | + until docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup; do + echo "Waiting for RabbitMQ..." + sleep 5 + done + + - name: ⏳ Wait for Elasticsearch + timeout-minutes: 3 + run: | + until curl -s http://localhost:9200/_cluster/health; do echo "Waiting for Elasticsearch..." sleep 5 done From 4f1b2130257264d8165653024fe43c5235fbe0a0 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:48:46 +0800 Subject: [PATCH 08/51] Update ci.yml --- .github/workflows/ci.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ba55ff3..797ba076 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,15 +27,7 @@ jobs: COMPOSE_DOCKER_CLI_BUILD: 1 DOCKER_BUILDKIT: 1 - - name: ⏳ Wait for MySQL - timeout-minutes: 3 - run: | - until docker inspect -f '{{.State.Health.Status}}' codely-java_ddd_example-mysql | grep -q "healthy"; do - echo "Waiting for MySQL..." - sleep 5 - done - - - name: ⏳ Wait for RabbitMQ + - name: ⏳ Wait for RabbitMQ timeout-minutes: 2 run: | until docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup; do @@ -43,7 +35,7 @@ jobs: sleep 5 done - - name: ⏳ Wait for Elasticsearch + - name: ⏳ Wait for Elasticsearch timeout-minutes: 3 run: | until curl -s http://localhost:9200/_cluster/health; do @@ -51,6 +43,15 @@ jobs: sleep 5 done + + - name: ⏳ Wait for MySQL + timeout-minutes: 3 + run: | + until docker exec codely-java_ddd_example-mysql mysqladmin ping --silent; do + echo "Waiting for MySQL..." + sleep 5 + done + - name: ✨ Code formatting check run: docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck From db120d8f00fcaaa4d480c031a15c78cf3eab7e38 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 01:49:15 +0800 Subject: [PATCH 09/51] Update ci.yml --- .github/workflows/ci.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 797ba076..5d739540 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,15 @@ jobs: COMPOSE_DOCKER_CLI_BUILD: 1 DOCKER_BUILDKIT: 1 - - name: ⏳ Wait for RabbitMQ + - name: ⏳ Wait for MySQL + timeout-minutes: 3 + run: | + until docker exec codely-java_ddd_example-mysql mysqladmin ping --silent; do + echo "Waiting for MySQL..." + sleep 5 + done + + - name: ⏳ Wait for RabbitMQ timeout-minutes: 2 run: | until docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup; do @@ -35,7 +43,7 @@ jobs: sleep 5 done - - name: ⏳ Wait for Elasticsearch + - name: ⏳ Wait for Elasticsearch timeout-minutes: 3 run: | until curl -s http://localhost:9200/_cluster/health; do @@ -43,15 +51,6 @@ jobs: sleep 5 done - - - name: ⏳ Wait for MySQL - timeout-minutes: 3 - run: | - until docker exec codely-java_ddd_example-mysql mysqladmin ping --silent; do - echo "Waiting for MySQL..." - sleep 5 - done - - name: ✨ Code formatting check run: docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck From f5449cedae3c94960f0af3419aa08fba83dc68c7 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:11:02 +0800 Subject: [PATCH 10/51] Add files via upload --- Jenkinsfile.Jenkinsfile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Jenkinsfile.Jenkinsfile diff --git a/Jenkinsfile.Jenkinsfile b/Jenkinsfile.Jenkinsfile new file mode 100644 index 00000000..6d27b7a4 --- /dev/null +++ b/Jenkinsfile.Jenkinsfile @@ -0,0 +1,34 @@ +pipeline { + agent any + stages { + stage('Checkout') { + steps { + git branch: 'master', url: 'https://github.com/wxwwixx/java1.git' + } + } + stage('Build') { + steps { bat 'gradlew clean build'} + } + stage('Test') { + steps { bat 'gradlew test'} + } + stage('Deploy') { + steps { powershell 'java -jar build/libs/hello-world-java-V1.jar'} + } +} + +post { + always { + echo 'Cleaning up workspace' + deleteDir() // Clean up the workspace after the build + } + success { + echo 'Build succeeded!!!' + // You could add notification steps here + } + failure { + echo 'Build failed!' + // You could add notification steps here + } + } +} From 4e60e1a6aa3b861df54de2cee2f89b30d6761be8 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:14:56 +0800 Subject: [PATCH 11/51] Update Jenkinsfile.Jenkinsfile --- Jenkinsfile.Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.Jenkinsfile b/Jenkinsfile.Jenkinsfile index 6d27b7a4..3abedacd 100644 --- a/Jenkinsfile.Jenkinsfile +++ b/Jenkinsfile.Jenkinsfile @@ -3,7 +3,7 @@ pipeline { stages { stage('Checkout') { steps { - git branch: 'master', url: 'https://github.com/wxwwixx/java1.git' + git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' } } stage('Build') { From 4f8f9ac2c365bb6464bc3a8e09d34c7a4aad6197 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:17:09 +0800 Subject: [PATCH 12/51] Delete Jenkins --- Jenkins | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 Jenkins diff --git a/Jenkins b/Jenkins deleted file mode 100644 index 9c2577e2..00000000 --- a/Jenkins +++ /dev/null @@ -1,51 +0,0 @@ -pipeline { - agent any - - tools { - jdk 'Java 17' // must match the JDK name you configured - } - - environment { - GRADLE_OPTS = "-Dorg.gradle.jvmargs='-Xmx1024m'" - } - - stages { - stage('Checkout') { - steps { - checkout scm - } - } - - stage('Build') { - steps { - sh './gradlew clean build' - } - } - - stage('Test') { - steps { - sh './gradlew test' - } - post { - always { - junit 'build/test-results/test/*.xml' - } - } - } - - stage('Assemble') { - steps { - sh './gradlew assemble' - } - } - } - - post { - success { - echo 'Gradle build and tests succeeded!' - } - failure { - echo 'Gradle build or tests failed.' - } - } -} From f206560b15bae2de840faa872c77ec54ffabeda3 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:17:52 +0800 Subject: [PATCH 13/51] Update Jenkinsfile.Jenkinsfile --- Jenkinsfile.Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.Jenkinsfile b/Jenkinsfile.Jenkinsfile index 3abedacd..b812d271 100644 --- a/Jenkinsfile.Jenkinsfile +++ b/Jenkinsfile.Jenkinsfile @@ -3,7 +3,7 @@ pipeline { stages { stage('Checkout') { steps { - git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' + git branch: 'master', url: 'https://github.com/mystery5639/java-ddd-example.git' } } stage('Build') { From 07cff1313f666e18607fd88569fcf41ff3537509 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:21:42 +0800 Subject: [PATCH 14/51] Update and rename Jenkinsfile.Jenkinsfile to Jenkinsfile --- Jenkinsfile.Jenkinsfile => Jenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Jenkinsfile.Jenkinsfile => Jenkinsfile (100%) diff --git a/Jenkinsfile.Jenkinsfile b/Jenkinsfile similarity index 100% rename from Jenkinsfile.Jenkinsfile rename to Jenkinsfile From 5aed3586560af4601b0ceda9dee1a80ec2491554 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:23:54 +0800 Subject: [PATCH 15/51] Update Jenkinsfile --- Jenkinsfile | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b812d271..5c636b8c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,34 +1,31 @@ pipeline { agent any + + environment { + JAVA_HOME = tool name: 'JDK21', type: 'JDK' // Updated to JDK21 + PATH = "${JAVA_HOME}/bin:${env.PATH}" // Ensure the JDK is added to the PATH + } + stages { stage('Checkout') { steps { - git branch: 'master', url: 'https://github.com/mystery5639/java-ddd-example.git' + echo "Checking out the code" + checkout scm } } + stage('Build') { - steps { bat 'gradlew clean build'} - } - stage('Test') { - steps { bat 'gradlew test'} + steps { + echo "Running Gradle build" + bat './gradlew clean build' // For Windows agents + // Use './gradlew clean build' instead of 'bat' for Linux agents + } } - stage('Deploy') { - steps { powershell 'java -jar build/libs/hello-world-java-V1.jar'} - } -} -post { - always { - echo 'Cleaning up workspace' - deleteDir() // Clean up the workspace after the build - } - success { - echo 'Build succeeded!!!' - // You could add notification steps here - } - failure { - echo 'Build failed!' - // You could add notification steps here + stage('Test') { + steps { + echo "Running Gradle tests" + bat './gradlew test' // For Windows agents + // Use './gradlew test' instead of 'bat' for Linux agents + } } - } -} From 98c0bdc387025ba42ef173f7a1844002e6f7ae04 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:31:54 +0800 Subject: [PATCH 16/51] Update Jenkinsfile --- Jenkinsfile | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5c636b8c..6d27b7a4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,31 +1,34 @@ pipeline { agent any - - environment { - JAVA_HOME = tool name: 'JDK21', type: 'JDK' // Updated to JDK21 - PATH = "${JAVA_HOME}/bin:${env.PATH}" // Ensure the JDK is added to the PATH - } - stages { stage('Checkout') { steps { - echo "Checking out the code" - checkout scm + git branch: 'master', url: 'https://github.com/wxwwixx/java1.git' } } - stage('Build') { - steps { - echo "Running Gradle build" - bat './gradlew clean build' // For Windows agents - // Use './gradlew clean build' instead of 'bat' for Linux agents - } + steps { bat 'gradlew clean build'} } - stage('Test') { - steps { - echo "Running Gradle tests" - bat './gradlew test' // For Windows agents - // Use './gradlew test' instead of 'bat' for Linux agents - } + steps { bat 'gradlew test'} + } + stage('Deploy') { + steps { powershell 'java -jar build/libs/hello-world-java-V1.jar'} + } +} + +post { + always { + echo 'Cleaning up workspace' + deleteDir() // Clean up the workspace after the build } + success { + echo 'Build succeeded!!!' + // You could add notification steps here + } + failure { + echo 'Build failed!' + // You could add notification steps here + } + } +} From ecbfea3c2769fe15944bd8aa534181adb3c23ff3 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:45:38 +0800 Subject: [PATCH 17/51] Update Jenkinsfile --- Jenkinsfile | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6d27b7a4..f1058d82 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,34 +1,48 @@ pipeline { agent any + + environment { + // Set JAVA_HOME (adjust path to your Java installation) + JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' // Windows path example + PATH = "${JAVA_HOME}\\bin;${env.PATH}" + } + stages { stage('Checkout') { steps { git branch: 'master', url: 'https://github.com/wxwwixx/java1.git' } } + stage('Build') { - steps { bat 'gradlew clean build'} + steps { + bat 'gradlew clean build' + } } + stage('Test') { - steps { bat 'gradlew test'} + steps { + bat 'gradlew test' + } } + stage('Deploy') { - steps { powershell 'java -jar build/libs/hello-world-java-V1.jar'} - } -} + steps { + powershell 'java -jar build/libs/hello-world-java-V1.jar' + } + } + } -post { + post { always { echo 'Cleaning up workspace' - deleteDir() // Clean up the workspace after the build + deleteDir() } success { echo 'Build succeeded!!!' - // You could add notification steps here } failure { echo 'Build failed!' - // You could add notification steps here } } } From ab40163319bb949b811edc184d13bade65c4d974 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:47:17 +0800 Subject: [PATCH 18/51] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f1058d82..8e43df91 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { environment { // Set JAVA_HOME (adjust path to your Java installation) - JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' // Windows path example + JAVA_HOME = 'C:\graalvm-jdk-21_windows-x64_bin\graalvm-jdk-21.0.6+8.1' // Windows path example PATH = "${JAVA_HOME}\\bin;${env.PATH}" } From b9be5169a24f25ab8cdb35442251f9f9498d5e9e Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:48:32 +0800 Subject: [PATCH 19/51] Update Jenkinsfile From 9a720512cf08feb37bd3baab700405f1a37cc500 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:49:13 +0800 Subject: [PATCH 20/51] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8e43df91..2960327d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { environment { // Set JAVA_HOME (adjust path to your Java installation) - JAVA_HOME = 'C:\graalvm-jdk-21_windows-x64_bin\graalvm-jdk-21.0.6+8.1' // Windows path example + JAVA_HOME = 'C:\Program Files\Java\jdk-17.0.12' // Windows path example PATH = "${JAVA_HOME}\\bin;${env.PATH}" } From 12d4aad8c2472177424da95fffbf8bef97af28b5 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 02:50:36 +0800 Subject: [PATCH 21/51] Update Jenkinsfile --- Jenkinsfile | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2960327d..3abedacd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,48 +1,34 @@ pipeline { agent any - - environment { - // Set JAVA_HOME (adjust path to your Java installation) - JAVA_HOME = 'C:\Program Files\Java\jdk-17.0.12' // Windows path example - PATH = "${JAVA_HOME}\\bin;${env.PATH}" - } - stages { stage('Checkout') { steps { - git branch: 'master', url: 'https://github.com/wxwwixx/java1.git' + git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' } } - stage('Build') { - steps { - bat 'gradlew clean build' - } + steps { bat 'gradlew clean build'} } - stage('Test') { - steps { - bat 'gradlew test' - } + steps { bat 'gradlew test'} } - stage('Deploy') { - steps { - powershell 'java -jar build/libs/hello-world-java-V1.jar' - } - } - } + steps { powershell 'java -jar build/libs/hello-world-java-V1.jar'} + } +} - post { +post { always { echo 'Cleaning up workspace' - deleteDir() + deleteDir() // Clean up the workspace after the build } success { echo 'Build succeeded!!!' + // You could add notification steps here } failure { echo 'Build failed!' + // You could add notification steps here } } } From 54042fcbf73f017fb5abcaef2919db443e92a835 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:01:59 +0800 Subject: [PATCH 22/51] Update Jenkinsfile --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3abedacd..39089116 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,11 @@ pipeline { agent any + evironment { + // Set JAVA_HOME (adjust path to your Java installation) + JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' // Windows path example + PATH = "${JAVA_HOME}\\bin;${env.PATH}" + } + stages { stage('Checkout') { steps { From 234a3d9fe6b343b3a80745b39e5a2ec074520560 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:03:09 +0800 Subject: [PATCH 23/51] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 39089116..75b2132b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { agent any - evironment { + environment { // Set JAVA_HOME (adjust path to your Java installation) JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' // Windows path example PATH = "${JAVA_HOME}\\bin;${env.PATH}" From 2ea7960565410edea6b7d8cea9e93a8726352001 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:17:29 +0800 Subject: [PATCH 24/51] Update Jenkinsfile --- Jenkinsfile | 88 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 75b2132b..7a81732b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,40 +1,88 @@ pipeline { agent any + environment { - // Set JAVA_HOME (adjust path to your Java installation) - JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' // Windows path example - PATH = "${JAVA_HOME}\\bin;${env.PATH}" + // Docker compose file (adjust path if needed) + COMPOSE_FILE = 'docker-compose.ci.yml' + JAVA_HOME = 'C:\Program Files\Java\jdk-21' + PATH = "${JAVA_HOME}/bin:${env.PATH}:/usr/local/bin" } - + stages { - stage('Checkout') { + stage('Setup Docker') { steps { - git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' + script { + // Install Docker if not present (Linux agents) + if (isUnix()) { + sh ''' + sudo apt-get update -y + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + sudo systemctl start docker + sudo usermod -aG docker $USER + ''' + } + } } } - stage('Build') { - steps { bat 'gradlew clean build'} + + stage('Start Containers') { + steps { + sh "docker-compose -f ${COMPOSE_FILE} up -d" + } } - stage('Test') { - steps { bat 'gradlew test'} + + stage('Wait for Services') { + steps { + sh ''' + # Wait for MySQL + until docker exec codely-java_ddd_example-mysql mysqladmin ping --silent; do + echo "Waiting for MySQL..." + sleep 5 + done + + # Wait for RabbitMQ + until docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup; do + echo "Waiting for RabbitMQ..." + sleep 5 + done + + # Wait for Elasticsearch + until curl -s http://localhost:9200/_cluster/health; do + echo "Waiting for Elasticsearch..." + sleep 5 + done + ''' + } } + + stage('Build & Test') { + steps { + sh 'docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck' + sh 'docker exec codely-java_ddd_example-test_server ./gradlew build --warning-mode all' + sh 'docker exec codely-java_ddd_example-test_server ./gradlew test --warning-mode all' + } + } + stage('Deploy') { - steps { powershell 'java -jar build/libs/hello-world-java-V1.jar'} - } -} + agent { + label 'windows' // Use Windows agent for PowerShell + } + steps { + powershell 'java -jar build/libs/hello-world-java-V1.jar' + } + } + } -post { + post { always { - echo 'Cleaning up workspace' - deleteDir() // Clean up the workspace after the build + sh "docker-compose -f ${COMPOSE_FILE} down" + cleanWs() // Clean workspace } success { - echo 'Build succeeded!!!' - // You could add notification steps here + echo 'Pipeline succeeded!' } failure { - echo 'Build failed!' - // You could add notification steps here + echo 'Pipeline failed!' } } } From 052f1ff538763de79c3dacf0bfcb382fdaf1a592 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:20:03 +0800 Subject: [PATCH 25/51] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7a81732b..2132c9b8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { // Docker compose file (adjust path if needed) COMPOSE_FILE = 'docker-compose.ci.yml' - JAVA_HOME = 'C:\Program Files\Java\jdk-21' + JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}/bin:${env.PATH}:/usr/local/bin" } From b9c2e9407d676f981f0c6f362cc3a7d177dc5ba6 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:21:33 +0800 Subject: [PATCH 26/51] Update Jenkinsfile --- Jenkinsfile | 82 ++++++++++++++--------------------------------------- 1 file changed, 21 insertions(+), 61 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2132c9b8..2ae998d9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,73 +1,33 @@ pipeline { agent any - - environment { - // Docker compose file (adjust path if needed) - COMPOSE_FILE = 'docker-compose.ci.yml' - JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' - PATH = "${JAVA_HOME}/bin:${env.PATH}:/usr/local/bin" + + environment { // Corrected spelling + JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' // Adjust path as needed + PATH = "${JAVA_HOME}\\bin;${env.PATH}" } stages { - stage('Setup Docker') { + stage('Checkout') { steps { - script { - // Install Docker if not present (Linux agents) - if (isUnix()) { - sh ''' - sudo apt-get update -y - sudo apt-get install -y docker-ce docker-ce-cli containerd.io - sudo systemctl start docker - sudo usermod -aG docker $USER - ''' - } - } + git branch: 'master', + url: 'https://github.com/mystery5639/java-ddd-example.git' } } - - stage('Start Containers') { - steps { - sh "docker-compose -f ${COMPOSE_FILE} up -d" - } - } - - stage('Wait for Services') { - steps { - sh ''' - # Wait for MySQL - until docker exec codely-java_ddd_example-mysql mysqladmin ping --silent; do - echo "Waiting for MySQL..." - sleep 5 - done - - # Wait for RabbitMQ - until docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup; do - echo "Waiting for RabbitMQ..." - sleep 5 - done - - # Wait for Elasticsearch - until curl -s http://localhost:9200/_cluster/health; do - echo "Waiting for Elasticsearch..." - sleep 5 - done - ''' + + stage('Build') { + steps { + bat 'gradlew clean build' } } - - stage('Build & Test') { - steps { - sh 'docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck' - sh 'docker exec codely-java_ddd_example-test_server ./gradlew build --warning-mode all' - sh 'docker exec codely-java_ddd_example-test_server ./gradlew test --warning-mode all' + + stage('Test') { + steps { + bat 'gradlew test' } } - + stage('Deploy') { - agent { - label 'windows' // Use Windows agent for PowerShell - } - steps { + steps { powershell 'java -jar build/libs/hello-world-java-V1.jar' } } @@ -75,14 +35,14 @@ pipeline { post { always { - sh "docker-compose -f ${COMPOSE_FILE} down" - cleanWs() // Clean workspace + echo 'Cleaning up workspace' + deleteDir() } success { - echo 'Pipeline succeeded!' + echo 'Build succeeded!!!' } failure { - echo 'Pipeline failed!' + echo 'Build failed!' } } } From 491edf210894d2269597d829db22881f9acebc59 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:22:22 +0800 Subject: [PATCH 27/51] Update Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2ae998d9..42bc9b79 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,8 +9,7 @@ pipeline { stages { stage('Checkout') { steps { - git branch: 'master', - url: 'https://github.com/mystery5639/java-ddd-example.git' + git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' } } From 0f0677e1edec9b36bec5c4bb0c4d3b53508cfa3b Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:25:49 +0800 Subject: [PATCH 28/51] Update Jenkinsfile --- Jenkinsfile | 98 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 42bc9b79..85da556a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,32 +1,91 @@ pipeline { agent any - environment { // Corrected spelling - JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' // Adjust path as needed + environment { + // Java configuration + JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" + + // Docker compose configuration + COMPOSE_FILE = 'docker-compose.ci.yml' + + // Service URLs (using container names as hosts) + DB_URL = 'jdbc:mysql://codely-java_ddd_example-mysql:3306/mooc' + ES_HOST = 'codely-java_ddd_example-elasticsearch' } stages { - stage('Checkout') { + stage('Setup Docker') { steps { - git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' + script { + // Install Docker on Linux agents + if (isUnix()) { + sh ''' + sudo apt-get update -y + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + sudo systemctl start docker + sudo usermod -aG docker $USER + ''' + } + } } } - - stage('Build') { - steps { - bat 'gradlew clean build' + + stage('Start Containers') { + steps { + sh "docker-compose -f ${COMPOSE_FILE} up -d" } } - - stage('Test') { - steps { - bat 'gradlew test' + + stage('Wait for Services') { + steps { + sh ''' + # Wait for MySQL + until docker exec codely-java_ddd_example-mysql mysqladmin ping --silent; do + echo "Waiting for MySQL..." + sleep 5 + done + + # Wait for Elasticsearch + until curl -s http://localhost:9200/_cluster/health; do + echo "Waiting for Elasticsearch..." + sleep 5 + done + ''' } } - + + stage('Build & Test') { + steps { + script { + // For Windows agents + if (isUnix()) { + sh """ + docker exec codely-java_ddd_example-test_server \ + ./gradlew build test \ + -Dspring.datasource.url=${DB_URL} \ + -Dspring.datasource.username=root \ + -Dspring.datasource.password='' \ + -Delasticsearch.host=${ES_HOST} + """ + } else { + bat """ + gradlew build test ^ + -Dspring.datasource.url=${DB_URL} ^ + -Dspring.datasource.username=root ^ + -Dspring.datasource.password= ^ + -Delasticsearch.host=${ES_HOST} + """ + } + } + } + } + stage('Deploy') { - steps { + agent { + label 'windows' // Use Windows agent for PowerShell + } + steps { powershell 'java -jar build/libs/hello-world-java-V1.jar' } } @@ -34,14 +93,9 @@ pipeline { post { always { - echo 'Cleaning up workspace' - deleteDir() - } - success { - echo 'Build succeeded!!!' - } - failure { - echo 'Build failed!' + // Clean up containers + sh "docker-compose -f ${COMPOSE_FILE} down" + cleanWs() } } } From ceb3ea23b7b7a7a5a0b8d80599010f91807d4047 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:28:13 +0800 Subject: [PATCH 29/51] Update Jenkinsfile --- Jenkinsfile | 93 +++++++++++++++++++---------------------------------- 1 file changed, 33 insertions(+), 60 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85da556a..119bd98c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,90 +1,64 @@ pipeline { - agent any + agent { + label 'windows' // Explicitly use Windows agent + } environment { - // Java configuration JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" - - // Docker compose configuration + // Windows Docker paths + DOCKER_COMPOSE = 'docker-compose' COMPOSE_FILE = 'docker-compose.ci.yml' - - // Service URLs (using container names as hosts) - DB_URL = 'jdbc:mysql://codely-java_ddd_example-mysql:3306/mooc' - ES_HOST = 'codely-java_ddd_example-elasticsearch' } stages { - stage('Setup Docker') { + stage('Checkout') { steps { - script { - // Install Docker on Linux agents - if (isUnix()) { - sh ''' - sudo apt-get update -y - sudo apt-get install -y docker-ce docker-ce-cli containerd.io - sudo systemctl start docker - sudo usermod -aG docker $USER - ''' - } - } + git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' } } stage('Start Containers') { steps { - sh "docker-compose -f ${COMPOSE_FILE} up -d" + bat "${DOCKER_COMPOSE} -f ${COMPOSE_FILE} up -d" } } stage('Wait for Services') { steps { - sh ''' - # Wait for MySQL - until docker exec codely-java_ddd_example-mysql mysqladmin ping --silent; do - echo "Waiting for MySQL..." - sleep 5 - done - - # Wait for Elasticsearch - until curl -s http://localhost:9200/_cluster/health; do - echo "Waiting for Elasticsearch..." - sleep 5 - done - ''' + bat """ + :loop_mysql + ${DOCKER_COMPOSE} exec -T mysql mysqladmin ping --silent + if %errorlevel% neq 0 ( + echo Waiting for MySQL... + timeout /t 5 /nobreak > nul + goto loop_mysql + ) + + :loop_es + curl -s http://localhost:9200/_cluster/health + if %errorlevel% neq 0 ( + echo Waiting for Elasticsearch... + timeout /t 5 /nobreak > nul + goto loop_es + ) + """ } } stage('Build & Test') { steps { - script { - // For Windows agents - if (isUnix()) { - sh """ - docker exec codely-java_ddd_example-test_server \ - ./gradlew build test \ - -Dspring.datasource.url=${DB_URL} \ - -Dspring.datasource.username=root \ - -Dspring.datasource.password='' \ - -Delasticsearch.host=${ES_HOST} - """ - } else { - bat """ - gradlew build test ^ - -Dspring.datasource.url=${DB_URL} ^ - -Dspring.datasource.username=root ^ - -Dspring.datasource.password= ^ - -Delasticsearch.host=${ES_HOST} - """ - } - } + bat """ + gradlew build test ^ + -Dspring.datasource.url=jdbc:mysql://localhost:3306/mooc ^ + -Dspring.datasource.username=root ^ + -Dspring.datasource.password= ^ + -Delasticsearch.host=localhost + """ } } stage('Deploy') { - agent { - label 'windows' // Use Windows agent for PowerShell - } steps { powershell 'java -jar build/libs/hello-world-java-V1.jar' } @@ -93,8 +67,7 @@ pipeline { post { always { - // Clean up containers - sh "docker-compose -f ${COMPOSE_FILE} down" + bat "${DOCKER_COMPOSE} -f ${COMPOSE_FILE} down" cleanWs() } } From 95b56eb5b400d9fc5c3ffd91e7c657890008817b Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:32:25 +0800 Subject: [PATCH 30/51] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 119bd98c..8ecf5dad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ pipeline { stage('Start Containers') { steps { - bat "${DOCKER_COMPOSE} -f ${COMPOSE_FILE} up -d" + bat "docker-compose.ci.yml up -d" } } From 31a51fbb726e1959e3af68a2fff647c29e203259 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:34:00 +0800 Subject: [PATCH 31/51] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8ecf5dad..07d5f5f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { agent { - label 'windows' // Explicitly use Windows agent + } environment { From cc848456d446bc3b1f05aefeebc178f542012990 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:35:00 +0800 Subject: [PATCH 32/51] Update Jenkinsfile --- Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 07d5f5f5..8886215e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,6 @@ pipeline { - agent { - - } - + agent any + environment { JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" From fd12ec810cff419c2f57a518c5fd81cd7578170b Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:37:26 +0800 Subject: [PATCH 33/51] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8886215e..92c0942f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { stage('Start Containers') { steps { - bat "docker-compose.ci.yml up -d" + bat "docker composer -f docker-compose.ci.yml up -d" } } From 142eef3aa36bf4b7898904fc246eca09fcf597a2 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:39:06 +0800 Subject: [PATCH 34/51] Update Jenkinsfile --- Jenkinsfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 92c0942f..729c9d75 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,21 +4,22 @@ pipeline { environment { JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" - // Windows Docker paths - DOCKER_COMPOSE = 'docker-compose' + // Docker configuration COMPOSE_FILE = 'docker-compose.ci.yml' } stages { stage('Checkout') { steps { - git branch: 'main', url: 'https://github.com/mystery5639/java-ddd-example.git' + git branch: 'main', + url: 'https://github.com/mystery5639/java-ddd-example.git', + credentialsId: 'your-github-credentials' // Add if private repo } } stage('Start Containers') { steps { - bat "docker composer -f docker-compose.ci.yml up -d" + bat "docker-compose -f ${COMPOSE_FILE} up -d" // Fixed command } } @@ -26,7 +27,7 @@ pipeline { steps { bat """ :loop_mysql - ${DOCKER_COMPOSE} exec -T mysql mysqladmin ping --silent + docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p"" --silent if %errorlevel% neq 0 ( echo Waiting for MySQL... timeout /t 5 /nobreak > nul @@ -65,7 +66,7 @@ pipeline { post { always { - bat "${DOCKER_COMPOSE} -f ${COMPOSE_FILE} down" + bat "docker-compose -f ${COMPOSE_FILE} down" cleanWs() } } From 5c1237ce1c65e70f20d1e368eeba6b92956ea1a7 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:40:32 +0800 Subject: [PATCH 35/51] Update Jenkinsfile --- Jenkinsfile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 729c9d75..2152e1fd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,22 +4,22 @@ pipeline { environment { JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" - // Docker configuration COMPOSE_FILE = 'docker-compose.ci.yml' } stages { - stage('Checkout') { + stage('Cleanup Previous Containers') { steps { - git branch: 'main', - url: 'https://github.com/mystery5639/java-ddd-example.git', - credentialsId: 'your-github-credentials' // Add if private repo + bat """ + docker-compose -f ${COMPOSE_FILE} down || echo "No containers to remove" + docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq || echo "Containers not found" + """ } } stage('Start Containers') { steps { - bat "docker-compose -f ${COMPOSE_FILE} up -d" // Fixed command + bat "docker-compose -f ${COMPOSE_FILE} up -d" } } @@ -41,6 +41,14 @@ pipeline { timeout /t 5 /nobreak > nul goto loop_es ) + + :loop_rabbit + docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup + if %errorlevel% neq 0 ( + echo Waiting for RabbitMQ... + timeout /t 5 /nobreak > nul + goto loop_rabbit + ) """ } } @@ -52,7 +60,8 @@ pipeline { -Dspring.datasource.url=jdbc:mysql://localhost:3306/mooc ^ -Dspring.datasource.username=root ^ -Dspring.datasource.password= ^ - -Delasticsearch.host=localhost + -Delasticsearch.host=localhost ^ + -Drabbitmq.host=localhost """ } } From edc9d3c93b4f21954337cfe537e2b51db7f2d830 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:44:37 +0800 Subject: [PATCH 36/51] Update Jenkinsfile --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2152e1fd..4c06c3e3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,8 +11,9 @@ pipeline { stage('Cleanup Previous Containers') { steps { bat """ - docker-compose -f ${COMPOSE_FILE} down || echo "No containers to remove" - docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq || echo "Containers not found" + docker-compose -f ${COMPOSE_FILE} down || echo "No compose containers to remove" + docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq codely-java_ddd_example-test_server || echo "Containers not found" + docker network rm test_default || echo "Network not found" """ } } From 829b8a9dc32e3fa4be20bf965a20b16783fdc4fc Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:45:28 +0800 Subject: [PATCH 37/51] Update Jenkinsfile --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4c06c3e3..2152e1fd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,9 +11,8 @@ pipeline { stage('Cleanup Previous Containers') { steps { bat """ - docker-compose -f ${COMPOSE_FILE} down || echo "No compose containers to remove" - docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq codely-java_ddd_example-test_server || echo "Containers not found" - docker network rm test_default || echo "Network not found" + docker-compose -f ${COMPOSE_FILE} down || echo "No containers to remove" + docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq || echo "Containers not found" """ } } From e91d80183d1b2f7975586ff4b3ebbeccdaa4d53f Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:46:37 +0800 Subject: [PATCH 38/51] Update docker-compose.ci.yml --- docker-compose.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index fe1c8113..a43783e7 100755 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -4,7 +4,7 @@ services: image: mysql:8 platform: linux/amd64 ports: - - "3306:3306" + - "3307:3306" environment: - MYSQL_ROOT_PASSWORD= - MYSQL_ALLOW_EMPTY_PASSWORD=yes From 724993daaa924cdffa5da96cf1988774b61010e1 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 03:54:52 +0800 Subject: [PATCH 39/51] Update docker-compose.ci.yml --- docker-compose.ci.yml | 73 ++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index a43783e7..78dc1275 100755 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -4,50 +4,79 @@ services: image: mysql:8 platform: linux/amd64 ports: - - "3307:3306" + - "3307:3306" # Changed from default 3306 to avoid conflicts environment: - - MYSQL_ROOT_PASSWORD= - - MYSQL_ALLOW_EMPTY_PASSWORD=yes - entrypoint: + MYSQL_ROOT_PASSWORD: "" + MYSQL_ALLOW_EMPTY_PASSWORD: "yes" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-uroot", "--silent"] + interval: 5s + timeout: 10s + retries: 10 + entrypoint: | sh -c " - echo 'CREATE DATABASE IF NOT EXISTS mooc;CREATE DATABASE IF NOT EXISTS backoffice;' > /docker-entrypoint-initdb.d/init.sql; - /usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + echo 'CREATE DATABASE IF NOT EXISTS mooc; + CREATE DATABASE IF NOT EXISTS backoffice;' > /docker-entrypoint-initdb.d/init.sql; + exec /usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci " command: ["--default-authentication-plugin=mysql_native_password"] shared_rabbitmq: container_name: codely-java_ddd_example-rabbitmq - image: 'rabbitmq:3.7-management' + image: rabbitmq:3.11-management # Updated to more recent version platform: linux/amd64 - restart: unless-stopped ports: - - "5630:5672" - - "8090:15672" + - "5630:5672" # AMQP port + - "8090:15672" # Management UI environment: - - RABBITMQ_DEFAULT_USER=codely - - RABBITMQ_DEFAULT_PASS=c0d3ly + RABBITMQ_DEFAULT_USER: "codely" + RABBITMQ_DEFAULT_PASS: "c0d3ly" + healthcheck: + test: ["CMD", "rabbitmqctl", "status"] + interval: 10s + timeout: 10s + retries: 5 backoffice_elasticsearch: container_name: codely-java_ddd_example-elasticsearch - image: 'elasticsearch:6.8.4' + image: elasticsearch:7.17.7 # Updated to compatible version platform: linux/amd64 - restart: unless-stopped + environment: + discovery.type: "single-node" + xpack.security.enabled: "false" + ES_JAVA_OPTS: "-Xms1g -Xmx1g" # Set heap size + ulimits: + memlock: + soft: -1 + hard: -1 ports: - - "9300:9300" - "9200:9200" - environment: - - discovery.type=single-node + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"] + interval: 10s + timeout: 20s + retries: 10 test_server_java: container_name: codely-java_ddd_example-test_server build: context: . dockerfile: Dockerfile - restart: unless-stopped + depends_on: + shared_mysql: + condition: service_healthy + shared_rabbitmq: + condition: service_healthy + backoffice_elasticsearch: + condition: service_healthy volumes: - .:/app:delegated - depends_on: - - shared_mysql - - shared_rabbitmq - - backoffice_elasticsearch + environment: + DB_URL: "jdbc:mysql://shared_mysql:3306/mooc" + ES_HOST: "backoffice_elasticsearch" tty: true + +networks: + default: + name: ddd_network + driver: bridge From b4e651b71f450fe9df0f6ec1e759954b32d5a0a0 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:06:51 +0800 Subject: [PATCH 40/51] Update Jenkinsfile --- Jenkinsfile | 133 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 50 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2152e1fd..5c526fd8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,82 +1,115 @@ pipeline { - agent any - + agent { + label 'ubuntu-latest' + } + + options { + timeout(time: 20, unit: 'MINUTES') + } + environment { + // New environment variables you requested JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" COMPOSE_FILE = 'docker-compose.ci.yml' + + // Existing environment variables + COMPOSE_DOCKER_CLI_BUILD = '1' + DOCKER_BUILDKIT = '1' } - + stages { - stage('Cleanup Previous Containers') { + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Setup Docker') { steps { - bat """ - docker-compose -f ${COMPOSE_FILE} down || echo "No containers to remove" - docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq || echo "Containers not found" - """ + sh ''' + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + sudo systemctl start docker + ''' } } - + stage('Start Containers') { steps { - bat "docker-compose -f ${COMPOSE_FILE} up -d" + // Now using COMPOSE_FILE environment variable + sh 'docker compose -f $COMPOSE_FILE up -d' } } - + stage('Wait for Services') { steps { - bat """ - :loop_mysql - docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p"" --silent - if %errorlevel% neq 0 ( - echo Waiting for MySQL... - timeout /t 5 /nobreak > nul - goto loop_mysql - ) + script { + timeout(time: 3, unit: 'MINUTES') { + waitUntil { + try { + sh 'docker exec codely-java_ddd_example-mysql mysqladmin ping --silent' + return true + } catch (Exception e) { + echo 'Waiting for MySQL...' + sleep 5 + return false + } + } + } - :loop_es - curl -s http://localhost:9200/_cluster/health - if %errorlevel% neq 0 ( - echo Waiting for Elasticsearch... - timeout /t 5 /nobreak > nul - goto loop_es - ) + timeout(time: 2, unit: 'MINUTES') { + waitUntil { + try { + sh 'docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup' + return true + } catch (Exception e) { + echo 'Waiting for RabbitMQ...' + sleep 5 + return false + } + } + } - :loop_rabbit - docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup - if %errorlevel% neq 0 ( - echo Waiting for RabbitMQ... - timeout /t 5 /nobreak > nul - goto loop_rabbit - ) - """ + timeout(time: 3, unit: 'MINUTES') { + waitUntil { + try { + sh 'curl -s http://localhost:9200/_cluster/health' + return true + } catch (Exception e) { + echo 'Waiting for Elasticsearch...' + sleep 5 + return false + } + } + } + } + } + } + + stage('Code Formatting Check') { + steps { + sh 'docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck' } } - - stage('Build & Test') { + + stage('Build Project') { steps { - bat """ - gradlew build test ^ - -Dspring.datasource.url=jdbc:mysql://localhost:3306/mooc ^ - -Dspring.datasource.username=root ^ - -Dspring.datasource.password= ^ - -Delasticsearch.host=localhost ^ - -Drabbitmq.host=localhost - """ + sh 'docker exec codely-java_ddd_example-test_server ./gradlew build --warning-mode all' } } - - stage('Deploy') { + + stage('Run Tests') { steps { - powershell 'java -jar build/libs/hello-world-java-V1.jar' + sh 'docker exec codely-java_ddd_example-test_server ./gradlew test --warning-mode all' } } } - + post { always { - bat "docker-compose -f ${COMPOSE_FILE} down" - cleanWs() + // Using COMPOSE_FILE environment variable here too + sh 'docker compose -f $COMPOSE_FILE down' } } } From 85a0b042948b57d097327aae881801631ebf5efb Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:08:18 +0800 Subject: [PATCH 41/51] Update Jenkinsfile --- Jenkinsfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5c526fd8..dde49c67 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,5 @@ pipeline { - agent { - label 'ubuntu-latest' - } - - options { - timeout(time: 20, unit: 'MINUTES') - } + agent any environment { // New environment variables you requested From a5139ccab56b27cec1918336acd248c5d5685826 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:12:22 +0800 Subject: [PATCH 42/51] Update docker-compose.ci.yml --- docker-compose.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 78dc1275..083728ba 100755 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -4,7 +4,7 @@ services: image: mysql:8 platform: linux/amd64 ports: - - "3307:3306" # Changed from default 3306 to avoid conflicts + - "3306:3306" # Changed from default 3306 to avoid conflicts environment: MYSQL_ROOT_PASSWORD: "" MYSQL_ALLOW_EMPTY_PASSWORD: "yes" From f47741ce59774fffec93a4a028d0b7064b75842b Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:12:55 +0800 Subject: [PATCH 43/51] Update Jenkinsfile --- Jenkinsfile | 130 ++++++++++++++++++++++------------------------------ 1 file changed, 54 insertions(+), 76 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dde49c67..2887ba72 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,109 +1,87 @@ pipeline { agent any - + environment { - // New environment variables you requested JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" - COMPOSE_FILE = 'docker-compose.ci.yml' - - // Existing environment variables - COMPOSE_DOCKER_CLI_BUILD = '1' - DOCKER_BUILDKIT = '1' + COMPOSE_FILE = 'docker-compose.ci.yml' // Fixed typo in filename } - + stages { - stage('Checkout') { + stage('Cleanup Previous Containers') { steps { - checkout scm + bat """ + docker-compose -f %COMPOSE_FILE% down || echo "No containers to remove" + docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq || echo "Containers not found" + """ } } - - stage('Setup Docker') { - steps { - sh ''' - sudo apt-get update - sudo apt-get install -y docker-ce docker-ce-cli containerd.io - sudo systemctl start docker - ''' - } - } - + stage('Start Containers') { steps { - // Now using COMPOSE_FILE environment variable - sh 'docker compose -f $COMPOSE_FILE up -d' + bat "docker-compose -f %COMPOSE_FILE% up -d" } } - + stage('Wait for Services') { steps { script { - timeout(time: 3, unit: 'MINUTES') { - waitUntil { - try { - sh 'docker exec codely-java_ddd_example-mysql mysqladmin ping --silent' - return true - } catch (Exception e) { - echo 'Waiting for MySQL...' - sleep 5 - return false - } - } - } - - timeout(time: 2, unit: 'MINUTES') { - waitUntil { - try { - sh 'docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup' - return true - } catch (Exception e) { - echo 'Waiting for RabbitMQ...' - sleep 5 - return false - } - } - } - - timeout(time: 3, unit: 'MINUTES') { - waitUntil { - try { - sh 'curl -s http://localhost:9200/_cluster/health' - return true - } catch (Exception e) { - echo 'Waiting for Elasticsearch...' - sleep 5 - return false - } - } + // Add timeouts to prevent infinite waiting + timeout(time: 5, unit: 'MINUTES') { + bat """ + :loop_mysql + docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p"" --silent + if %errorlevel% neq 0 ( + echo Waiting for MySQL... + timeout /t 5 /nobreak > nul + goto loop_mysql + ) + + :loop_es + curl -s http://localhost:9200/_cluster/health + if %errorlevel% neq 0 ( + echo Waiting for Elasticsearch... + timeout /t 5 /nobreak > nul + goto loop_es + ) + + :loop_rabbit + docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup + if %errorlevel% neq 0 ( + echo Waiting for RabbitMQ... + timeout /t 5 /nobreak > nul + goto loop_rabbit + ) + """ } } } } - - stage('Code Formatting Check') { - steps { - sh 'docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck' - } - } - - stage('Build Project') { + + stage('Build & Test') { steps { - sh 'docker exec codely-java_ddd_example-test_server ./gradlew build --warning-mode all' + bat """ + gradlew build test ^ + -Dspring.datasource.url=jdbc:mysql://localhost:3306/mooc ^ + -Dspring.datasource.username=root ^ + -Dspring.datasource.password= ^ + -Delasticsearch.host=localhost:9200 ^ // Added port for Elasticsearch + -Drabbitmq.host=localhost + """ } } - - stage('Run Tests') { + + stage('Deploy') { steps { - sh 'docker exec codely-java_ddd_example-test_server ./gradlew test --warning-mode all' + powershell 'java -jar build/libs/hello-world-java-V1.jar' } } } - + post { always { - // Using COMPOSE_FILE environment variable here too - sh 'docker compose -f $COMPOSE_FILE down' + bat "docker-compose -f %COMPOSE_FILE% down" + cleanWs() } } } From 253f46cb95e192cd46224c5e617c7dd8117d9b41 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:15:53 +0800 Subject: [PATCH 44/51] Update Jenkinsfile --- Jenkinsfile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2887ba72..acbaad67 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,14 +60,8 @@ pipeline { stage('Build & Test') { steps { - bat """ - gradlew build test ^ - -Dspring.datasource.url=jdbc:mysql://localhost:3306/mooc ^ - -Dspring.datasource.username=root ^ - -Dspring.datasource.password= ^ - -Delasticsearch.host=localhost:9200 ^ // Added port for Elasticsearch - -Drabbitmq.host=localhost - """ + // Single-line command to avoid line continuation issues + bat 'gradlew build test -Dspring.datasource.url=jdbc:mysql://localhost:3306/mooc -Dspring.datasource.username=root -Dspring.datasource.password= -Delasticsearch.host=localhost:9200 -Drabbitmq.host=localhost' } } From a7cbd8b1b49d0a5d4a293a9ff4de640ff3d5b045 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:21:39 +0800 Subject: [PATCH 45/51] Update Jenkinsfile --- Jenkinsfile | 84 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index acbaad67..0b3ecce2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,55 +4,65 @@ pipeline { environment { JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" - COMPOSE_FILE = 'docker-compose.ci.yml' // Fixed typo in filename + COMPOSE_FILE = 'docker-compose.ci.yml' + ELASTICSEARCH_HOST = 'host.docker.internal' // Changed from localhost } stages { - stage('Cleanup Previous Containers') { + stage('Cleanup') { steps { bat """ - docker-compose -f %COMPOSE_FILE% down || echo "No containers to remove" - docker rm -f codely-java_ddd_example-mysql codely-java_ddd_example-elasticsearch codely-java_ddd_example-rabbitmq || echo "Containers not found" + docker-compose -f %COMPOSE_FILE% down -v --remove-orphans || echo "Cleanup failed" """ } } - stage('Start Containers') { + stage('Start Services') { steps { bat "docker-compose -f %COMPOSE_FILE% up -d" } } - stage('Wait for Services') { + stage('Verify Services') { steps { script { - // Add timeouts to prevent infinite waiting - timeout(time: 5, unit: 'MINUTES') { - bat """ - :loop_mysql - docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p"" --silent - if %errorlevel% neq 0 ( - echo Waiting for MySQL... - timeout /t 5 /nobreak > nul - goto loop_mysql + // More robust waiting with retries and timeouts + def servicesReady = false + def attempts = 0 + + while(!servicesReady && attempts < 12) { + attempts++ + try { + def mysqlStatus = bat( + script: 'docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p"" --silent', + returnStatus: true ) - :loop_es - curl -s http://localhost:9200/_cluster/health - if %errorlevel% neq 0 ( - echo Waiting for Elasticsearch... - timeout /t 5 /nobreak > nul - goto loop_es + def esStatus = bat( + script: 'curl -s -o nul -w "%{http_code}" http://%ELASTICSEARCH_HOST%:9200/_cluster/health', + returnStatus: true ) - :loop_rabbit - docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup - if %errorlevel% neq 0 ( - echo Waiting for RabbitMQ... - timeout /t 5 /nobreak > nul - goto loop_rabbit + def rabbitStatus = bat( + script: 'docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup', + returnStatus: true ) - """ + + if (mysqlStatus == 0 && esStatus == 0 && rabbitStatus == 0) { + servicesReady = true + echo "All services are ready!" + } else { + echo "Waiting for services... (attempt $attempts)" + sleep(time: 10, unit: 'SECONDS') + } + } catch (Exception e) { + echo "Service check failed, retrying... ${e.message}" + sleep(time: 10, unit: 'SECONDS') + } + } + + if (!servicesReady) { + error("Services failed to start within expected time") } } } @@ -60,21 +70,21 @@ pipeline { stage('Build & Test') { steps { - // Single-line command to avoid line continuation issues - bat 'gradlew build test -Dspring.datasource.url=jdbc:mysql://localhost:3306/mooc -Dspring.datasource.username=root -Dspring.datasource.password= -Delasticsearch.host=localhost:9200 -Drabbitmq.host=localhost' - } - } - - stage('Deploy') { - steps { - powershell 'java -jar build/libs/hello-world-java-V1.jar' + bat """ + gradlew build test ^ + -Dspring.datasource.url=jdbc:mysql://host.docker.internal:3306/mooc ^ + -Dspring.datasource.username=root ^ + -Dspring.datasource.password= ^ + -Delasticsearch.host=%ELASTICSEARCH_HOST%:9200 ^ + -Drabbitmq.host=host.docker.internal + """ } } } post { always { - bat "docker-compose -f %COMPOSE_FILE% down" + bat "docker-compose -f %COMPOSE_FILE% down -v" cleanWs() } } From f7781d08d7862c97859b2c2f320db6e9e371276b Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:26:26 +0800 Subject: [PATCH 46/51] Update Jenkinsfile --- Jenkinsfile | 96 ++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0b3ecce2..74434669 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,18 +5,12 @@ pipeline { JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' PATH = "${JAVA_HOME}\\bin;${env.PATH}" COMPOSE_FILE = 'docker-compose.ci.yml' - ELASTICSEARCH_HOST = 'host.docker.internal' // Changed from localhost + ELASTICSEARCH_HOST = 'host.docker.internal' + MYSQL_HOST = 'host.docker.internal' + RABBITMQ_HOST = 'host.docker.internal' } stages { - stage('Cleanup') { - steps { - bat """ - docker-compose -f %COMPOSE_FILE% down -v --remove-orphans || echo "Cleanup failed" - """ - } - } - stage('Start Services') { steps { bat "docker-compose -f %COMPOSE_FILE% up -d" @@ -26,44 +20,10 @@ pipeline { stage('Verify Services') { steps { script { - // More robust waiting with retries and timeouts - def servicesReady = false - def attempts = 0 - - while(!servicesReady && attempts < 12) { - attempts++ - try { - def mysqlStatus = bat( - script: 'docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p"" --silent', - returnStatus: true - ) - - def esStatus = bat( - script: 'curl -s -o nul -w "%{http_code}" http://%ELASTICSEARCH_HOST%:9200/_cluster/health', - returnStatus: true - ) - - def rabbitStatus = bat( - script: 'docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup', - returnStatus: true - ) - - if (mysqlStatus == 0 && esStatus == 0 && rabbitStatus == 0) { - servicesReady = true - echo "All services are ready!" - } else { - echo "Waiting for services... (attempt $attempts)" - sleep(time: 10, unit: 'SECONDS') - } - } catch (Exception e) { - echo "Service check failed, retrying... ${e.message}" - sleep(time: 10, unit: 'SECONDS') - } - } - - if (!servicesReady) { - error("Services failed to start within expected time") - } + // Service-specific verification with detailed logging + verifyService('MySQL', "docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p\"\" --silent", 60) + verifyService('Elasticsearch', "curl -s http://%ELASTICSEARCH_HOST%:9200/_cluster/health | find \"green\"", 60) + verifyService('RabbitMQ', "docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup", 30) } } } @@ -72,11 +32,11 @@ pipeline { steps { bat """ gradlew build test ^ - -Dspring.datasource.url=jdbc:mysql://host.docker.internal:3306/mooc ^ + -Dspring.datasource.url=jdbc:mysql://%MYSQL_HOST%:3306/mooc ^ -Dspring.datasource.username=root ^ -Dspring.datasource.password= ^ -Delasticsearch.host=%ELASTICSEARCH_HOST%:9200 ^ - -Drabbitmq.host=host.docker.internal + -Drabbitmq.host=%RABBITMQ_HOST% """ } } @@ -86,6 +46,44 @@ pipeline { always { bat "docker-compose -f %COMPOSE_FILE% down -v" cleanWs() + archiveArtifacts artifacts: '**/build/reports/tests/test', allowEmptyArchive: true + } + } +} + +// Custom verification method +def verifyService(String serviceName, String checkCommand, int timeoutSeconds) { + def startTime = System.currentTimeMillis() + def maxTime = startTime + (timeoutSeconds * 1000) + + while (System.currentTimeMillis() < maxTime) { + try { + // Run check command + def status = bat(script: checkCommand, returnStatus: true) + + if (status == 0) { + echo "${serviceName} is ready!" + return + } + + // Get service logs for debugging + if (serviceName == 'MySQL') { + bat "docker logs codely-java_ddd_example-mysql --tail 20 || echo \"Could not get ${serviceName} logs\"" + } else if (serviceName == 'Elasticsearch') { + bat "docker logs codely-java_ddd_example-elasticsearch --tail 20 || echo \"Could not get ${serviceName} logs\"" + } else if (serviceName == 'RabbitMQ') { + bat "docker logs codely-java_ddd_example-rabbitmq --tail 20 || echo \"Could not get ${serviceName} logs\"" + } + + // Wait before retrying + sleep(time: 5, unit: 'SECONDS') + echo "Waiting for ${serviceName}... (${(System.currentTimeMillis() - startTime)/1000}s elapsed)" + + } catch (Exception e) { + echo "Error checking ${serviceName}: ${e.getMessage()}" + sleep(time: 5, unit: 'SECONDS') } } + + error("${serviceName} failed to start within ${timeoutSeconds} seconds") } From f5c983bb2e9093e92908081a0966598337938400 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:32:06 +0800 Subject: [PATCH 47/51] Update Jenkinsfile --- Jenkinsfile | 106 ++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 57 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 74434669..ed12adc9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,40 +2,65 @@ pipeline { agent any environment { - JAVA_HOME = 'C:\\Program Files\\Java\\jdk-21' - PATH = "${JAVA_HOME}\\bin;${env.PATH}" - COMPOSE_FILE = 'docker-compose.ci.yml' - ELASTICSEARCH_HOST = 'host.docker.internal' - MYSQL_HOST = 'host.docker.internal' - RABBITMQ_HOST = 'host.docker.internal' + // 1. Use consistent networking + NETWORK_NAME = 'ddd_network' + ELASTICSEARCH_URL = 'http://elasticsearch:9200' // Use Docker service names + MYSQL_URL = 'jdbc:mysql://mysql:3306/mooc' + RABBITMQ_HOST = 'rabbitmq' } stages { + stage('Setup Network') { + steps { + bat """ + docker network create %NETWORK_NAME% || echo "Network already exists" + """ + } + } + stage('Start Services') { steps { - bat "docker-compose -f %COMPOSE_FILE% up -d" + // 2. Force rebuild and use custom network + bat """ + docker-compose -f docker-compose.ci.yml down -v --remove-orphans + docker-compose -f docker-compose.ci.yml build --no-cache + docker-compose -f docker-compose.ci.yml up -d + """ } } stage('Verify Services') { steps { script { - // Service-specific verification with detailed logging - verifyService('MySQL', "docker exec codely-java_ddd_example-mysql mysqladmin ping -uroot -p\"\" --silent", 60) - verifyService('Elasticsearch', "curl -s http://%ELASTICSEARCH_HOST%:9200/_cluster/health | find \"green\"", 60) - verifyService('RabbitMQ', "docker exec codely-java_ddd_example-rabbitmq rabbitmqctl await_startup", 30) + // 3. Container-native health checks + def checkService = { cmd, timeout -> + waitUntil(initialRecurrencePeriod: 5000) { + try { + bat(script: cmd, returnStatus: true) == 0 + } catch(e) { + echo "Check failed: ${e.message}" + false + } + } + } + + checkService('docker exec mysql mysqladmin ping -uroot -p"" --silent', 120) + checkService('curl -s http://elasticsearch:9200/_cluster/health | find "green"', 120) + checkService('docker exec rabbitmq rabbitmqctl await_startup', 60) } } } - stage('Build & Test') { + stage('Run Tests') { steps { + // 4. Run tests INSIDE the test container bat """ - gradlew build test ^ - -Dspring.datasource.url=jdbc:mysql://%MYSQL_HOST%:3306/mooc ^ - -Dspring.datasource.username=root ^ - -Dspring.datasource.password= ^ - -Delasticsearch.host=%ELASTICSEARCH_HOST%:9200 ^ + docker exec -e "SPRING_PROFILES_ACTIVE=test" \\ + test_container ./gradlew test \\ + -Dspring.datasource.url=%MYSQL_URL% \\ + -Dspring.datasource.username=root \\ + -Dspring.datasource.password= \\ + -Delasticsearch.host=elasticsearch \\ -Drabbitmq.host=%RABBITMQ_HOST% """ } @@ -44,46 +69,13 @@ pipeline { post { always { - bat "docker-compose -f %COMPOSE_FILE% down -v" - cleanWs() - archiveArtifacts artifacts: '**/build/reports/tests/test', allowEmptyArchive: true - } - } -} - -// Custom verification method -def verifyService(String serviceName, String checkCommand, int timeoutSeconds) { - def startTime = System.currentTimeMillis() - def maxTime = startTime + (timeoutSeconds * 1000) - - while (System.currentTimeMillis() < maxTime) { - try { - // Run check command - def status = bat(script: checkCommand, returnStatus: true) - - if (status == 0) { - echo "${serviceName} is ready!" - return - } - - // Get service logs for debugging - if (serviceName == 'MySQL') { - bat "docker logs codely-java_ddd_example-mysql --tail 20 || echo \"Could not get ${serviceName} logs\"" - } else if (serviceName == 'Elasticsearch') { - bat "docker logs codely-java_ddd_example-elasticsearch --tail 20 || echo \"Could not get ${serviceName} logs\"" - } else if (serviceName == 'RabbitMQ') { - bat "docker logs codely-java_ddd_example-rabbitmq --tail 20 || echo \"Could not get ${serviceName} logs\"" - } - - // Wait before retrying - sleep(time: 5, unit: 'SECONDS') - echo "Waiting for ${serviceName}... (${(System.currentTimeMillis() - startTime)/1000}s elapsed)" - - } catch (Exception e) { - echo "Error checking ${serviceName}: ${e.getMessage()}" - sleep(time: 5, unit: 'SECONDS') + // 5. Capture diagnostics before cleanup + bat """ + docker logs elasticsearch > elasticsearch.log 2>&1 || echo "No ES logs" + docker-compose -f docker-compose.ci.yml down -v + docker network rm %NETWORK_NAME% || echo "Network removal failed" + """ + archiveArtifacts artifacts: '*.log', allowEmptyArchive: true } } - - error("${serviceName} failed to start within ${timeoutSeconds} seconds") } From 780cbf4dd883c23df7b723094256ddc4788dcf22 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:34:15 +0800 Subject: [PATCH 48/51] Update Jenkinsfile --- Jenkinsfile | 90 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ed12adc9..18115045 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,29 +2,35 @@ pipeline { agent any environment { - // 1. Use consistent networking + COMPOSE_FILE = 'docker-compose.ci.yml' NETWORK_NAME = 'ddd_network' - ELASTICSEARCH_URL = 'http://elasticsearch:9200' // Use Docker service names - MYSQL_URL = 'jdbc:mysql://mysql:3306/mooc' - RABBITMQ_HOST = 'rabbitmq' } stages { - stage('Setup Network') { + stage('Prepare Network') { steps { - bat """ - docker network create %NETWORK_NAME% || echo "Network already exists" - """ + script { + // 1. Safely handle existing network + def networkStatus = bat( + script: 'docker network inspect %NETWORK_NAME% > nul 2>&1 && echo EXISTS || echo MISSING', + returnStdout: true + ).trim() + + if (networkStatus == 'EXISTS') { + bat 'docker network rm %NETWORK_NAME%' + } + bat 'docker network create --label com.docker.compose.network=default %NETWORK_NAME%' + } } } stage('Start Services') { steps { - // 2. Force rebuild and use custom network + // 2. Force clean start with proper network bat """ - docker-compose -f docker-compose.ci.yml down -v --remove-orphans - docker-compose -f docker-compose.ci.yml build --no-cache - docker-compose -f docker-compose.ci.yml up -d + docker-compose -f %COMPOSE_FILE% down -v --remove-orphans + docker-compose -f %COMPOSE_FILE% build --no-cache + docker-compose -f %COMPOSE_FILE% up -d """ } } @@ -32,36 +38,44 @@ pipeline { stage('Verify Services') { steps { script { - // 3. Container-native health checks - def checkService = { cmd, timeout -> - waitUntil(initialRecurrencePeriod: 5000) { - try { - bat(script: cmd, returnStatus: true) == 0 - } catch(e) { - echo "Check failed: ${e.message}" - false + // 3. Container-native checks with retries + def services = [ + [name: 'MySQL', cmd: 'docker exec mysql mysqladmin ping -uroot -p"" --silent'], + [name: 'Elasticsearch', cmd: 'curl -s http://elasticsearch:9200/_cluster/health | find "green"'], + [name: 'RabbitMQ', cmd: 'docker exec rabbitmq rabbitmqctl await_startup'] + ] + + services.each { svc -> + retry(3) { + timeout(time: 2, unit: 'MINUTES') { + waitUntil { + try { + bat(script: svc.cmd, returnStatus: true) == 0 + } catch(e) { + echo "${svc.name} check failed: ${e.message}" + bat "docker logs ${svc.name.toLowerCase()} --tail 50" + sleep 10 + false + } + } + echo "${svc.name} verified!" } } } - - checkService('docker exec mysql mysqladmin ping -uroot -p"" --silent', 120) - checkService('curl -s http://elasticsearch:9200/_cluster/health | find "green"', 120) - checkService('docker exec rabbitmq rabbitmqctl await_startup', 60) } } } stage('Run Tests') { steps { - // 4. Run tests INSIDE the test container bat """ docker exec -e "SPRING_PROFILES_ACTIVE=test" \\ test_container ./gradlew test \\ - -Dspring.datasource.url=%MYSQL_URL% \\ + -Dspring.datasource.url=jdbc:mysql://mysql:3306/mooc \\ -Dspring.datasource.username=root \\ -Dspring.datasource.password= \\ -Delasticsearch.host=elasticsearch \\ - -Drabbitmq.host=%RABBITMQ_HOST% + -Drabbitmq.host=rabbitmq """ } } @@ -69,13 +83,21 @@ pipeline { post { always { - // 5. Capture diagnostics before cleanup - bat """ - docker logs elasticsearch > elasticsearch.log 2>&1 || echo "No ES logs" - docker-compose -f docker-compose.ci.yml down -v - docker network rm %NETWORK_NAME% || echo "Network removal failed" - """ - archiveArtifacts artifacts: '*.log', allowEmptyArchive: true + // 4. Preserve logs even if pipeline fails + script { + try { + bat """ + docker-compose -f %COMPOSE_FILE% logs --no-color > all_logs.txt + docker inspect %NETWORK_NAME% > network_info.json + """ + archiveArtifacts artifacts: '*.txt,*.json', allowEmptyArchive: true + } finally { + bat """ + docker-compose -f %COMPOSE_FILE% down -v + docker network rm %NETWORK_NAME% || echo "Network removal failed" + """ + } + } } } } From 53663a04aef197dd548da060ab21d98df725836f Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:35:05 +0800 Subject: [PATCH 49/51] Update docker-compose.ci.yml --- docker-compose.ci.yml | 92 +++++++++++-------------------------------- 1 file changed, 24 insertions(+), 68 deletions(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 083728ba..85ce5579 100755 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -1,82 +1,38 @@ services: - shared_mysql: - container_name: codely-java_ddd_example-mysql - image: mysql:8 - platform: linux/amd64 - ports: - - "3306:3306" # Changed from default 3306 to avoid conflicts + mysql: + image: mysql:8.0 + networks: + - ddd_network environment: MYSQL_ROOT_PASSWORD: "" - MYSQL_ALLOW_EMPTY_PASSWORD: "yes" - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-uroot", "--silent"] - interval: 5s - timeout: 10s - retries: 10 - entrypoint: | - sh -c " - echo 'CREATE DATABASE IF NOT EXISTS mooc; - CREATE DATABASE IF NOT EXISTS backoffice;' > /docker-entrypoint-initdb.d/init.sql; - exec /usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci - " - command: ["--default-authentication-plugin=mysql_native_password"] + MYSQL_DATABASE: mooc - shared_rabbitmq: - container_name: codely-java_ddd_example-rabbitmq - image: rabbitmq:3.11-management # Updated to more recent version - platform: linux/amd64 - ports: - - "5630:5672" # AMQP port - - "8090:15672" # Management UI + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0 + networks: + - ddd_network environment: - RABBITMQ_DEFAULT_USER: "codely" - RABBITMQ_DEFAULT_PASS: "c0d3ly" + - discovery.type=single-node healthcheck: - test: ["CMD", "rabbitmqctl", "status"] - interval: 10s - timeout: 10s - retries: 5 + test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health?wait_for_status=green&timeout=60s"] - backoffice_elasticsearch: - container_name: codely-java_ddd_example-elasticsearch - image: elasticsearch:7.17.7 # Updated to compatible version - platform: linux/amd64 - environment: - discovery.type: "single-node" - xpack.security.enabled: "false" - ES_JAVA_OPTS: "-Xms1g -Xmx1g" # Set heap size - ulimits: - memlock: - soft: -1 - hard: -1 - ports: - - "9200:9200" + rabbitmq: + image: rabbitmq:3-management + networks: + - ddd_network healthcheck: - test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"] - interval: 10s - timeout: 20s - retries: 10 + test: ["CMD", "rabbitmqctl", "await_startup"] - test_server_java: - container_name: codely-java_ddd_example-test_server - build: - context: . - dockerfile: Dockerfile + test_container: + build: . + networks: + - ddd_network depends_on: - shared_mysql: - condition: service_healthy - shared_rabbitmq: - condition: service_healthy - backoffice_elasticsearch: - condition: service_healthy - volumes: - - .:/app:delegated - environment: - DB_URL: "jdbc:mysql://shared_mysql:3306/mooc" - ES_HOST: "backoffice_elasticsearch" - tty: true + - mysql + - elasticsearch + - rabbitmq networks: - default: + ddd_network: name: ddd_network driver: bridge From 4d898344718ad8d77fc0afe067021cdd734500a7 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:39:30 +0800 Subject: [PATCH 50/51] Update docker-compose.ci.yml --- docker-compose.ci.yml | 72 +++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 85ce5579..71646374 100755 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -1,38 +1,36 @@ services: - mysql: - image: mysql:8.0 - networks: - - ddd_network - environment: - MYSQL_ROOT_PASSWORD: "" - MYSQL_DATABASE: mooc - - elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0 - networks: - - ddd_network - environment: - - discovery.type=single-node - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health?wait_for_status=green&timeout=60s"] - - rabbitmq: - image: rabbitmq:3-management - networks: - - ddd_network - healthcheck: - test: ["CMD", "rabbitmqctl", "await_startup"] - - test_container: - build: . - networks: - - ddd_network - depends_on: - - mysql - - elasticsearch - - rabbitmq - -networks: - ddd_network: - name: ddd_network - driver: bridge + +mysql: + image: mysql:8.0 + networks: + - ddd_network + environment: + MYSQL_ROOT_PASSWORD: "" + MYSQL_DATABASE: mooc + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0 + networks: + - ddd_network + environment: + - discovery.type=single-node + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health?wait_for_status=green&timeout=60s"] + rabbitmq: + image: rabbitmq:3-management + networks: + - ddd_network + healthcheck: +test: ["CMD", "rabbitmqctl", "await_startup"] + test_container: + build: . + networks: + - ddd_network + depends_on: + - mysql + - elasticsearch + - rabbitmq + + networks: + ddd_network: + name: ddd_network + driver: bridge From bae1a9be78a8d03ce195141daf2ecaf6e94ef131 Mon Sep 17 00:00:00 2001 From: mystery5639 Date: Mon, 28 Apr 2025 04:41:28 +0800 Subject: [PATCH 51/51] Update docker-compose.ci.yml --- docker-compose.ci.yml | 87 ++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 71646374..fe1c8113 100755 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -1,36 +1,53 @@ services: - -mysql: - image: mysql:8.0 - networks: - - ddd_network - environment: - MYSQL_ROOT_PASSWORD: "" - MYSQL_DATABASE: mooc - elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0 - networks: - - ddd_network - environment: - - discovery.type=single-node - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health?wait_for_status=green&timeout=60s"] - rabbitmq: - image: rabbitmq:3-management - networks: - - ddd_network - healthcheck: -test: ["CMD", "rabbitmqctl", "await_startup"] - test_container: - build: . - networks: - - ddd_network - depends_on: - - mysql - - elasticsearch - - rabbitmq - - networks: - ddd_network: - name: ddd_network - driver: bridge + shared_mysql: + container_name: codely-java_ddd_example-mysql + image: mysql:8 + platform: linux/amd64 + ports: + - "3306:3306" + environment: + - MYSQL_ROOT_PASSWORD= + - MYSQL_ALLOW_EMPTY_PASSWORD=yes + entrypoint: + sh -c " + echo 'CREATE DATABASE IF NOT EXISTS mooc;CREATE DATABASE IF NOT EXISTS backoffice;' > /docker-entrypoint-initdb.d/init.sql; + /usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + " + command: ["--default-authentication-plugin=mysql_native_password"] + + shared_rabbitmq: + container_name: codely-java_ddd_example-rabbitmq + image: 'rabbitmq:3.7-management' + platform: linux/amd64 + restart: unless-stopped + ports: + - "5630:5672" + - "8090:15672" + environment: + - RABBITMQ_DEFAULT_USER=codely + - RABBITMQ_DEFAULT_PASS=c0d3ly + + backoffice_elasticsearch: + container_name: codely-java_ddd_example-elasticsearch + image: 'elasticsearch:6.8.4' + platform: linux/amd64 + restart: unless-stopped + ports: + - "9300:9300" + - "9200:9200" + environment: + - discovery.type=single-node + + test_server_java: + container_name: codely-java_ddd_example-test_server + build: + context: . + dockerfile: Dockerfile + restart: unless-stopped + volumes: + - .:/app:delegated + depends_on: + - shared_mysql + - shared_rabbitmq + - backoffice_elasticsearch + tty: true