From c332ffcb14e458faa95cee662e12cae76cd45f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 23 Jul 2024 15:15:28 +0700 Subject: [PATCH 1/5] MARP-662 Mount Docker container to read file --- marketplace-build/docker-compose.yml | 3 ++- marketplace-build/release/docker-compose.yml | 4 ++-- marketplace-service/src/main/resources/application.properties | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index 5cf4f924e..e1756f155 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -34,13 +34,14 @@ services: service: container_name: marketplace-service restart: always + volumns: + - /home/axonivy/marketplace/data/market-installations.json: /home/data/market-installation.json environment: - MONGODB_HOST=${SERVICE_MONGODB_HOST} - MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE} - MONGODB_USERNAME=${SERVICE_MONGODB_USER} - MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD} - MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN} - - MARKETPLACE_INSTALLATION_URL=${MARKETPLACE_INSTALLATION_URL} build: context: ../marketplace-service dockerfile: Dockerfile diff --git a/marketplace-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml index 983c94622..af64ddac3 100644 --- a/marketplace-build/release/docker-compose.yml +++ b/marketplace-build/release/docker-compose.yml @@ -25,13 +25,13 @@ services: service: image: ghcr.io/axonivy-market/marketplace-service:latest restart: always + volumns: + - /home/axonivy/marketplace/data/market-installations.json: /home/data/market-installation.json environment: - MONGODB_HOST=${SERVICE_MONGODB_HOST} - MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE} - MONGODB_USERNAME=${SERVICE_MONGODB_USER} - MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD} - MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN} - - MARKETPLACE_INSTALLATION_URL=${MARKETPLACE_INSTALLATION_URL} - volumes: mongodata: \ No newline at end of file diff --git a/marketplace-service/src/main/resources/application.properties b/marketplace-service/src/main/resources/application.properties index 17f6ab518..cf52580be 100644 --- a/marketplace-service/src/main/resources/application.properties +++ b/marketplace-service/src/main/resources/application.properties @@ -8,7 +8,7 @@ server.forward-headers-strategy=framework springdoc.api-docs.path=/api-docs springdoc.swagger-ui.path=/swagger-ui.html market.cors.allowed.origin.maxAge=3600 -synchronized.installation.counts.path=${MARKETPLACE_INSTALLATION_URL} +synchronized.installation.counts.path='/home/data/market-installation.json' market.github.token=${MARKET_GITHUB_TOKEN} logging.level.org.springframework.security=DEBUG spring.security.oauth2.client.registration.github.client-id= From 54406e8bc03f1353df521a89b6ef1498ce60b3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 23 Jul 2024 15:29:34 +0700 Subject: [PATCH 2/5] MARP-662 update volumes --- marketplace-build/docker-compose.yml | 4 ++-- marketplace-build/release/docker-compose.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index e1756f155..71682a2fd 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -34,8 +34,8 @@ services: service: container_name: marketplace-service restart: always - volumns: - - /home/axonivy/marketplace/data/market-installations.json: /home/data/market-installation.json + volumes: + - /home/axonivy/marketplace/data/market-installations.json:/home/data/market-installation.json environment: - MONGODB_HOST=${SERVICE_MONGODB_HOST} - MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE} diff --git a/marketplace-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml index af64ddac3..dfc95f0fb 100644 --- a/marketplace-build/release/docker-compose.yml +++ b/marketplace-build/release/docker-compose.yml @@ -25,8 +25,8 @@ services: service: image: ghcr.io/axonivy-market/marketplace-service:latest restart: always - volumns: - - /home/axonivy/marketplace/data/market-installations.json: /home/data/market-installation.json + volumes: + - /home/axonivy/marketplace/data/market-installations.json:/home/data/market-installation.json environment: - MONGODB_HOST=${SERVICE_MONGODB_HOST} - MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE} From 37460884b0a9dcd586d9e57379657a49d98270a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 23 Jul 2024 15:44:11 +0700 Subject: [PATCH 3/5] MARP-662 update docker build --- .github/workflows/docker-build.yml | 2 -- marketplace-build/release/sprint-compose.yml | 1 - .../java/com/axonivy/market/service/SchedulingTasksTest.java | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index bbe173702..fa7f07be8 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -22,7 +22,6 @@ jobs: SERVICE_PASSWORD: ${{ secrets.SERVICE_PASSWORD }} MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }} GH_TOKEN: ${{ secrets.GH_TOKEN }} - MARKETPLACE_INSTALLATION_URL: ${{ secrets.MARKETPLACE_INSTALLATION_URL }} run: | sed -i "s/^MONGODB_INITDB_ROOT_USERNAME=.*$/MONGODB_INITDB_ROOT_USERNAME=$ROOT_USERNAME/" $ENV_FILE sed -i "s/^MONGODB_INITDB_ROOT_PASSWORD=.*$/MONGODB_INITDB_ROOT_PASSWORD=$ROOT_PASSWORD/" $ENV_FILE @@ -31,7 +30,6 @@ jobs: sed -i "s/^SERVICE_MONGODB_USER=.*$/SERVICE_MONGODB_USER=$SERVICE_USERNAME/" $ENV_FILE sed -i "s/^SERVICE_MONGODB_PASSWORD=.*$/SERVICE_MONGODB_PASSWORD=$SERVICE_PASSWORD/" $ENV_FILE sed -i "s/^MARKET_GITHUB_TOKEN=.*$/MARKET_GITHUB_TOKEN=$GH_TOKEN/" $ENV_FILE - sed -i "s/^MARKETPLACE_INSTALLATION_URL=.*$/MARKETPLACE_INSTALLATION_URL=$MARKETPLACE_INSTALLATION_URL/" $ENV_FILE - name: Refresh Docker images working-directory: ./marketplace-build diff --git a/marketplace-build/release/sprint-compose.yml b/marketplace-build/release/sprint-compose.yml index 85b42f243..e727f40d6 100644 --- a/marketplace-build/release/sprint-compose.yml +++ b/marketplace-build/release/sprint-compose.yml @@ -31,7 +31,6 @@ services: - MONGODB_USERNAME=${SERVICE_MONGODB_USER} - MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD} - MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN} - - MARKETPLACE_INSTALLATION_URL=${MARKETPLACE_INSTALLATION_URL} volumes: mongodata: \ No newline at end of file diff --git a/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java b/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java index d436cf72e..56a48343d 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java @@ -10,7 +10,7 @@ import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.verify; -@SpringBootTest(properties = { "MARKETPLACE_INSTALLATION_URL=marketplace-installation.json", "MONGODB_USERNAME=user", +@SpringBootTest(properties = { "MONGODB_USERNAME=user", "MONGODB_PASSWORD=password", "MONGODB_HOST=mongoHost", "MONGODB_DATABASE=product" }) class SchedulingTasksTest { From 4331a3a253d39004a52035f96a96a78a2c5bcc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 23 Jul 2024 15:53:15 +0700 Subject: [PATCH 4/5] MARP-662 Add sprint-compose.yml --- marketplace-build/release/sprint-compose.yml | 2 ++ marketplace-service/src/main/resources/application.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/marketplace-build/release/sprint-compose.yml b/marketplace-build/release/sprint-compose.yml index e727f40d6..ff273c945 100644 --- a/marketplace-build/release/sprint-compose.yml +++ b/marketplace-build/release/sprint-compose.yml @@ -25,6 +25,8 @@ services: service: image: ghcr.io/axonivy-market/marketplace-service:sprint restart: always + volumes: + - /home/axonivy/marketplace/data/market-installations.json:/home/data/market-installation.json environment: - MONGODB_HOST=${SERVICE_MONGODB_HOST} - MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE} diff --git a/marketplace-service/src/main/resources/application.properties b/marketplace-service/src/main/resources/application.properties index cf52580be..b2fd17582 100644 --- a/marketplace-service/src/main/resources/application.properties +++ b/marketplace-service/src/main/resources/application.properties @@ -8,7 +8,7 @@ server.forward-headers-strategy=framework springdoc.api-docs.path=/api-docs springdoc.swagger-ui.path=/swagger-ui.html market.cors.allowed.origin.maxAge=3600 -synchronized.installation.counts.path='/home/data/market-installation.json' +synchronized.installation.counts.path=/home/data/market-installation.json market.github.token=${MARKET_GITHUB_TOKEN} logging.level.org.springframework.security=DEBUG spring.security.oauth2.client.registration.github.client-id= From e1d8ed6a5c739438fa49185d0f41fc76244c8e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20V=C4=A9nh=20Thi=E1=BB=87n=20Ph=C3=BAc?= Date: Tue, 23 Jul 2024 17:08:50 +0700 Subject: [PATCH 5/5] MARP-662 Reformat code --- .../axonivy/market/controller/ProductDetailsController.java | 5 +++-- .../java/com/axonivy/market/service/SchedulingTasksTest.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java b/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java index b57f80e0f..2d89ffd0c 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java +++ b/marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; - +import org.springframework.web.bind.annotation.CrossOrigin; import java.util.List; import static com.axonivy.market.constants.RequestMappingConstants.PRODUCT_DETAILS; @@ -40,7 +40,8 @@ public ResponseEntity findProductDetailsByVersion(@PathVaria return new ResponseEntity<>(detailModelAssembler.toModel(productDetail, tag), HttpStatus.OK); } - @Operation(summary = "increase installation count by 1", description = "increase installation count by 1") + @Operation(summary = "increase installation count by 1", description = "update installation count when click download product files by users") + @CrossOrigin(originPatterns = "*") @PutMapping("/installationcount/{key}") public ResponseEntity syncInstallationCount(@PathVariable("key") String key) { int result = productService.updateInstallationCountForProduct(key); diff --git a/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java b/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java index 56a48343d..0407a7f75 100644 --- a/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java +++ b/marketplace-service/src/test/java/com/axonivy/market/service/SchedulingTasksTest.java @@ -10,8 +10,8 @@ import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.verify; -@SpringBootTest(properties = { "MONGODB_USERNAME=user", - "MONGODB_PASSWORD=password", "MONGODB_HOST=mongoHost", "MONGODB_DATABASE=product" }) +@SpringBootTest(properties = { "MONGODB_USERNAME=user", "MONGODB_PASSWORD=password", "MONGODB_HOST=mongoHost", + "MONGODB_DATABASE=product" }) class SchedulingTasksTest { @SpyBean