From 54461c026d73e78fcbcb2dd7d41ea804947c2041 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 11 Jul 2024 18:48:10 +0700 Subject: [PATCH 01/34] Init approach --- .github/workflows/docker-compose-build.yml | 37 +++++++++++++ marketplace-build/.dockerignore | 3 ++ marketplace-build/.env | 6 +++ marketplace-build/Dockerfile | 1 - marketplace-build/Dockerfile-NGINX | 10 ++++ marketplace-build/Dockerfile-Service | 30 +++++++++++ marketplace-build/Dockerfile-UI | 13 +++++ marketplace-build/config/nginx/nginx.conf | 27 ++++++++++ marketplace-build/config/tomcat/web.xml | 32 +++++++++++ marketplace-build/docker-compose.yml | 53 ++++++++++++++++++- marketplace-build/mongod.conf | 5 ++ .../com/axonivy/market/config/WebConfig.java | 7 +-- .../market/controller/ProductController.java | 2 + .../src/main/resources/application.properties | 4 +- marketplace-ui/Dockerfile | 9 ++++ marketplace-ui/nginx.conf | 27 ++++++++++ .../src/environments/environment.ts | 5 +- 17 files changed, 261 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/docker-compose-build.yml create mode 100644 marketplace-build/.dockerignore create mode 100644 marketplace-build/.env delete mode 100644 marketplace-build/Dockerfile create mode 100644 marketplace-build/Dockerfile-NGINX create mode 100644 marketplace-build/Dockerfile-Service create mode 100644 marketplace-build/Dockerfile-UI create mode 100644 marketplace-build/config/nginx/nginx.conf create mode 100644 marketplace-build/config/tomcat/web.xml create mode 100644 marketplace-build/mongod.conf create mode 100644 marketplace-ui/Dockerfile create mode 100644 marketplace-ui/nginx.conf diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml new file mode 100644 index 000000000..a6f70f276 --- /dev/null +++ b/.github/workflows/docker-compose-build.yml @@ -0,0 +1,37 @@ +name: Run Docker compose up + +on: + push: + branches: [ "develop" ] + workflow_dispatch: + +jobs: + build: + runs-on: self-hosted + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Update configuration + env: + ENV_FILE: '../../marketplace-build/.env' + MONGODB_HOST: ${{ secrets.MONGODB_HOST }} + MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + sed -i "s/^MONGODB_INITDB_ROOT_USERNAME=.*$/spring.data.mongodb.host=$MONGODB_HOST/" $ENV_FILE + sed -i "s/^MONGODB_INITDB_ROOT_PASSWORD=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE + sed -i "s/^SERVICE_MONGODB_HOST=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE + sed -i "s/^SERVICE_MONGODB_DATABASE=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE + sed -i "s/^SERVICE_MONGODB_USER=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE + sed -i "s/^SERVICE_MONGODB_PASSWORD=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE + + - name: Build and push Docker images + working-directory: ../../marketplace-build + run: | + docker-compose -f docker-compose.yml up -d diff --git a/marketplace-build/.dockerignore b/marketplace-build/.dockerignore new file mode 100644 index 000000000..483c6a7f7 --- /dev/null +++ b/marketplace-build/.dockerignore @@ -0,0 +1,3 @@ +# Node +/node_modules +../marketplace-ui/node_modules \ No newline at end of file diff --git a/marketplace-build/.env b/marketplace-build/.env new file mode 100644 index 000000000..380ce87fc --- /dev/null +++ b/marketplace-build/.env @@ -0,0 +1,6 @@ +MONGODB_INITDB_ROOT_USERNAME= +MONGODB_INITDB_ROOT_PASSWORD= +SERVICE_MONGODB_HOST= +SERVICE_MONGODB_DATABASE= +SERVICE_MONGODB_USER= +SERVICE_MONGODB_PASSWORD= diff --git a/marketplace-build/Dockerfile b/marketplace-build/Dockerfile deleted file mode 100644 index f6e0339af..000000000 --- a/marketplace-build/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -Placeholder \ No newline at end of file diff --git a/marketplace-build/Dockerfile-NGINX b/marketplace-build/Dockerfile-NGINX new file mode 100644 index 000000000..93bfec627 --- /dev/null +++ b/marketplace-build/Dockerfile-NGINX @@ -0,0 +1,10 @@ +# use the latest version of the official nginx image as the base image +FROM nginx:latest +# copy the custom nginx configuration file to the container in the +# default location +COPY ./config/nginx/nginx.conf /etc/nginx/nginx.conf +# copy the built Angular app files to the default nginx html directory +#COPY /dist/browser /usr/share/nginx/html +COPY --from=assets browser /usr/share/nginx/html + +# the paths are relative from the Docker file diff --git a/marketplace-build/Dockerfile-Service b/marketplace-build/Dockerfile-Service new file mode 100644 index 000000000..e2c52fd12 --- /dev/null +++ b/marketplace-build/Dockerfile-Service @@ -0,0 +1,30 @@ +# Use the official Tomcat 10.1 image from the Docker Hub +FROM tomcat:10.1-jdk17-openjdk-slim +# Stage 2: Run the application +#FROM openjdk:17-jdk-slim + +# Set the working directory +#WORKDIR /app + +# Copy the built jar file from the previous stage +#COPY --from=build /app/target/your-spring-boot-app.jar /app/app.jar +#COPY --from=assets marketplace-service-0.0.1-SNAPSHOT.jar /app/app.jar + +# Expose port 8080 +#EXPOSE 8080 + +# Start the application +#CMD ["java", "-jar", "app.jar"] + +# Remove the default ROOT webapp to avoid conflicts +RUN rm -rf /usr/local/tomcat/webapps/ROOT + +# Copy the WAR file to the webapps directory in Tomcat +COPY --from=assets marketplace-service-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/marketplace-service.war + +# Expose port 8080 +EXPOSE 8080 + +# Start Tomcat +CMD ["catalina.sh", "run"] + diff --git a/marketplace-build/Dockerfile-UI b/marketplace-build/Dockerfile-UI new file mode 100644 index 000000000..eab1641c4 --- /dev/null +++ b/marketplace-build/Dockerfile-UI @@ -0,0 +1,13 @@ +# Stage 2: Serve the Angular application with Nginx +FROM nginx:alpine + +# Copy the built Angular application from the previous stage +COPY --from=assets browser /usr/share/nginx/html + +COPY ./config/nginx/nginx.conf /etc/nginx/nginx.conf + +# Expose port 80 +EXPOSE 80 + +# Start Nginx server +CMD ["nginx", "-g", "daemon off;"] diff --git a/marketplace-build/config/nginx/nginx.conf b/marketplace-build/config/nginx/nginx.conf new file mode 100644 index 000000000..bd3cc2b35 --- /dev/null +++ b/marketplace-build/config/nginx/nginx.conf @@ -0,0 +1,27 @@ +# the events block is required +events{} + +http { + # include the default mime.types to map file extensions to MIME types + include /etc/nginx/mime.types; + + server { + # set the root directory for the server (we need to copy our + # application files here) + root /usr/share/nginx/html; + + # set the default index file for the server (Angular generates the + # index.html file for us and it will be in the above directory) + index index.html; + + # specify the configuration for the '/' location + location / { + # try to serve the requested URI. if that fails then try to + # serve the URI with a trailing slash. if that fails, then + # serve the index.html file; this is needed in order to serve + # Angular routes--e.g.,'localhost:8080/customer' will serve + # the index.html file + try_files $uri $uri/ /index.html; + } + } +} diff --git a/marketplace-build/config/tomcat/web.xml b/marketplace-build/config/tomcat/web.xml new file mode 100644 index 000000000..05d0a570b --- /dev/null +++ b/marketplace-build/config/tomcat/web.xml @@ -0,0 +1,32 @@ + + CorsFilter + org.apache.catalina.filters.CorsFilter + + cors.allowed.origins + * + + + cors.allowed.methods + GET,POST,HEAD,OPTIONS,PUT + + + cors.allowed.headers + Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers + + + cors.exposed.headers + Access-Control-Allow-Origin,Access-Control-Allow-Credentials + + + cors.support.credentials + true + + + cors.preflight.maxage + 10 + + + + CorsFilter + /* + \ No newline at end of file diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index f6e0339af..662812cec 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -1 +1,52 @@ -Placeholder \ No newline at end of file +version: '3.8' + +name: marketplace + +services: + mongodb: + image: mongodb/mongodb-community-server:7.0.0-ubi8 + container_name: mongodb-7.0.0 + restart: always + ports: + - "27017:27017" + environment: + MONGODB_INITDB_ROOT_USERNAME: ${MONGODB_INITDB_ROOT_USERNAME} + MONGODB_INITDB_ROOT_PASSWORD: ${MONGODB_INITDB_ROOT_USERNAME} + volumes: + - mongodata:/data/db + - ./mongod.conf:/etc/mongod.conf + command: ["mongod", "--config", "/etc/mongod.conf"] + + nginx: + build: + context: . + additional_contexts: + assets: ../marketplace-ui/dist/ + dockerfile: Dockerfile-NGINX + restart: always + volumes: + - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf + ports: + - "85:80" + + marketplace-service: + image: marketplace-service + container_name: marketplace-service + restart: always + environment: + - MONGODB_HOST=${SERVICE_MONGODB_HOST} + - MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE} + - MONGODB_USER=${SERVICE_MONGODB_USER} + - MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD} + build: + context: . + additional_contexts: + assets: ../marketplace-service/target/ + dockerfile: Dockerfile-Service + volumes: + - ../marketplace-service/target/marketplace-service-0.0.1-SNAPSHOT.war:/usr/local/tomcat/webapps/marketplace-service.war + ports: + - "9090:8080" + +volumes: + mongodata: \ No newline at end of file diff --git a/marketplace-build/mongod.conf b/marketplace-build/mongod.conf new file mode 100644 index 000000000..18b901f07 --- /dev/null +++ b/marketplace-build/mongod.conf @@ -0,0 +1,5 @@ +security: + authorization: enabled +net: + bindIpAll: true + port: 27017 diff --git a/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java b/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java index b9d75afa3..90c30116d 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java +++ b/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java @@ -12,7 +12,7 @@ public class WebConfig implements WebMvcConfigurer { private static final String[] EXCLUDE_PATHS = { "/", "/swagger-ui/**", "/api-docs/**" }; private static final String[] ALLOWED_HEADERS = { "Accept-Language", "Content-Type", "Authorization", "X-Requested-By", "x-requested-with", "X-Forwarded-Host" }; - private static final String[] ALLOWED_METHODS = { "GET", "POST", "PUT", "DELETE", "OPTIONS" }; + private static final String[] ALLOWED_METHODS = { "GET", "OPTIONS" }; private final MarketHeaderInterceptor headerInterceptor; @@ -33,10 +33,7 @@ public void addInterceptors(InterceptorRegistry registry) { @Override public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOriginPatterns(marketCorsAllowedOriginPatterns) - .allowedMethods(ALLOWED_METHODS) - .allowedHeaders(ALLOWED_HEADERS) + registry.addMapping("/**").allowedOrigins("*").allowedMethods(ALLOWED_METHODS).allowedHeaders(ALLOWED_HEADERS) .maxAge(marketCorsAllowedOriginMaxAge); } } \ No newline at end of file diff --git a/marketplace-service/src/main/java/com/axonivy/market/controller/ProductController.java b/marketplace-service/src/main/java/com/axonivy/market/controller/ProductController.java index 55d0444ff..c40c04ac1 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/controller/ProductController.java +++ b/marketplace-service/src/main/java/com/axonivy/market/controller/ProductController.java @@ -11,6 +11,7 @@ import org.springframework.hateoas.PagedModel; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -56,6 +57,7 @@ public ResponseEntity> findProducts( return new ResponseEntity<>(pageResources, HttpStatus.OK); } + @CrossOrigin(originPatterns = "http://localhost:[*]") @PutMapping(SYNC) public ResponseEntity syncProducts() { var stopWatch = new StopWatch(); diff --git a/marketplace-service/src/main/resources/application.properties b/marketplace-service/src/main/resources/application.properties index 458102046..2fc80c180 100644 --- a/marketplace-service/src/main/resources/application.properties +++ b/marketplace-service/src/main/resources/application.properties @@ -1,5 +1,5 @@ spring.application.name=marketplace-service -spring.data.mongodb.host=mongodb://localhost:27017/ +spring.data.mongodb.host=mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@${MONGODB_HOST}:27017/ spring.data.mongodb.database=marketplace server.port=8080 logging.level.org.springframework.web=warn @@ -7,5 +7,5 @@ request.header=ivy server.forward-headers-strategy=framework springdoc.api-docs.path=/api-docs springdoc.swagger-ui.path=/swagger-ui.html -market.cors.allowed.origin.patterns=http://localhost:[*], http://10.193.8.78:[*], http://marketplace.server.ivy-cloud.com:[*] market.cors.allowed.origin.maxAge=3600 +logging.level.org.springframework.security=DEBUG \ No newline at end of file diff --git a/marketplace-ui/Dockerfile b/marketplace-ui/Dockerfile new file mode 100644 index 000000000..a92872200 --- /dev/null +++ b/marketplace-ui/Dockerfile @@ -0,0 +1,9 @@ +# use the latest version of the official nginx image as the base image +FROM nginx:latest +# copy the custom nginx configuration file to the container in the +# default location +COPY nginx.conf /etc/nginx/nginx.conf +# copy the built Angular app files to the default nginx html directory +COPY /dist/browser /usr/share/nginx/html + +# the paths are relative from the Docker file diff --git a/marketplace-ui/nginx.conf b/marketplace-ui/nginx.conf new file mode 100644 index 000000000..bd3cc2b35 --- /dev/null +++ b/marketplace-ui/nginx.conf @@ -0,0 +1,27 @@ +# the events block is required +events{} + +http { + # include the default mime.types to map file extensions to MIME types + include /etc/nginx/mime.types; + + server { + # set the root directory for the server (we need to copy our + # application files here) + root /usr/share/nginx/html; + + # set the default index file for the server (Angular generates the + # index.html file for us and it will be in the above directory) + index index.html; + + # specify the configuration for the '/' location + location / { + # try to serve the requested URI. if that fails then try to + # serve the URI with a trailing slash. if that fails, then + # serve the index.html file; this is needed in order to serve + # Angular routes--e.g.,'localhost:8080/customer' will serve + # the index.html file + try_files $uri $uri/ /index.html; + } + } +} diff --git a/marketplace-ui/src/environments/environment.ts b/marketplace-ui/src/environments/environment.ts index b0c3ad6e3..a43f3c432 100644 --- a/marketplace-ui/src/environments/environment.ts +++ b/marketplace-ui/src/environments/environment.ts @@ -1,4 +1,7 @@ export const environment = { production: true, - apiUrl: 'http://10.193.8.78:9090/marketplace-service' + //apiUrl: 'http://api-service-network:8080/marketplace-service' + //apiUrl: 'http://localhost:9090/marketplace-service' + //apiUrl: 'http://192.168.73.13:8080' + apiUrl: 'http://192.168.73.17:9090/marketplace-service' }; From a9c8f26ba154c0f42479323951149f6df688d933 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen <83745591+nqhoan-axonivy@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:20:53 +0700 Subject: [PATCH 02/34] Fix dockercompose (#29) Co-authored-by: Hoan Nguyen --- .github/workflows/docker-compose-build.yml | 7 ++++--- marketplace-build/.env | 2 -- .../config/mongodb/docker-compose.yml | 17 +++++++++++++++++ marketplace-build/config/mongodb/mongod.conf | 5 +++++ marketplace-build/docker-compose.yml | 14 +++++--------- .../com/axonivy/market/config/WebConfig.java | 3 --- marketplace-ui/src/environments/environment.ts | 5 +---- sonar-project.properties | 5 +++++ 8 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 marketplace-build/config/mongodb/docker-compose.yml create mode 100644 marketplace-build/config/mongodb/mongod.conf create mode 100644 sonar-project.properties diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml index a6f70f276..51d111de6 100644 --- a/.github/workflows/docker-compose-build.yml +++ b/.github/workflows/docker-compose-build.yml @@ -7,7 +7,8 @@ on: jobs: build: - runs-on: self-hosted + #runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -19,7 +20,7 @@ jobs: cache: maven - name: Update configuration env: - ENV_FILE: '../../marketplace-build/.env' + ENV_FILE: './marketplace-build/.env' MONGODB_HOST: ${{ secrets.MONGODB_HOST }} MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }} GH_TOKEN: ${{ secrets.GH_TOKEN }} @@ -32,6 +33,6 @@ jobs: sed -i "s/^SERVICE_MONGODB_PASSWORD=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE - name: Build and push Docker images - working-directory: ../../marketplace-build + working-directory: ./marketplace-build run: | docker-compose -f docker-compose.yml up -d diff --git a/marketplace-build/.env b/marketplace-build/.env index 380ce87fc..14ed8770f 100644 --- a/marketplace-build/.env +++ b/marketplace-build/.env @@ -1,6 +1,4 @@ MONGODB_INITDB_ROOT_USERNAME= MONGODB_INITDB_ROOT_PASSWORD= -SERVICE_MONGODB_HOST= -SERVICE_MONGODB_DATABASE= SERVICE_MONGODB_USER= SERVICE_MONGODB_PASSWORD= diff --git a/marketplace-build/config/mongodb/docker-compose.yml b/marketplace-build/config/mongodb/docker-compose.yml new file mode 100644 index 000000000..17dc83b6e --- /dev/null +++ b/marketplace-build/config/mongodb/docker-compose.yml @@ -0,0 +1,17 @@ +services: + mongodb: + image: mongodb/mongodb-community-server:7.0.0-ubi8 + container_name: mongodb-7.0.0 + restart: always + ports: + - "27017:27017" + volumes: + - mongodata:/data/db + environment: + - MONGODB_INITDB_ROOT_USERNAME= + - MONGODB_INITDB_ROOT_PASSWORD= + - ./mongod.conf:/etc/mongod.conf + command: ["mongod", "--config", "/etc/mongod.conf"] + +volumes: + mongodata: \ No newline at end of file diff --git a/marketplace-build/config/mongodb/mongod.conf b/marketplace-build/config/mongodb/mongod.conf new file mode 100644 index 000000000..18b901f07 --- /dev/null +++ b/marketplace-build/config/mongodb/mongod.conf @@ -0,0 +1,5 @@ +security: + authorization: enabled +net: + bindIpAll: true + port: 27017 diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index 662812cec..b0993f220 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - name: marketplace services: @@ -11,10 +9,10 @@ services: - "27017:27017" environment: MONGODB_INITDB_ROOT_USERNAME: ${MONGODB_INITDB_ROOT_USERNAME} - MONGODB_INITDB_ROOT_PASSWORD: ${MONGODB_INITDB_ROOT_USERNAME} + MONGODB_INITDB_ROOT_PASSWORD: ${MONGODB_INITDB_ROOT_PASSWORD} volumes: - mongodata:/data/db - - ./mongod.conf:/etc/mongod.conf + - ./config/mongodb/mongod.conf:/etc/mongod.conf command: ["mongod", "--config", "/etc/mongod.conf"] nginx: @@ -34,8 +32,8 @@ services: container_name: marketplace-service restart: always environment: - - MONGODB_HOST=${SERVICE_MONGODB_HOST} - - MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE} + - MONGODB_HOST=mongodb + - MONGODB_DATABASE=marketplace - MONGODB_USER=${SERVICE_MONGODB_USER} - MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD} build: @@ -43,10 +41,8 @@ services: additional_contexts: assets: ../marketplace-service/target/ dockerfile: Dockerfile-Service - volumes: - - ../marketplace-service/target/marketplace-service-0.0.1-SNAPSHOT.war:/usr/local/tomcat/webapps/marketplace-service.war ports: - - "9090:8080" + - "8080:8080" volumes: mongodata: \ No newline at end of file diff --git a/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java b/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java index 90c30116d..97b9a1506 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java +++ b/marketplace-service/src/main/java/com/axonivy/market/config/WebConfig.java @@ -16,9 +16,6 @@ public class WebConfig implements WebMvcConfigurer { private final MarketHeaderInterceptor headerInterceptor; - @Value("${market.cors.allowed.origin.patterns}") - private String marketCorsAllowedOriginPatterns; - @Value("${market.cors.allowed.origin.maxAge}") private int marketCorsAllowedOriginMaxAge; diff --git a/marketplace-ui/src/environments/environment.ts b/marketplace-ui/src/environments/environment.ts index a43f3c432..2b861682d 100644 --- a/marketplace-ui/src/environments/environment.ts +++ b/marketplace-ui/src/environments/environment.ts @@ -1,7 +1,4 @@ export const environment = { production: true, - //apiUrl: 'http://api-service-network:8080/marketplace-service' - //apiUrl: 'http://localhost:9090/marketplace-service' - //apiUrl: 'http://192.168.73.13:8080' - apiUrl: 'http://192.168.73.17:9090/marketplace-service' + apiUrl: 'http://marketplace.server.ivy-cloud.com:8080/marketplace-service' }; diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..950647ff3 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.sources=src/main/java +sonar.tests=src/test/java +sonar.java.binaries=target/classes +sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml +sonar.exclusions=**/test/**,**/tests/**,**/src/test/**,**/src/**/test/** \ No newline at end of file From 7a31c8f82c0904b84e837e7477c658dc938b8e77 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Tue, 16 Jul 2024 17:15:26 +0700 Subject: [PATCH 03/34] Pimp up README Add new workflow --- .github/workflows/docker-build.yml | 58 +++++++++++++++++++ .github/workflows/docker-compose-build.yml | 38 ------------ .github/workflows/docker-release.yml | 46 +++++++++++++++ .github/workflows/service-ci-build.yml | 2 + .github/workflows/service-dev-build.yml | 42 -------------- .github/workflows/ui-ci-build.yml | 5 +- .github/workflows/ui-dev-build.yml | 28 --------- README.md | 37 ++++-------- marketplace-build/.env | 3 + marketplace-build/Dockerfile-NGINX | 10 ---- marketplace-build/Dockerfile-UI | 19 +++--- .../Marketplace Tomcat v10.1 Server.launch | 5 +- marketplace-build/README.md | 51 ++++++++++++++++ .../config/mongodb/docker-compose.yml | 11 ++-- marketplace-build/config/tomcat/web.xml | 32 ---------- marketplace-build/docker-compose.yml | 23 +++++--- marketplace-build/mongod.conf | 5 -- marketplace-build/release/docker-compose.yml | 14 +++++ .../market/github/model/GitHubProperty.java | 20 +++++++ .../service/impl/GitHubServiceImpl.java | 14 ++--- .../src/main/resources/application.properties | 5 +- .../src/main/resources/github.token | 1 - sonar-project.properties | 5 -- 23 files changed, 246 insertions(+), 228 deletions(-) create mode 100644 .github/workflows/docker-build.yml delete mode 100644 .github/workflows/docker-compose-build.yml create mode 100644 .github/workflows/docker-release.yml delete mode 100644 .github/workflows/service-dev-build.yml delete mode 100644 .github/workflows/ui-dev-build.yml delete mode 100644 marketplace-build/Dockerfile-NGINX create mode 100644 marketplace-build/README.md delete mode 100644 marketplace-build/config/tomcat/web.xml delete mode 100644 marketplace-build/mongod.conf create mode 100644 marketplace-build/release/docker-compose.yml create mode 100644 marketplace-service/src/main/java/com/axonivy/market/github/model/GitHubProperty.java delete mode 100644 marketplace-service/src/main/resources/github.token delete mode 100644 sonar-project.properties diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..7760089f0 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,58 @@ +name: Docker build + +on: + push: + branches: [ "develop" ] + workflow_dispatch: + workflow_call: + +jobs: + build: + runs-on: self-hosted + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build Marketplace service project + run: | + cd ./marketplace-service + mvn clean install -DskipTests + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: ./marketplace-ui/package-lock.json + - name: Build Marketplace ui project + run: | + cd ./marketplace-ui + npm i + npm run build --prod + - name: Update environment variables for ENV + env: + ENV_FILE: './marketplace-build/.env' + MONGODB_HOST: ${{ secrets.MONGODB_HOST }} + ROOT_USERNAME: ${{ secrets.MONGODB_ROOT_USERNAME }} + ROOT_PASSWORD: ${{ secrets.MONGODB_ROOT_PASSWORD }} + SERVICE_USERNAME: ${{ secrets.SERVICE_USERNAME }} + SERVICE_PASSWORD: ${{ secrets.SERVICE_PASSWORD }} + MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + 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 + sed -i "s/^SERVICE_MONGODB_HOST=.*$/SERVICE_MONGODB_HOST=$MONGODB_HOST/" $ENV_FILE + sed -i "s/^SERVICE_MONGODB_DATABASE=.*$/SERVICE_MONGODB_DATABASE=$MONGODB_DATABASE/" $ENV_FILE + 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 + + - name: Refresh Docker images + working-directory: ./marketplace-build + run: | + docker compose down + docker compose -f docker-compose.yml up -d diff --git a/.github/workflows/docker-compose-build.yml b/.github/workflows/docker-compose-build.yml deleted file mode 100644 index 51d111de6..000000000 --- a/.github/workflows/docker-compose-build.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Run Docker compose up - -on: - push: - branches: [ "develop" ] - workflow_dispatch: - -jobs: - build: - #runs-on: self-hosted - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Update configuration - env: - ENV_FILE: './marketplace-build/.env' - MONGODB_HOST: ${{ secrets.MONGODB_HOST }} - MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} - run: | - sed -i "s/^MONGODB_INITDB_ROOT_USERNAME=.*$/spring.data.mongodb.host=$MONGODB_HOST/" $ENV_FILE - sed -i "s/^MONGODB_INITDB_ROOT_PASSWORD=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE - sed -i "s/^SERVICE_MONGODB_HOST=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE - sed -i "s/^SERVICE_MONGODB_DATABASE=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE - sed -i "s/^SERVICE_MONGODB_USER=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE - sed -i "s/^SERVICE_MONGODB_PASSWORD=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $ENV_FILE - - - name: Build and push Docker images - working-directory: ./marketplace-build - run: | - docker-compose -f docker-compose.yml up -d diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 000000000..854276579 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,46 @@ +name: Docker Release + +on: + push: + branches: [ "master" ] + workflow_dispatch: + +env: + UI_IMAGE_NAME: marketplace-ui + SERVICE_IMAGE_NAME: marketplace-service + +jobs: + + build: + uses: ./.github/workflows/docker-build.yml + + release: + needs: build + runs-on: self-hosted + permissions: + packages: write + contents: read + + steps: + - name: Log in to registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Refine release version + run: | + # This strips the git ref prefix from the version. + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # This strips the "v" prefix from the tag name. + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # This uses the Docker `latest` tag convention. + [ "$VERSION" == "main" ] && VERSION=latest + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Release Marketplace UI image + run: | + UI_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$UI_IMAGE_NAME + docker tag $UI_IMAGE_NAME $UI_IMAGE_ID:$VERSION + docker push $UI_IMAGE_ID:$VERSION + + - name: Release Marketplace Service image + run: | + SERVICE_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$SERVICE_IMAGE_NAME + docker tag $SERVICE_IMAGE_NAME $SERVICE_IMAGE_ID:$VERSION + docker push $SERVICE_IMAGE_ID:$VERSION \ No newline at end of file diff --git a/.github/workflows/service-ci-build.yml b/.github/workflows/service-ci-build.yml index e384445d2..ef121541e 100644 --- a/.github/workflows/service-ci-build.yml +++ b/.github/workflows/service-ci-build.yml @@ -3,6 +3,8 @@ run-name: Build Service on branch ${{github.ref_name}} triggered by ${{github.ac on: push: + paths: + - 'marketplace-service/**' workflow_dispatch: jobs: diff --git a/.github/workflows/service-dev-build.yml b/.github/workflows/service-dev-build.yml deleted file mode 100644 index e310a9378..000000000 --- a/.github/workflows/service-dev-build.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Service DEV Build -run-name: Build and Deploy Marketplace-Service on branch ${{github.ref_name}} by ${{github.actor}} - -on: - push: - branches: [ "develop" ] - workflow_dispatch: - -jobs: - build: - name: Packge project and deploy to tomcat - runs-on: self-hosted - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Update configuration - env: - APP_PROPERTIES_FILE: './marketplace-service/src/main/resources/application.properties' - GITHUB_TOKEN_FILE: './marketplace-service/src/main/resources/github.token' - MONGODB_HOST: ${{ secrets.MONGODB_HOST }} - MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} - run: | - sed -i "s/^spring.data.mongodb.host=.*$/spring.data.mongodb.host=$MONGODB_HOST/" $APP_PROPERTIES_FILE - sed -i "s/^spring.data.mongodb.database=.*$/spring.data.mongodb.database=$MONGODB_DATABASE/" $APP_PROPERTIES_FILE - sed -i '1d;$d' $GITHUB_TOKEN_FILE && echo $GH_TOKEN > $GITHUB_TOKEN_FILE - - name: Build with Maven - run: mvn clean package -DskipTests --file ./marketplace-service/pom.xml - - name: Prepare deployment directory - run: mkdir -p deployment && cp ./marketplace-service/target/*.war deployment/ - - name: Copy WAR to Tomcat server - run: sudo cp deployment/*.war /opt/tomcat/webapps/marketplace-service.war - - name: Restart Tomcat server - run: | - sudo systemctl stop tomcat - sudo systemctl start tomcat diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 8137daf8b..ea3b727ec 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -3,9 +3,8 @@ run-name: Build on branch ${{github.ref_name}} triggered by ${{github.actor}} on: push: - branches-ignore: - - develop - - master + paths: + - 'marketplace-ui/**' workflow_dispatch: jobs: diff --git a/.github/workflows/ui-dev-build.yml b/.github/workflows/ui-dev-build.yml deleted file mode 100644 index 506278838..000000000 --- a/.github/workflows/ui-dev-build.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: UI Dev Build -run-name: Build and Deploy Marketplace-UI on branch ${{github.ref_name}} by ${{github.actor}} - -on: - push: - branches: [ "develop" ] - workflow_dispatch: - -jobs: - build: - name: Build and deploy new code to Deployment directory - runs-on: self-hosted - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '18' - cache: 'npm' - - name: Install Dependencies - run: npm install - - name: Build Angular app - run: npm run build -- --configuration production --output-path=dist - - name: Execute Tests - run: npm run test - - name: Copy files to Deployment directory - if: success() - run: sudo cp -r dist/* /var/www/marketplace-ui diff --git a/README.md b/README.md index 4d546f33a..5ef75bcd7 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,17 @@ # Getting Started -### Reference Documentation -For further reference, please consider the following sections: - -* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) -* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.2.5/maven-plugin/reference/html/) -* [Spring Data MongoDB](https://docs.spring.io/spring-boot/docs/3.2.5/reference/htmlsingle/index.html#data.nosql.mongodb) -* [Spring Web](https://docs.spring.io/spring-boot/docs/3.2.5/reference/htmlsingle/index.html#web) +For AxonIvy Marketplace, we have 3 parts: marketplace-ui, marketplace-service, and marketplace-build: +* ``marketplace-ui``: is an Angular project, built on v18 and contains the frontend code for the website. +* ``marketplace-service``: is a SpringBoot project, built on v3.2.5 and includes the apis code for the website. +* ``marketplace-build``: is a folder to keep everything related to build and dockers. ### Guides -The following guides illustrate how to use some features concretely: - -* Installing mongodb, and access it as Url mongodb://localhost:27017/, and you can create and name whatever you want ,then you should put them to application.properties -* You can change the MongoDB configuration in file `application.properties` - ``` - spring.data.mongodb.host= - spring.data.mongodb.database= - ``` -* Update GitHub token in file `github.token` -* Run mvn clean install to build project -* Run mvn test to test all tests +* How to start the Marketplace UI refer to the [marketplace-ui guide][1] +* How to start the Marketplace Service refer to the [marketplace-service guide][2] -### Access Swagger URL: http://{your-host}/swagger-ui/index.html +* How to start the Marketplace Build refer to the [marketplace-build guide][3] -### Install Lombok for Eclipse IDE -* Download lombok here https://projectlombok.org/download -* run command "java -jar lombok.jar" then you can access file “eclipse.ini“ in eclipse folder where you install → there is a text like this: -javaagent:C:\Users\tvtphuc\eclipse\jee-2024-032\eclipse\lombok.jar → it means you are successful -* Start eclipse -* Import the project then in the eclipse , you should run the command “mvn clean install“ -* After that you go to class MarketplaceServiceApplication → right click to main method → click run as → choose Java Application -* Then you can send a request in postman -* If you want to run single test in class UserServiceImplTest. You can right-click to method testFindAllUser and right click → select Run as → choose JUnit Test \ No newline at end of file + [1]: marketplace-ui/README.md + [2]: marketplace-service/README.md + [3]: marketplace-build/README.md diff --git a/marketplace-build/.env b/marketplace-build/.env index 14ed8770f..e2ca21cd2 100644 --- a/marketplace-build/.env +++ b/marketplace-build/.env @@ -1,4 +1,7 @@ MONGODB_INITDB_ROOT_USERNAME= MONGODB_INITDB_ROOT_PASSWORD= +SERVICE_MONGODB_HOST= SERVICE_MONGODB_USER= SERVICE_MONGODB_PASSWORD= +SERVICE_MONGODB_DATABASE= +MARKET_GITHUB_TOKEN= \ No newline at end of file diff --git a/marketplace-build/Dockerfile-NGINX b/marketplace-build/Dockerfile-NGINX deleted file mode 100644 index 93bfec627..000000000 --- a/marketplace-build/Dockerfile-NGINX +++ /dev/null @@ -1,10 +0,0 @@ -# use the latest version of the official nginx image as the base image -FROM nginx:latest -# copy the custom nginx configuration file to the container in the -# default location -COPY ./config/nginx/nginx.conf /etc/nginx/nginx.conf -# copy the built Angular app files to the default nginx html directory -#COPY /dist/browser /usr/share/nginx/html -COPY --from=assets browser /usr/share/nginx/html - -# the paths are relative from the Docker file diff --git a/marketplace-build/Dockerfile-UI b/marketplace-build/Dockerfile-UI index eab1641c4..93bfec627 100644 --- a/marketplace-build/Dockerfile-UI +++ b/marketplace-build/Dockerfile-UI @@ -1,13 +1,10 @@ -# Stage 2: Serve the Angular application with Nginx -FROM nginx:alpine - -# Copy the built Angular application from the previous stage -COPY --from=assets browser /usr/share/nginx/html - +# use the latest version of the official nginx image as the base image +FROM nginx:latest +# copy the custom nginx configuration file to the container in the +# default location COPY ./config/nginx/nginx.conf /etc/nginx/nginx.conf +# copy the built Angular app files to the default nginx html directory +#COPY /dist/browser /usr/share/nginx/html +COPY --from=assets browser /usr/share/nginx/html -# Expose port 80 -EXPOSE 80 - -# Start Nginx server -CMD ["nginx", "-g", "daemon off;"] +# the paths are relative from the Docker file diff --git a/marketplace-build/Marketplace Tomcat v10.1 Server.launch b/marketplace-build/Marketplace Tomcat v10.1 Server.launch index 5e4b64925..e3efb4803 100644 --- a/marketplace-build/Marketplace Tomcat v10.1 Server.launch +++ b/marketplace-build/Marketplace Tomcat v10.1 Server.launch @@ -2,8 +2,9 @@ - - + + + diff --git a/marketplace-build/README.md b/marketplace-build/README.md new file mode 100644 index 000000000..9d2da125b --- /dev/null +++ b/marketplace-build/README.md @@ -0,0 +1,51 @@ +# Get starts with Marketplace build + +### Set up MongoDB with authentication mode +* Navigate to ``marketplace-build/config/mongodb`` and execute the ``docker-compose up`` to start MongoDB with non-auth mode +* Create root user for authentication + ``` + use admin + db.createUser( + { + user: "username", + pwd: "password", + roles: [ + { role: "userAdminAnyDatabase", db: "admin" }, + { role: "readWriteAnyDatabase", db: "admin" } + ] + } + ) + + db.grantRolesToUser('username', [{ role: 'root', db: 'admin' }]) + ``` + +* [Optional] Execute authentication test for the created user + ``` + use admin + db.auth('username','password') + ``` +This command should return the ``OK`` code + +### Docker build for DEV environment +* Navigate to ``marketplace-service`` and execute maven build for spring-boot app to get the war file: + ``` + mvn clean install -DskipTests + ``` + +* Navigate to ``marketplace-ui`` and execute node install and run the angular app to get the dist folder: + ``` + npm instal + npm run build --prod + ``` + +* Please run ``docker-compose up --build`` from folder ``marketplace-build`` to start a Marketplace DEV at the local + +### Docker release +To release a new version for marketplace images, please trigger the ``Docker Release`` actions. +* This GH Actions will trigger the ``Docker build`` on the master branch. +* Login to GitHub Registry Hub. +* Deploy new image to packages. +Please verify the result in the ``Package`` after the build is completed. + +### Docker compose for PROD deployment +* Navigate to ``marketplace-build/release`` run ``docker-compose up`` to clone the docker images from GitHub packages and start the website diff --git a/marketplace-build/config/mongodb/docker-compose.yml b/marketplace-build/config/mongodb/docker-compose.yml index 17dc83b6e..ddfb3acb0 100644 --- a/marketplace-build/config/mongodb/docker-compose.yml +++ b/marketplace-build/config/mongodb/docker-compose.yml @@ -1,17 +1,14 @@ +# This docker compose to init mongo for setup auth +name: marketplace + services: mongodb: image: mongodb/mongodb-community-server:7.0.0-ubi8 - container_name: mongodb-7.0.0 restart: always ports: - "27017:27017" volumes: - mongodata:/data/db - environment: - - MONGODB_INITDB_ROOT_USERNAME= - - MONGODB_INITDB_ROOT_PASSWORD= - - ./mongod.conf:/etc/mongod.conf - command: ["mongod", "--config", "/etc/mongod.conf"] volumes: - mongodata: \ No newline at end of file + mongodata: diff --git a/marketplace-build/config/tomcat/web.xml b/marketplace-build/config/tomcat/web.xml deleted file mode 100644 index 05d0a570b..000000000 --- a/marketplace-build/config/tomcat/web.xml +++ /dev/null @@ -1,32 +0,0 @@ - - CorsFilter - org.apache.catalina.filters.CorsFilter - - cors.allowed.origins - * - - - cors.allowed.methods - GET,POST,HEAD,OPTIONS,PUT - - - cors.allowed.headers - Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers - - - cors.exposed.headers - Access-Control-Allow-Origin,Access-Control-Allow-Credentials - - - cors.support.credentials - true - - - cors.preflight.maxage - 10 - - - - CorsFilter - /* - \ No newline at end of file diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index b0993f220..ecc39822f 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -3,7 +3,7 @@ name: marketplace services: mongodb: image: mongodb/mongodb-community-server:7.0.0-ubi8 - container_name: mongodb-7.0.0 + container_name: marketplace-mongodb-7.0.0 restart: always ports: - "27017:27017" @@ -15,34 +15,41 @@ services: - ./config/mongodb/mongod.conf:/etc/mongod.conf command: ["mongod", "--config", "/etc/mongod.conf"] - nginx: + ui: build: context: . additional_contexts: assets: ../marketplace-ui/dist/ - dockerfile: Dockerfile-NGINX + dockerfile: Dockerfile-UI restart: always volumes: - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf ports: - - "85:80" + - "90:80" + depends_on: + - service - marketplace-service: + service: image: marketplace-service container_name: marketplace-service restart: always environment: - - MONGODB_HOST=mongodb - - MONGODB_DATABASE=marketplace - - MONGODB_USER=${SERVICE_MONGODB_USER} + - 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} build: context: . additional_contexts: assets: ../marketplace-service/target/ dockerfile: Dockerfile-Service + volumes: + - ../marketplace-service/target/marketplace-service-0.0.1-SNAPSHOT.war:/usr/local/tomcat/webapps/marketplace-service.war ports: - "8080:8080" + depends_on: + - mongodb volumes: mongodata: \ No newline at end of file diff --git a/marketplace-build/mongod.conf b/marketplace-build/mongod.conf deleted file mode 100644 index 18b901f07..000000000 --- a/marketplace-build/mongod.conf +++ /dev/null @@ -1,5 +0,0 @@ -security: - authorization: enabled -net: - bindIpAll: true - port: 27017 diff --git a/marketplace-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml new file mode 100644 index 000000000..491361199 --- /dev/null +++ b/marketplace-build/release/docker-compose.yml @@ -0,0 +1,14 @@ +name: marketplace-website + +services: + mongodb: + image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-db:latest + + nginx: + image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-nginx:latest + + marketplace-service: + image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-service:latest + +volumes: + mongodata: \ No newline at end of file diff --git a/marketplace-service/src/main/java/com/axonivy/market/github/model/GitHubProperty.java b/marketplace-service/src/main/java/com/axonivy/market/github/model/GitHubProperty.java new file mode 100644 index 000000000..e0e30f669 --- /dev/null +++ b/marketplace-service/src/main/java/com/axonivy/market/github/model/GitHubProperty.java @@ -0,0 +1,20 @@ +package com.axonivy.market.github.model; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Configuration +@ConfigurationProperties(prefix = "market.github") +public class GitHubProperty { + + private String token; +} diff --git a/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java b/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java index 62bbd9181..174e5f44c 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java +++ b/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java @@ -1,8 +1,6 @@ package com.axonivy.market.github.service.impl; -import java.io.File; import java.io.IOException; -import java.nio.file.Files; import java.util.List; import org.kohsuke.github.GHContent; @@ -12,20 +10,22 @@ import org.kohsuke.github.GitHubBuilder; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import org.springframework.util.ResourceUtils; +import com.axonivy.market.github.model.GitHubProperty; import com.axonivy.market.github.service.GitHubService; @Service public class GitHubServiceImpl implements GitHubService { - private static final String GITHUB_TOKEN_FILE = "classpath:github.token"; + private GitHubProperty gitHubProperty; + + public GitHubServiceImpl(GitHubProperty gitHubProperty) { + this.gitHubProperty = gitHubProperty; + } @Override public GitHub getGitHub() throws IOException { - File gitHubToken = ResourceUtils.getFile(GITHUB_TOKEN_FILE); - var token = Files.readString(gitHubToken.toPath()); - return new GitHubBuilder().withOAuthToken(token.trim().strip()).build(); + return new GitHubBuilder().withOAuthToken(gitHubProperty.getToken().trim().strip()).build(); } @Override diff --git a/marketplace-service/src/main/resources/application.properties b/marketplace-service/src/main/resources/application.properties index 2fc80c180..6b29fd70d 100644 --- a/marketplace-service/src/main/resources/application.properties +++ b/marketplace-service/src/main/resources/application.properties @@ -1,6 +1,6 @@ spring.application.name=marketplace-service -spring.data.mongodb.host=mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@${MONGODB_HOST}:27017/ -spring.data.mongodb.database=marketplace +spring.data.mongodb.host=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@${MONGODB_HOST}:27017/ +spring.data.mongodb.database=${MONGODB_DATABASE} server.port=8080 logging.level.org.springframework.web=warn request.header=ivy @@ -8,4 +8,5 @@ server.forward-headers-strategy=framework springdoc.api-docs.path=/api-docs springdoc.swagger-ui.path=/swagger-ui.html market.cors.allowed.origin.maxAge=3600 +market.github.token=${MARKET_GITHUB_TOKEN} logging.level.org.springframework.security=DEBUG \ No newline at end of file diff --git a/marketplace-service/src/main/resources/github.token b/marketplace-service/src/main/resources/github.token deleted file mode 100644 index 8433821ba..000000000 --- a/marketplace-service/src/main/resources/github.token +++ /dev/null @@ -1 +0,0 @@ -ghp_replace-with-your-token \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 950647ff3..000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,5 +0,0 @@ -sonar.sources=src/main/java -sonar.tests=src/test/java -sonar.java.binaries=target/classes -sonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml -sonar.exclusions=**/test/**,**/tests/**,**/src/test/**,**/src/**/test/** \ No newline at end of file From 6682240c8b7840bd23d7f9904d2245ec60509a1a Mon Sep 17 00:00:00 2001 From: Hoan Nguyen <83745591+nqhoan-axonivy@users.noreply.github.com> Date: Thu, 18 Jul 2024 09:43:06 +0700 Subject: [PATCH 04/34] Unify code (#38) Co-authored-by: Hoan Nguyen Co-authored-by: ivyTeam --- marketplace-build/Dockerfile-Service | 30 ----------------- marketplace-build/Dockerfile-UI | 10 ------ marketplace-build/README.md | 18 +--------- .../config/mongodb/docker-compose.yml | 1 + .../config/mongodb/mongo-init.js | 12 +++++++ marketplace-build/docker-compose.yml | 16 ++++----- marketplace-service/.dockerignore | 33 +++++++++++++++++++ marketplace-service/Dockerfile | 21 ++++++++++++ .../java/com/axonivy/market/entity/User.java | 2 +- marketplace-ui/.dockerignore | 5 +++ marketplace-ui/Dockerfile | 18 +++++----- 11 files changed, 92 insertions(+), 74 deletions(-) delete mode 100644 marketplace-build/Dockerfile-Service delete mode 100644 marketplace-build/Dockerfile-UI create mode 100644 marketplace-build/config/mongodb/mongo-init.js create mode 100644 marketplace-service/.dockerignore create mode 100644 marketplace-service/Dockerfile create mode 100644 marketplace-ui/.dockerignore diff --git a/marketplace-build/Dockerfile-Service b/marketplace-build/Dockerfile-Service deleted file mode 100644 index e2c52fd12..000000000 --- a/marketplace-build/Dockerfile-Service +++ /dev/null @@ -1,30 +0,0 @@ -# Use the official Tomcat 10.1 image from the Docker Hub -FROM tomcat:10.1-jdk17-openjdk-slim -# Stage 2: Run the application -#FROM openjdk:17-jdk-slim - -# Set the working directory -#WORKDIR /app - -# Copy the built jar file from the previous stage -#COPY --from=build /app/target/your-spring-boot-app.jar /app/app.jar -#COPY --from=assets marketplace-service-0.0.1-SNAPSHOT.jar /app/app.jar - -# Expose port 8080 -#EXPOSE 8080 - -# Start the application -#CMD ["java", "-jar", "app.jar"] - -# Remove the default ROOT webapp to avoid conflicts -RUN rm -rf /usr/local/tomcat/webapps/ROOT - -# Copy the WAR file to the webapps directory in Tomcat -COPY --from=assets marketplace-service-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/marketplace-service.war - -# Expose port 8080 -EXPOSE 8080 - -# Start Tomcat -CMD ["catalina.sh", "run"] - diff --git a/marketplace-build/Dockerfile-UI b/marketplace-build/Dockerfile-UI deleted file mode 100644 index 93bfec627..000000000 --- a/marketplace-build/Dockerfile-UI +++ /dev/null @@ -1,10 +0,0 @@ -# use the latest version of the official nginx image as the base image -FROM nginx:latest -# copy the custom nginx configuration file to the container in the -# default location -COPY ./config/nginx/nginx.conf /etc/nginx/nginx.conf -# copy the built Angular app files to the default nginx html directory -#COPY /dist/browser /usr/share/nginx/html -COPY --from=assets browser /usr/share/nginx/html - -# the paths are relative from the Docker file diff --git a/marketplace-build/README.md b/marketplace-build/README.md index 9d2da125b..327f754b6 100644 --- a/marketplace-build/README.md +++ b/marketplace-build/README.md @@ -1,23 +1,7 @@ # Get starts with Marketplace build ### Set up MongoDB with authentication mode -* Navigate to ``marketplace-build/config/mongodb`` and execute the ``docker-compose up`` to start MongoDB with non-auth mode -* Create root user for authentication - ``` - use admin - db.createUser( - { - user: "username", - pwd: "password", - roles: [ - { role: "userAdminAnyDatabase", db: "admin" }, - { role: "readWriteAnyDatabase", db: "admin" } - ] - } - ) - - db.grantRolesToUser('username', [{ role: 'root', db: 'admin' }]) - ``` +* Navigate to ``marketplace-build/config/mongodb`` and execute the ``docker-compose up`` to start MongoDB with non-auth mode and create a root admin user. * [Optional] Execute authentication test for the created user ``` diff --git a/marketplace-build/config/mongodb/docker-compose.yml b/marketplace-build/config/mongodb/docker-compose.yml index ddfb3acb0..d02961e27 100644 --- a/marketplace-build/config/mongodb/docker-compose.yml +++ b/marketplace-build/config/mongodb/docker-compose.yml @@ -9,6 +9,7 @@ services: - "27017:27017" volumes: - mongodata:/data/db + - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro volumes: mongodata: diff --git a/marketplace-build/config/mongodb/mongo-init.js b/marketplace-build/config/mongodb/mongo-init.js new file mode 100644 index 000000000..5cef1331f --- /dev/null +++ b/marketplace-build/config/mongodb/mongo-init.js @@ -0,0 +1,12 @@ +db = db.getSiblingDB('admin'); +db.createUser( + { + user: "username", + pwd: "password", + roles: [ + { role: "userAdminAnyDatabase", db: "admin" }, + { role: "readWriteAnyDatabase", db: "admin" }, + { role: 'root', db: 'admin' } + ] + } +) \ No newline at end of file diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index ecc39822f..41f79df3b 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -16,11 +16,12 @@ services: command: ["mongod", "--config", "/etc/mongod.conf"] ui: + container_name: marketplace-ui build: - context: . + context: ../marketplace-ui additional_contexts: - assets: ../marketplace-ui/dist/ - dockerfile: Dockerfile-UI + assets: ../marketplace-build/ + dockerfile: Dockerfile restart: always volumes: - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf @@ -30,7 +31,6 @@ services: - service service: - image: marketplace-service container_name: marketplace-service restart: always environment: @@ -40,10 +40,10 @@ services: - MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD} - MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN} build: - context: . - additional_contexts: - assets: ../marketplace-service/target/ - dockerfile: Dockerfile-Service + context: ../marketplace-service + dockerfile: Dockerfile + volumes: + - ../marketplace-service/target/marketplace-service-0.0.1-SNAPSHOT.war:/usr/local/tomcat/webapps/marketplace-service.war volumes: - ../marketplace-service/target/marketplace-service-0.0.1-SNAPSHOT.war:/usr/local/tomcat/webapps/marketplace-service.war ports: diff --git a/marketplace-service/.dockerignore b/marketplace-service/.dockerignore new file mode 100644 index 000000000..0384b84cd --- /dev/null +++ b/marketplace-service/.dockerignore @@ -0,0 +1,33 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ +/bin/ diff --git a/marketplace-service/Dockerfile b/marketplace-service/Dockerfile new file mode 100644 index 000000000..8a963d725 --- /dev/null +++ b/marketplace-service/Dockerfile @@ -0,0 +1,21 @@ +# Stage 1: Maven build +FROM maven:3.8.1-openjdk-17 AS build-api +WORKDIR /app +COPY . . +RUN mvn clean install -DskipTests + +# Stage 2: Run the application +FROM tomcat:10.1-jdk17-openjdk-slim +WORKDIR /app +# Remove the default ROOT webapp to avoid conflicts +RUN rm -rf /usr/local/tomcat/webapps/ROOT + +# Copy the WAR file to the webapps directory in Tomcat +COPY --from=build-api /app/target/marketplace-service-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/marketplace-service.war + +# Expose port 8080 +EXPOSE 8080 + +# Start Tomcat +CMD ["catalina.sh", "run"] + diff --git a/marketplace-service/src/main/java/com/axonivy/market/entity/User.java b/marketplace-service/src/main/java/com/axonivy/market/entity/User.java index 0f8e7b612..10eb1c89a 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/entity/User.java +++ b/marketplace-service/src/main/java/com/axonivy/market/entity/User.java @@ -45,4 +45,4 @@ public boolean equals(Object obj) { } return new EqualsBuilder().append(id, ((User) obj).getId()).isEquals(); } -} +} \ No newline at end of file diff --git a/marketplace-ui/.dockerignore b/marketplace-ui/.dockerignore new file mode 100644 index 000000000..acaadf758 --- /dev/null +++ b/marketplace-ui/.dockerignore @@ -0,0 +1,5 @@ +node_modules +dist +.git +.gitignore +Dockerfile diff --git a/marketplace-ui/Dockerfile b/marketplace-ui/Dockerfile index a92872200..825c0f6bc 100644 --- a/marketplace-ui/Dockerfile +++ b/marketplace-ui/Dockerfile @@ -1,9 +1,11 @@ -# use the latest version of the official nginx image as the base image -FROM nginx:latest -# copy the custom nginx configuration file to the container in the -# default location -COPY nginx.conf /etc/nginx/nginx.conf -# copy the built Angular app files to the default nginx html directory -COPY /dist/browser /usr/share/nginx/html +# Stage 1: Build Angular app +FROM node:14-alpine AS build-angular +WORKDIR /app +COPY . . +RUN npm install +RUN npm run build --prod -# the paths are relative from the Docker file +# Stage 2: Serve Angular app using Nginx +FROM nginx:alpine +COPY --from=build-angular /app/dist/browser /usr/share/nginx/html +COPY --from=assets ./config/nginx/nginx.conf /etc/nginx/nginx.conf From dbd9e830ed361d8191d29e87f6de23da6007d1f7 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 11:18:26 +0700 Subject: [PATCH 05/34] Unify code --- marketplace-build/README.md | 17 ++++-------- .../config/mongodb/docker-compose.yml | 1 + marketplace-build/docker-compose.yml | 4 --- .../axonivy/market/config/MongoConfig.java | 27 ++++++++++--------- .../src/main/resources/application.properties | 2 +- marketplace-ui/Dockerfile | 2 +- 6 files changed, 22 insertions(+), 31 deletions(-) diff --git a/marketplace-build/README.md b/marketplace-build/README.md index 327f754b6..6b8c30ce0 100644 --- a/marketplace-build/README.md +++ b/marketplace-build/README.md @@ -1,7 +1,7 @@ # Get starts with Marketplace build ### Set up MongoDB with authentication mode -* Navigate to ``marketplace-build/config/mongodb`` and execute the ``docker-compose up`` to start MongoDB with non-auth mode and create a root admin user. +* Navigate to ``marketplace-build/config/mongodb`` and execute the ``docker-compose up -d`` to start MongoDB with non-auth mode and create a root admin user. * [Optional] Execute authentication test for the created user ``` @@ -10,19 +10,12 @@ ``` This command should return the ``OK`` code -### Docker build for DEV environment -* Navigate to ``marketplace-service`` and execute maven build for spring-boot app to get the war file: - ``` - mvn clean install -DskipTests - ``` +* Down the non-authen instance to start the main docker compose file by run ``docker-compose down`` -* Navigate to ``marketplace-ui`` and execute node install and run the angular app to get the dist folder: - ``` - npm instal - npm run build --prod - ``` +### Docker build for DEV environment +* Navigate to ``marketplace-build`` -* Please run ``docker-compose up --build`` from folder ``marketplace-build`` to start a Marketplace DEV at the local +* Run ``docker-compose up --build`` to start a Marketplace DEV at the local ### Docker release To release a new version for marketplace images, please trigger the ``Docker Release`` actions. diff --git a/marketplace-build/config/mongodb/docker-compose.yml b/marketplace-build/config/mongodb/docker-compose.yml index d02961e27..c7e2ec662 100644 --- a/marketplace-build/config/mongodb/docker-compose.yml +++ b/marketplace-build/config/mongodb/docker-compose.yml @@ -3,6 +3,7 @@ name: marketplace services: mongodb: + container_name: marketplace-mongodb-non-authen image: mongodb/mongodb-community-server:7.0.0-ubi8 restart: always ports: diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index 41f79df3b..816cf86ed 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -42,10 +42,6 @@ services: build: context: ../marketplace-service dockerfile: Dockerfile - volumes: - - ../marketplace-service/target/marketplace-service-0.0.1-SNAPSHOT.war:/usr/local/tomcat/webapps/marketplace-service.war - volumes: - - ../marketplace-service/target/marketplace-service-0.0.1-SNAPSHOT.war:/usr/local/tomcat/webapps/marketplace-service.war ports: - "8080:8080" depends_on: diff --git a/marketplace-service/src/main/java/com/axonivy/market/config/MongoConfig.java b/marketplace-service/src/main/java/com/axonivy/market/config/MongoConfig.java index 7f558f1cc..697ae2a4e 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/config/MongoConfig.java +++ b/marketplace-service/src/main/java/com/axonivy/market/config/MongoConfig.java @@ -1,9 +1,5 @@ package com.axonivy.market.config; -import com.mongodb.ConnectionString; -import com.mongodb.MongoClientSettings; -import com.mongodb.client.MongoClient; -import com.mongodb.client.MongoClients; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,13 +13,18 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; + @Configuration @EnableMongoRepositories(basePackages = "com.axonivy.market.repository") @EnableMongoAuditing public class MongoConfig extends AbstractMongoClientConfiguration { - @Value("${spring.data.mongodb.host}") - private String host; + @Value("${spring.data.mongodb.uri}") + private String uri; @Value("${spring.data.mongodb.database}") private String databaseName; @@ -33,14 +34,14 @@ protected String getDatabaseName() { return databaseName; } - @Override - public MongoClient mongoClient() { - ConnectionString connectionString = new ConnectionString(host); - MongoClientSettings mongoClientSettings = MongoClientSettings.builder().applyConnectionString(connectionString) - .build(); + @Override + public MongoClient mongoClient() { + ConnectionString connectionString = new ConnectionString(uri); + MongoClientSettings mongoClientSettings = MongoClientSettings.builder().applyConnectionString(connectionString) + .build(); - return MongoClients.create(mongoClientSettings); - } + return MongoClients.create(mongoClientSettings); + } /** * By default, the key in hash map is not allow to contain dot character (.) we diff --git a/marketplace-service/src/main/resources/application.properties b/marketplace-service/src/main/resources/application.properties index bdb5a651e..f945609f0 100644 --- a/marketplace-service/src/main/resources/application.properties +++ b/marketplace-service/src/main/resources/application.properties @@ -1,5 +1,5 @@ spring.application.name=marketplace-service -spring.data.mongodb.host=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@${MONGODB_HOST}:27017/ +spring.data.mongodb.uri=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@${MONGODB_HOST}:27017/ spring.data.mongodb.database=${MONGODB_DATABASE} server.port=8080 logging.level.org.springframework.web=warn diff --git a/marketplace-ui/Dockerfile b/marketplace-ui/Dockerfile index 825c0f6bc..e7e6dcee2 100644 --- a/marketplace-ui/Dockerfile +++ b/marketplace-ui/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build Angular app -FROM node:14-alpine AS build-angular +FROM node:20-alpine AS build-angular WORKDIR /app COPY . . RUN npm install From beb7c1d76871d8204e18045c6f1e5782323d72a8 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 11:23:13 +0700 Subject: [PATCH 06/34] Fix CI for angular --- .github/workflows/ui-ci-build.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index ea3b727ec..c1d0715f5 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -20,9 +20,13 @@ jobs: node-version: '20' cache: 'npm' - name: Install Dependencies - run: npm install + run: | + cd ./marketplace-ui + npm install - name: Build project - run: npm run build + run: | + cd ./marketplace-ui + npm run build analysis: name: Sonarqube @@ -35,7 +39,9 @@ jobs: steps: - name: Execute Tests - run: npm run test + run: | + cd ./marketplace-ui + npm run test - uses: sonarsource/sonarqube-scan-action@master env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} @@ -53,4 +59,5 @@ jobs: - name: Clean up run: | + cd ./marketplace-ui rm -rf * From a80797caeb12954f3e97974104becc814a66fbaf Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 12:24:35 +0700 Subject: [PATCH 07/34] Fix CI UI build --- .github/workflows/ui-ci-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index c1d0715f5..7623f0387 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -19,6 +19,7 @@ jobs: with: node-version: '20' cache: 'npm' + cache-dependency-path: ./marketplace-ui/package-lock.json - name: Install Dependencies run: | cd ./marketplace-ui From 73340dae8ae645b793e979781b5b5f56058ac9db Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 12:36:55 +0700 Subject: [PATCH 08/34] Add project basedir --- .github/workflows/ui-ci-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 7623f0387..85840b6f9 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -48,6 +48,7 @@ jobs: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} with: + projectBaseDir: ./marketplace-ui args: -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} - name: SonarQube Quality Gate check From 519e17ac48f8a1b1b6d0d49e0a58ad03f9a17a7a Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 13:33:46 +0700 Subject: [PATCH 09/34] Fix missing sonar report --- .github/workflows/ui-ci-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 85840b6f9..15cf6b227 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -54,6 +54,8 @@ jobs: - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master + with: + scanMetadataReportFile: ./marketplace-ui/coverage/lcov.info timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} From 35b495a7c14c3f0c67174a696f9e96b1aad52cf8 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 14:01:19 +0700 Subject: [PATCH 10/34] fix sonar --- .github/workflows/ui-ci-build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 15cf6b227..13d3fc238 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -48,20 +48,18 @@ jobs: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} with: - projectBaseDir: ./marketplace-ui + projectBaseDir: marketplace-ui args: -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master - with: - scanMetadataReportFile: ./marketplace-ui/coverage/lcov.info timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} - name: Clean up + working-directory: marketplace-ui run: | - cd ./marketplace-ui rm -rf * From d53bcb222ba999588e87f818ddd3ad82bd387ac1 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 14:06:49 +0700 Subject: [PATCH 11/34] try again --- .github/workflows/ui-ci-build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 13d3fc238..69edd9c2a 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -48,12 +48,14 @@ jobs: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} with: - projectBaseDir: marketplace-ui + projectBaseDir: ./marketplace-ui args: -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master + with: + scanMetadataReportFile: marketplace-ui/.scannerwork/coverage/lcov.info timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} From 4b3d935ed86471656fc1878e842ce231fc509500 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 14:11:45 +0700 Subject: [PATCH 12/34] again --- .github/workflows/ui-ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 69edd9c2a..5e29e8d06 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -55,7 +55,7 @@ jobs: id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master with: - scanMetadataReportFile: marketplace-ui/.scannerwork/coverage/lcov.info + scanMetadataReportFile: ./marketplace-ui/.scannerwork/coverage/lcov.info timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} From fe2a0974a8e930c101fd3ba2170c12cd5c6b7a91 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 14:39:36 +0700 Subject: [PATCH 13/34] again --- .github/workflows/ui-ci-build.yml | 3 +-- marketplace-ui/sonar-project.properties | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 5e29e8d06..e0595292c 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -51,11 +51,10 @@ jobs: projectBaseDir: ./marketplace-ui args: -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} + -Dsonar.javascript.lcov.reportPaths=${{ github.workspace }}/marketplace-ui/coverage/lcov.info - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master - with: - scanMetadataReportFile: ./marketplace-ui/.scannerwork/coverage/lcov.info timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} diff --git a/marketplace-ui/sonar-project.properties b/marketplace-ui/sonar-project.properties index e2453c704..829f41157 100644 --- a/marketplace-ui/sonar-project.properties +++ b/marketplace-ui/sonar-project.properties @@ -2,4 +2,3 @@ sonar.sources=src sonar.tests=src sonar.exclusions=**/node_modules/**, src/assets/**, **/*.html, **/*.scss, src/app/shared/mocks/**, **/*.constant.ts, **/*.enum.ts, **/*.routes.ts, **/*.model.ts, **/*.config.ts, src/environments/** sonar.test.inclusions=**/*.spec.ts -sonar.typescript.lcov.reportPaths=coverage/lcov.info \ No newline at end of file From b2cab8db322d05a01a5bb1e14e92532e7a5e1827 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 14:50:45 +0700 Subject: [PATCH 14/34] again --- .github/workflows/ui-ci-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index e0595292c..5e66fc851 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -55,6 +55,8 @@ jobs: - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master + with: + scanMetadataReportFile: ${{ github.workspace }}/marketplace-ui/coverage/lcov.info timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} From ac81ce8687a19177f714e1cd3779826a38b8fc6c Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Thu, 18 Jul 2024 17:42:55 +0700 Subject: [PATCH 15/34] Remove warning --- .../github/service/impl/GitHubServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java b/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java index 1418f8b66..264134e5c 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java +++ b/marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java @@ -1,13 +1,10 @@ package com.axonivy.market.github.service.impl; -import com.axonivy.market.constants.GitHubConstants; -import com.axonivy.market.entity.User; -import com.axonivy.market.enums.ErrorCode; -import com.axonivy.market.exceptions.model.NotFoundException; -import com.axonivy.market.exceptions.model.Oauth2ExchangeCodeException; -import com.axonivy.market.github.service.GitHubService; -import com.axonivy.market.model.GitHubAccessTokenResponse; -import com.axonivy.market.repository.UserRepository; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import org.kohsuke.github.GHContent; import org.kohsuke.github.GHOrganization; import org.kohsuke.github.GHRepository; @@ -28,9 +25,12 @@ import com.axonivy.market.constants.GitHubConstants; import com.axonivy.market.entity.User; +import com.axonivy.market.enums.ErrorCode; +import com.axonivy.market.exceptions.model.NotFoundException; import com.axonivy.market.exceptions.model.Oauth2ExchangeCodeException; import com.axonivy.market.github.model.GitHubProperty; import com.axonivy.market.github.service.GitHubService; +import com.axonivy.market.model.GitHubAccessTokenResponse; import com.axonivy.market.repository.UserRepository; @Service From 2d7013148209139181072e4464a61d8e50127a5c Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 08:44:17 +0700 Subject: [PATCH 16/34] Introduce new input for action --- .github/workflows/docker-release.yml | 9 ++++++--- marketplace-build/README.md | 11 ++++++++--- marketplace-build/release/docker-compose.yml | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 854276579..f316d0d91 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -4,6 +4,11 @@ on: push: branches: [ "master" ] workflow_dispatch: + inputs: + image_version: + description: 'Marketplace Docker image version' + required: true + default: 'latest' env: UI_IMAGE_NAME: marketplace-ui @@ -27,9 +32,7 @@ jobs: - name: Refine release version run: | # This strips the git ref prefix from the version. - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - # This strips the "v" prefix from the tag name. - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + VERSION=${{ github.event.inputs.image_version }} # This uses the Docker `latest` tag convention. [ "$VERSION" == "main" ] && VERSION=latest echo "VERSION=$VERSION" >> $GITHUB_ENV diff --git a/marketplace-build/README.md b/marketplace-build/README.md index 6b8c30ce0..741b59e02 100644 --- a/marketplace-build/README.md +++ b/marketplace-build/README.md @@ -15,7 +15,7 @@ This command should return the ``OK`` code ### Docker build for DEV environment * Navigate to ``marketplace-build`` -* Run ``docker-compose up --build`` to start a Marketplace DEV at the local +* Run ``docker-compose up -d --build`` to start a Marketplace DEV at the local ### Docker release To release a new version for marketplace images, please trigger the ``Docker Release`` actions. @@ -24,5 +24,10 @@ To release a new version for marketplace images, please trigger the ``Docker Rel * Deploy new image to packages. Please verify the result in the ``Package`` after the build is completed. -### Docker compose for PROD deployment -* Navigate to ``marketplace-build/release`` run ``docker-compose up`` to clone the docker images from GitHub packages and start the website +### Start Docker compose for PROD deployment +* Navigate to ``marketplace-build/release`` run ``docker-compose up -d`` to clone the docker images from GitHub packages and start the website + +### Start Docker compose using SPRINT release version +* Navigate to ``marketplace-build/release`` run ``docker-compose -f sprint-compose.yml up`` to clone the docker images from GitHub packages and start the website + + diff --git a/marketplace-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml index 491361199..760cbf60e 100644 --- a/marketplace-build/release/docker-compose.yml +++ b/marketplace-build/release/docker-compose.yml @@ -2,10 +2,23 @@ name: marketplace-website services: mongodb: - image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-db:latest + build: + context: ../config/mongodb + container_name: marketplace-mongodb-7.0.0 + restart: always + ports: + - "27017:27017" + environment: + MONGODB_INITDB_ROOT_USERNAME: ${MONGODB_INITDB_ROOT_USERNAME} + MONGODB_INITDB_ROOT_PASSWORD: ${MONGODB_INITDB_ROOT_PASSWORD} + volumes: + - mongodata:/data/db + - ../config/mongodb/mongod.conf:/etc/mongod.conf nginx: image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-nginx:latest + ports: + - "95:80" marketplace-service: image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-service:latest From cb248f31d4b4f0dc4612a338b9a32036f162ea2c Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 09:07:46 +0700 Subject: [PATCH 17/34] Remove manual build --- .github/workflows/docker-build.yml | 20 ------------------- .../config/mongodb/docker-compose.yml | 4 +++- marketplace-build/docker-compose.yml | 5 +++-- marketplace-build/release/docker-compose.yml | 5 +++-- marketplace-build/release/sprint-compose.yml | 9 +++++---- 5 files changed, 14 insertions(+), 29 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 7760089f0..10f315adb 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -12,26 +12,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Build Marketplace service project - run: | - cd ./marketplace-service - mvn clean install -DskipTests - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: ./marketplace-ui/package-lock.json - - name: Build Marketplace ui project - run: | - cd ./marketplace-ui - npm i - npm run build --prod - name: Update environment variables for ENV env: ENV_FILE: './marketplace-build/.env' diff --git a/marketplace-build/config/mongodb/docker-compose.yml b/marketplace-build/config/mongodb/docker-compose.yml index c7e2ec662..606db72df 100644 --- a/marketplace-build/config/mongodb/docker-compose.yml +++ b/marketplace-build/config/mongodb/docker-compose.yml @@ -4,7 +4,9 @@ name: marketplace services: mongodb: container_name: marketplace-mongodb-non-authen - image: mongodb/mongodb-community-server:7.0.0-ubi8 + build: + context: . + dockerfile: Dockerfile restart: always ports: - "27017:27017" diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index 816cf86ed..df25280df 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -2,8 +2,10 @@ name: marketplace services: mongodb: - image: mongodb/mongodb-community-server:7.0.0-ubi8 container_name: marketplace-mongodb-7.0.0 + build: + context: ./config/mongodb + dockerfile: Dockerfile restart: always ports: - "27017:27017" @@ -13,7 +15,6 @@ services: volumes: - mongodata:/data/db - ./config/mongodb/mongod.conf:/etc/mongod.conf - command: ["mongod", "--config", "/etc/mongod.conf"] ui: container_name: marketplace-ui diff --git a/marketplace-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml index 760cbf60e..b5868dc5b 100644 --- a/marketplace-build/release/docker-compose.yml +++ b/marketplace-build/release/docker-compose.yml @@ -4,6 +4,7 @@ services: mongodb: build: context: ../config/mongodb + dockerfile: Dockerfile container_name: marketplace-mongodb-7.0.0 restart: always ports: @@ -15,12 +16,12 @@ services: - mongodata:/data/db - ../config/mongodb/mongod.conf:/etc/mongod.conf - nginx: + ui: image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-nginx:latest ports: - "95:80" - marketplace-service: + service: image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-service:latest volumes: diff --git a/marketplace-build/release/sprint-compose.yml b/marketplace-build/release/sprint-compose.yml index 956172aed..8de58faad 100644 --- a/marketplace-build/release/sprint-compose.yml +++ b/marketplace-build/release/sprint-compose.yml @@ -2,8 +2,10 @@ name: marketplace-website services: mongodb: - image: mongodb/mongodb-community-server:7.0.0-ubi8 container_name: marketplace-mongodb-7.0.0 + build: + context: ../config/mongodb + dockerfile: Dockerfile restart: always ports: - "27017:27017" @@ -13,12 +15,11 @@ services: volumes: - mongodata:/data/db - ../config/mongodb/mongod.conf:/etc/mongod.conf - command: ["mongod", "--config", "/etc/mongod.conf"] - nginx: + ui: image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-nginx:latest - marketplace-service: + service: image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-service:latest volumes: From a7bf9ebfcdd2ea3e23fd57f23b6402a3fea54d19 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 10:24:51 +0700 Subject: [PATCH 18/34] Fix UI does not build --- .github/workflows/docker-build.yml | 3 ++- marketplace-build/.env | 3 ++- marketplace-build/docker-compose.yml | 1 + marketplace-ui/Dockerfile | 2 +- marketplace-ui/nginx.conf | 27 --------------------------- 5 files changed, 6 insertions(+), 30 deletions(-) delete mode 100644 marketplace-ui/nginx.conf diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 10f315adb..fc4fc373c 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -30,9 +30,10 @@ 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=dummy/" $ENV_FILE - name: Refresh Docker images working-directory: ./marketplace-build run: | docker compose down - docker compose -f docker-compose.yml up -d + docker compose up -d diff --git a/marketplace-build/.env b/marketplace-build/.env index e2ca21cd2..8f0271811 100644 --- a/marketplace-build/.env +++ b/marketplace-build/.env @@ -4,4 +4,5 @@ SERVICE_MONGODB_HOST= SERVICE_MONGODB_USER= SERVICE_MONGODB_PASSWORD= SERVICE_MONGODB_DATABASE= -MARKET_GITHUB_TOKEN= \ No newline at end of file +MARKET_GITHUB_TOKEN= +MARKETPLACE_INSTALLATION_URL= \ No newline at end of file diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index df25280df..e3f864ead 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -40,6 +40,7 @@ services: - 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-ui/Dockerfile b/marketplace-ui/Dockerfile index e7e6dcee2..e02ed0f60 100644 --- a/marketplace-ui/Dockerfile +++ b/marketplace-ui/Dockerfile @@ -8,4 +8,4 @@ RUN npm run build --prod # Stage 2: Serve Angular app using Nginx FROM nginx:alpine COPY --from=build-angular /app/dist/browser /usr/share/nginx/html -COPY --from=assets ./config/nginx/nginx.conf /etc/nginx/nginx.conf +COPY --from=assets config/nginx/nginx.conf /etc/nginx/nginx.conf diff --git a/marketplace-ui/nginx.conf b/marketplace-ui/nginx.conf deleted file mode 100644 index bd3cc2b35..000000000 --- a/marketplace-ui/nginx.conf +++ /dev/null @@ -1,27 +0,0 @@ -# the events block is required -events{} - -http { - # include the default mime.types to map file extensions to MIME types - include /etc/nginx/mime.types; - - server { - # set the root directory for the server (we need to copy our - # application files here) - root /usr/share/nginx/html; - - # set the default index file for the server (Angular generates the - # index.html file for us and it will be in the above directory) - index index.html; - - # specify the configuration for the '/' location - location / { - # try to serve the requested URI. if that fails then try to - # serve the URI with a trailing slash. if that fails, then - # serve the index.html file; this is needed in order to serve - # Angular routes--e.g.,'localhost:8080/customer' will serve - # the index.html file - try_files $uri $uri/ /index.html; - } - } -} From 99c14363f30a262683cd4656d1e95711c91042f7 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 11:07:30 +0700 Subject: [PATCH 19/34] Unify port --- .github/workflows/docker-build.yml | 5 +++-- marketplace-build/config/nginx/nginx.conf | 15 --------------- marketplace-build/docker-compose.yml | 2 +- marketplace-build/release/docker-compose.yml | 6 +++--- marketplace-build/release/sprint-compose.yml | 6 ++++-- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index fc4fc373c..07542118a 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Update environment variables for ENV + - name: Update environment variables for .env env: ENV_FILE: './marketplace-build/.env' MONGODB_HOST: ${{ secrets.MONGODB_HOST }} @@ -22,6 +22,7 @@ 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 @@ -30,7 +31,7 @@ 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=dummy/" $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/config/nginx/nginx.conf b/marketplace-build/config/nginx/nginx.conf index bd3cc2b35..e9fe9ac0c 100644 --- a/marketplace-build/config/nginx/nginx.conf +++ b/marketplace-build/config/nginx/nginx.conf @@ -1,4 +1,3 @@ -# the events block is required events{} http { @@ -6,22 +5,8 @@ http { include /etc/nginx/mime.types; server { - # set the root directory for the server (we need to copy our - # application files here) root /usr/share/nginx/html; - # set the default index file for the server (Angular generates the - # index.html file for us and it will be in the above directory) index index.html; - - # specify the configuration for the '/' location - location / { - # try to serve the requested URI. if that fails then try to - # serve the URI with a trailing slash. if that fails, then - # serve the index.html file; this is needed in order to serve - # Angular routes--e.g.,'localhost:8080/customer' will serve - # the index.html file - try_files $uri $uri/ /index.html; - } } } diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index e3f864ead..5cf4f924e 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -27,7 +27,7 @@ services: volumes: - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf ports: - - "90:80" + - "4200:80" depends_on: - service diff --git a/marketplace-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml index b5868dc5b..66595b534 100644 --- a/marketplace-build/release/docker-compose.yml +++ b/marketplace-build/release/docker-compose.yml @@ -17,12 +17,12 @@ services: - ../config/mongodb/mongod.conf:/etc/mongod.conf ui: - image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-nginx:latest + image: ghcr.io/axonivy-market/marketplace-ui:latest ports: - - "95:80" + - "80:80" service: - image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-service:latest + image: ghcr.io/axonivy-market/marketplace-service:latest volumes: mongodata: \ No newline at end of file diff --git a/marketplace-build/release/sprint-compose.yml b/marketplace-build/release/sprint-compose.yml index 8de58faad..04c34606f 100644 --- a/marketplace-build/release/sprint-compose.yml +++ b/marketplace-build/release/sprint-compose.yml @@ -17,10 +17,12 @@ services: - ../config/mongodb/mongod.conf:/etc/mongod.conf ui: - image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-nginx:latest + image: ghcr.io/axonivy-market/marketplace-ui:sprint + ports: + - "95:80" service: - image: ghcr.io/nqhoan-axonivy/marketplace/marketplace-service:latest + image: ghcr.io/axonivy-market/marketplace-service:sprint volumes: mongodata: \ No newline at end of file From b3517b1ad23af66dca01b3caf52ce87f8c6f5812 Mon Sep 17 00:00:00 2001 From: tutn Date: Fri, 19 Jul 2024 11:34:26 +0700 Subject: [PATCH 20/34] Test path --- .github/workflows/ui-ci-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 5e66fc851..472ce7280 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -52,6 +52,9 @@ jobs: args: -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.javascript.lcov.reportPaths=${{ github.workspace }}/marketplace-ui/coverage/lcov.info + + - run: echo $(ls -l ${{ github.workspace }}/marketplace-ui/coverage) + - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master From 0b49115b5418adf097ad46a15c64c2db4b8926a2 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 11:35:17 +0700 Subject: [PATCH 21/34] Fix env with specifit char --- .github/workflows/docker-build.yml | 16 ++++++++-------- marketplace-build/release/.env | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 07542118a..0c72bdc5e 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -24,14 +24,14 @@ jobs: 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 - sed -i "s/^SERVICE_MONGODB_HOST=.*$/SERVICE_MONGODB_HOST=$MONGODB_HOST/" $ENV_FILE - sed -i "s/^SERVICE_MONGODB_DATABASE=.*$/SERVICE_MONGODB_DATABASE=$MONGODB_DATABASE/" $ENV_FILE - 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 + 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 + sed -i 's|^SERVICE_MONGODB_HOST=.*|SERVICE_MONGODB_HOST=${MONGODB_HOST}'| $ENV_FILE + sed -i 's|^SERVICE_MONGODB_DATABASE=.*|SERVICE_MONGODB_DATABASE=${MONGODB_DATABASE}'| $ENV_FILE + 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/.env b/marketplace-build/release/.env index e2ca21cd2..8f0271811 100644 --- a/marketplace-build/release/.env +++ b/marketplace-build/release/.env @@ -4,4 +4,5 @@ SERVICE_MONGODB_HOST= SERVICE_MONGODB_USER= SERVICE_MONGODB_PASSWORD= SERVICE_MONGODB_DATABASE= -MARKET_GITHUB_TOKEN= \ No newline at end of file +MARKET_GITHUB_TOKEN= +MARKETPLACE_INSTALLATION_URL= \ No newline at end of file From cdfaada7cf38a03d7bc267f5e5e862c5cd15eef6 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 11:40:10 +0700 Subject: [PATCH 22/34] Fix wrong synctax --- .github/workflows/docker-build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 0c72bdc5e..1bab3c929 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -24,13 +24,13 @@ jobs: 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 - sed -i 's|^SERVICE_MONGODB_HOST=.*|SERVICE_MONGODB_HOST=${MONGODB_HOST}'| $ENV_FILE - sed -i 's|^SERVICE_MONGODB_DATABASE=.*|SERVICE_MONGODB_DATABASE=${MONGODB_DATABASE}'| $ENV_FILE - 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|^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 + sed -i 's|^SERVICE_MONGODB_HOST=.*|SERVICE_MONGODB_HOST=${MONGODB_HOST}|' $ENV_FILE + sed -i 's|^SERVICE_MONGODB_DATABASE=.*|SERVICE_MONGODB_DATABASE=${MONGODB_DATABASE}|' $ENV_FILE + 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 From 5021e6addc2b7537daf4d4404662e605d0c0a42c Mon Sep 17 00:00:00 2001 From: tutn Date: Fri, 19 Jul 2024 11:40:45 +0700 Subject: [PATCH 23/34] remove with --- .github/workflows/ui-ci-build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index 472ce7280..b2b1e28c0 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -53,13 +53,11 @@ jobs: -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.javascript.lcov.reportPaths=${{ github.workspace }}/marketplace-ui/coverage/lcov.info - - run: echo $(ls -l ${{ github.workspace }}/marketplace-ui/coverage) - - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master - with: - scanMetadataReportFile: ${{ github.workspace }}/marketplace-ui/coverage/lcov.info + # with: + # scanMetadataReportFile: ${{ github.workspace }}/marketplace-ui/coverage/lcov.info timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} From ec66eea67a7d49388877b46cbaaf12b53e2f6969 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 11:43:23 +0700 Subject: [PATCH 24/34] Wrong syntax --- .github/workflows/docker-build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 1bab3c929..568854b12 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -24,14 +24,14 @@ jobs: 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 - sed -i 's|^SERVICE_MONGODB_HOST=.*|SERVICE_MONGODB_HOST=${MONGODB_HOST}|' $ENV_FILE - sed -i 's|^SERVICE_MONGODB_DATABASE=.*|SERVICE_MONGODB_DATABASE=${MONGODB_DATABASE}|' $ENV_FILE - 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 + 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 + sed -i 's|^SERVICE_MONGODB_HOST=.*|SERVICE_MONGODB_HOST=$MONGODB_HOST|' $ENV_FILE + sed -i 's|^SERVICE_MONGODB_DATABASE=.*|SERVICE_MONGODB_DATABASE=$MONGODB_DATABASE|' $ENV_FILE + 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 From e1efe3f181d6e05f8dc872811fd896ace597ea0e Mon Sep 17 00:00:00 2001 From: tutn Date: Fri, 19 Jul 2024 11:46:45 +0700 Subject: [PATCH 25/34] Update sonar meta --- .github/workflows/ui-ci-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ui-ci-build.yml b/.github/workflows/ui-ci-build.yml index b2b1e28c0..d792f34a8 100644 --- a/.github/workflows/ui-ci-build.yml +++ b/.github/workflows/ui-ci-build.yml @@ -56,8 +56,8 @@ jobs: - name: SonarQube Quality Gate check id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master - # with: - # scanMetadataReportFile: ${{ github.workspace }}/marketplace-ui/coverage/lcov.info + with: + scanMetadataReportFile: ${{ github.workspace }}/marketplace-ui/.scannerwork/report-task.txt timeout-minutes: 5 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} From 89004e48ce7ed36fdbfa810d5d874ee9efeb1847 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 11:55:47 +0700 Subject: [PATCH 26/34] update syntax --- .github/workflows/docker-build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 568854b12..07542118a 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -24,14 +24,14 @@ jobs: 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 - sed -i 's|^SERVICE_MONGODB_HOST=.*|SERVICE_MONGODB_HOST=$MONGODB_HOST|' $ENV_FILE - sed -i 's|^SERVICE_MONGODB_DATABASE=.*|SERVICE_MONGODB_DATABASE=$MONGODB_DATABASE|' $ENV_FILE - 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 + 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 + sed -i "s/^SERVICE_MONGODB_HOST=.*$/SERVICE_MONGODB_HOST=$MONGODB_HOST/" $ENV_FILE + sed -i "s/^SERVICE_MONGODB_DATABASE=.*$/SERVICE_MONGODB_DATABASE=$MONGODB_DATABASE/" $ENV_FILE + 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 From d8e67cc635015aa2506b872926d2a9921b18f947 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 12:07:29 +0700 Subject: [PATCH 27/34] Rename build --- .github/workflows/docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 07542118a..bbe173702 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,4 +1,4 @@ -name: Docker build +name: Docker Build on: push: From e7e4392fb2536e9ee4c645df550b617337b9235c Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Fri, 19 Jul 2024 13:46:06 +0700 Subject: [PATCH 28/34] Add env for release --- marketplace-build/release/docker-compose.yml | 11 ++++++++++- marketplace-build/release/sprint-compose.yml | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/marketplace-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml index 66595b534..983c94622 100644 --- a/marketplace-build/release/docker-compose.yml +++ b/marketplace-build/release/docker-compose.yml @@ -1,4 +1,4 @@ -name: marketplace-website +name: marketplace services: mongodb: @@ -18,11 +18,20 @@ services: ui: image: ghcr.io/axonivy-market/marketplace-ui:latest + restart: always ports: - "80:80" service: image: ghcr.io/axonivy-market/marketplace-service:latest + restart: always + 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-build/release/sprint-compose.yml b/marketplace-build/release/sprint-compose.yml index 04c34606f..85b42f243 100644 --- a/marketplace-build/release/sprint-compose.yml +++ b/marketplace-build/release/sprint-compose.yml @@ -1,4 +1,4 @@ -name: marketplace-website +name: marketplace services: mongodb: @@ -18,11 +18,20 @@ services: ui: image: ghcr.io/axonivy-market/marketplace-ui:sprint + restart: always ports: - "95:80" service: image: ghcr.io/axonivy-market/marketplace-service:sprint - + restart: always + 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 + mongodata: + \ No newline at end of file From 8866b51b482b32c53cc17014787b2b465ded6985 Mon Sep 17 00:00:00 2001 From: Dinh Nguyen Date: Fri, 19 Jul 2024 16:35:36 +0700 Subject: [PATCH 29/34] update util for local env - sonar scanner --- .../util-local/sonar/docker-compose.yml | 44 +++++++++++++++++++ marketplace-build/util-local/sonar/init-db.sh | 7 +++ marketplace-build/util-local/sonar/init.sh | 2 + 3 files changed, 53 insertions(+) create mode 100644 marketplace-build/util-local/sonar/docker-compose.yml create mode 100644 marketplace-build/util-local/sonar/init-db.sh create mode 100644 marketplace-build/util-local/sonar/init.sh diff --git a/marketplace-build/util-local/sonar/docker-compose.yml b/marketplace-build/util-local/sonar/docker-compose.yml new file mode 100644 index 000000000..415936562 --- /dev/null +++ b/marketplace-build/util-local/sonar/docker-compose.yml @@ -0,0 +1,44 @@ + +services: + sonarqube: + image: sonarqube:latest + name: sonar_local + ports: + - '9000:9000' + environment: + - SONAR_JDBC_URL=jdbc:postgresql://postgres:5432/mydb + - SONAR_JDBC_USERNAME=sonar + - SONAR_JDBC_PASSWORD=sonar + volumes: + - sonarqube_data:/opt/sonarqube + - sonarqube_extensions:/opt/sonarqube/extensions + depends_on: + - init + - postgres + + postgres: + image: postgres:12 + container_name: postgres_sonar + environment: + - POSTGRES_DB=mydb + - POSTGRES_USER=sonar + - POSTGRES_PASSWORD=sonar + - POSTGRES_INITDB_ARGS=--data-checksums + volumes: + - postgres_data:/var/lib/postgresql/data + - ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh + ports: + - "5432:5432" + + init: + image: bash + privileged: true + user: root + volumes: + - ./init.sh:/init.sh + command: ["sh", "-e", "/init.sh"] + +volumes: + sonarqube_data: + sonarqube_extensions: + postgres_data: \ No newline at end of file diff --git a/marketplace-build/util-local/sonar/init-db.sh b/marketplace-build/util-local/sonar/init-db.sh new file mode 100644 index 000000000..758c2c205 --- /dev/null +++ b/marketplace-build/util-local/sonar/init-db.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE ROLE mysuper WITH SUPERUSER CREATEDB CREATEROLE NOLOGIN; + ALTER USER myuser WITH SUPERUSER; +EOSQL \ No newline at end of file diff --git a/marketplace-build/util-local/sonar/init.sh b/marketplace-build/util-local/sonar/init.sh new file mode 100644 index 000000000..5096e4f32 --- /dev/null +++ b/marketplace-build/util-local/sonar/init.sh @@ -0,0 +1,2 @@ +sysctl -w vm.max_map_count=262144 +sysctl -w fs.file-max=131072 \ No newline at end of file From 6324ca753a7a443d2627b2f20ac3ac055984168c Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Mon, 22 Jul 2024 09:59:44 +0700 Subject: [PATCH 30/34] Handle feedback --- marketplace-build/.dockerignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/marketplace-build/.dockerignore b/marketplace-build/.dockerignore index 483c6a7f7..429ee38ff 100644 --- a/marketplace-build/.dockerignore +++ b/marketplace-build/.dockerignore @@ -1,3 +1,2 @@ # Node -/node_modules -../marketplace-ui/node_modules \ No newline at end of file +**/node_modules \ No newline at end of file From 3edc79cf0fcbf6d7e50884473d633b0f2ff6149d Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Mon, 22 Jul 2024 10:02:16 +0700 Subject: [PATCH 31/34] Unify folder --- marketplace-build/{util-local => dev}/sonar/docker-compose.yml | 0 marketplace-build/{util-local => dev}/sonar/init-db.sh | 0 marketplace-build/{util-local => dev}/sonar/init.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename marketplace-build/{util-local => dev}/sonar/docker-compose.yml (100%) rename marketplace-build/{util-local => dev}/sonar/init-db.sh (100%) rename marketplace-build/{util-local => dev}/sonar/init.sh (100%) diff --git a/marketplace-build/util-local/sonar/docker-compose.yml b/marketplace-build/dev/sonar/docker-compose.yml similarity index 100% rename from marketplace-build/util-local/sonar/docker-compose.yml rename to marketplace-build/dev/sonar/docker-compose.yml diff --git a/marketplace-build/util-local/sonar/init-db.sh b/marketplace-build/dev/sonar/init-db.sh similarity index 100% rename from marketplace-build/util-local/sonar/init-db.sh rename to marketplace-build/dev/sonar/init-db.sh diff --git a/marketplace-build/util-local/sonar/init.sh b/marketplace-build/dev/sonar/init.sh similarity index 100% rename from marketplace-build/util-local/sonar/init.sh rename to marketplace-build/dev/sonar/init.sh From 1f10fb554be75267a50b52561783b0fc4404bae1 Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Wed, 24 Jul 2024 15:09:06 +0700 Subject: [PATCH 32/34] Added revert proxy for server to avoid cors check --- marketplace-build/config/nginx/nginx.conf | 14 ++++++++++++++ marketplace-build/docker-compose.yml | 2 +- marketplace-ui/Dockerfile | 2 +- marketplace-ui/src/app/auth/auth.service.ts | 2 +- .../src/app/core/interceptors/api.interceptor.ts | 2 +- .../src/environments/environment.development.ts | 2 +- marketplace-ui/src/environments/environment.ts | 5 ++--- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/marketplace-build/config/nginx/nginx.conf b/marketplace-build/config/nginx/nginx.conf index e9fe9ac0c..5507e98ce 100644 --- a/marketplace-build/config/nginx/nginx.conf +++ b/marketplace-build/config/nginx/nginx.conf @@ -5,8 +5,22 @@ http { include /etc/nginx/mime.types; server { + listen 80; + server_name marketplace; + root /usr/share/nginx/html; index index.html; + + location /marketplace-service { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-NginX-Proxy true; + proxy_pass http://service:8080/marketplace-service; + proxy_ssl_session_reuse off; + proxy_set_header Host $http_host; + proxy_cache_bypass $http_upgrade; + proxy_redirect off; + } } } diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index 5cf4f924e..2fe84626b 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -2,7 +2,7 @@ name: marketplace services: mongodb: - container_name: marketplace-mongodb-7.0.0 + container_name: marketplace-mongodb build: context: ./config/mongodb dockerfile: Dockerfile diff --git a/marketplace-ui/Dockerfile b/marketplace-ui/Dockerfile index e02ed0f60..eb7f9dc12 100644 --- a/marketplace-ui/Dockerfile +++ b/marketplace-ui/Dockerfile @@ -6,6 +6,6 @@ RUN npm install RUN npm run build --prod # Stage 2: Serve Angular app using Nginx -FROM nginx:alpine +FROM nginx COPY --from=build-angular /app/dist/browser /usr/share/nginx/html COPY --from=assets config/nginx/nginx.conf /etc/nginx/nginx.conf diff --git a/marketplace-ui/src/app/auth/auth.service.ts b/marketplace-ui/src/app/auth/auth.service.ts index 39e4fccbb..1021ffd17 100644 --- a/marketplace-ui/src/app/auth/auth.service.ts +++ b/marketplace-ui/src/app/auth/auth.service.ts @@ -28,7 +28,7 @@ export class AuthService { private readonly BASE_URL = environment.apiUrl; private readonly TOKEN_KEY = 'token'; private readonly githubAuthUrl = 'https://github.com/login/oauth/authorize'; - private readonly githubAuthCallbackUrl = environment.githubAuthCallbackUrl; + private readonly githubAuthCallbackUrl = window.location.host + environment.githubAuthCallbackUrl; constructor( private readonly http: HttpClient, diff --git a/marketplace-ui/src/app/core/interceptors/api.interceptor.ts b/marketplace-ui/src/app/core/interceptors/api.interceptor.ts index 249a97ec0..e8ec8fa2b 100644 --- a/marketplace-ui/src/app/core/interceptors/api.interceptor.ts +++ b/marketplace-ui/src/app/core/interceptors/api.interceptor.ts @@ -24,7 +24,7 @@ export const apiInterceptor: HttpInterceptorFn = (req, next) => { } let requestURL = req.url; const apiURL = environment.apiUrl; - if (!requestURL.startsWith(apiURL)) { + if (!requestURL.includes(apiURL)) { requestURL = `${apiURL}/${req.url}`; } diff --git a/marketplace-ui/src/environments/environment.development.ts b/marketplace-ui/src/environments/environment.development.ts index 4a93e0eca..48f6e55ab 100644 --- a/marketplace-ui/src/environments/environment.development.ts +++ b/marketplace-ui/src/environments/environment.development.ts @@ -2,6 +2,6 @@ export const environment = { production: false, apiUrl: 'http://localhost:9090/marketplace-service', githubClientId: 'Ov23liUzb36JCQIfEBGn', - githubAuthCallbackUrl: 'http://localhost:4200/auth/github/callback', + githubAuthCallbackUrl: '/auth/github/callback', dayInMiliseconds: 86400000 }; diff --git a/marketplace-ui/src/environments/environment.ts b/marketplace-ui/src/environments/environment.ts index 9d002c724..dd01676f5 100644 --- a/marketplace-ui/src/environments/environment.ts +++ b/marketplace-ui/src/environments/environment.ts @@ -1,8 +1,7 @@ export const environment = { production: true, - apiUrl: 'http://marketplace.server.ivy-cloud.com:8080/marketplace-service', + apiUrl: '/marketplace-service', githubClientId: 'Ov23liVMliBxBqdQ7FnG', - githubAuthCallbackUrl: 'http://marketplace.server.ivy-cloud.com:4200/auth/github/callback', + githubAuthCallbackUrl: '/auth/github/callback', dayInMiliseconds: 86400000 - }; From 120a64ec9ff71fc15d3955a68a5185357308dadc Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Wed, 24 Jul 2024 15:17:29 +0700 Subject: [PATCH 33/34] Resolve conflict --- marketplace-build/config/nginx/nginx.conf | 4 ++++ marketplace-build/docker-compose.yml | 2 ++ marketplace-build/release/docker-compose.yml | 3 ++- marketplace-service/src/main/resources/application.properties | 2 -- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/marketplace-build/config/nginx/nginx.conf b/marketplace-build/config/nginx/nginx.conf index 5507e98ce..a2bd1f39b 100644 --- a/marketplace-build/config/nginx/nginx.conf +++ b/marketplace-build/config/nginx/nginx.conf @@ -12,6 +12,10 @@ http { index index.html; + location / { + try_files $uri $uri/ /index.html; + } + location /marketplace-service { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index 3e0a0b17e..cbb6eecee 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -34,6 +34,8 @@ services: service: container_name: marketplace-service 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-build/release/docker-compose.yml b/marketplace-build/release/docker-compose.yml index 983c94622..8dd907bfc 100644 --- a/marketplace-build/release/docker-compose.yml +++ b/marketplace-build/release/docker-compose.yml @@ -25,13 +25,14 @@ services: service: image: ghcr.io/axonivy-market/marketplace-service:latest 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} - 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 5f1451dab..b2fd17582 100644 --- a/marketplace-service/src/main/resources/application.properties +++ b/marketplace-service/src/main/resources/application.properties @@ -11,8 +11,6 @@ market.cors.allowed.origin.maxAge=3600 synchronized.installation.counts.path=/home/data/market-installation.json market.github.token=${MARKET_GITHUB_TOKEN} logging.level.org.springframework.security=DEBUG -market.github.token=${MARKET_GITHUB_TOKEN} -logging.level.org.springframework.security=DEBUG spring.security.oauth2.client.registration.github.client-id= spring.security.oauth2.client.registration.github.client-secret= jwt.secret= From 209ddc335ee28da2a23ca4376f72ad16e58f830b Mon Sep 17 00:00:00 2001 From: Hoan Nguyen Date: Wed, 24 Jul 2024 15:19:38 +0700 Subject: [PATCH 34/34] Resovlve conflict --- marketplace-build/docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/marketplace-build/docker-compose.yml b/marketplace-build/docker-compose.yml index cbb6eecee..bc559bb1b 100644 --- a/marketplace-build/docker-compose.yml +++ b/marketplace-build/docker-compose.yml @@ -42,7 +42,6 @@ services: - 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