Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/axonivy-market/marketplace
Browse files Browse the repository at this point in the history
… into feature/MARP-224-Create-dockerfile-for-deployment-of-marketplace

# Conflicts:
#	.github/workflows/docker-build.yml
#	.github/workflows/docker-release.yml
#	marketplace-build/config/nginx/nginx.conf
#	marketplace-build/docker-compose.yml
#	marketplace-build/release/docker-compose.yml
#	marketplace-build/release/sprint-compose.yml
#	marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GitHubServiceImpl.java
#	marketplace-service/src/main/resources/application.properties
#	marketplace-ui/Dockerfile
#	marketplace-ui/src/environments/environment.ts
  • Loading branch information
nqhoan-axonivy committed Jul 24, 2024
2 parents 1f10fb5 + 9067cf7 commit 20d5099
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 35 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ on:
workflow_call:

jobs:
build:
cleanup:
name: Clean up docker container and images
runs-on: self-hosted

steps:
- uses: actions/checkout@v4
- name: Bring down and remove containers and images
working-directory: ./marketplace-build
run: |
docker compose down --rmi all
build-and-deploy:
name: Build and bring up docker containers
runs-on: self-hosted
needs: cleanup

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Update environment variables for .env
env:
ENV_FILE: './marketplace-build/.env'
Expand All @@ -22,7 +36,6 @@ jobs:
SERVICE_PASSWORD: ${{ secrets.SERVICE_PASSWORD }}
MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MARKETPLACE_INSTALLATION_URL: ${{ secrets.MARKETPLACE_INSTALLATION_URL }}
run: |
sed -i "s/^MONGODB_INITDB_ROOT_USERNAME=.*$/MONGODB_INITDB_ROOT_USERNAME=$ROOT_USERNAME/" $ENV_FILE
sed -i "s/^MONGODB_INITDB_ROOT_PASSWORD=.*$/MONGODB_INITDB_ROOT_PASSWORD=$ROOT_PASSWORD/" $ENV_FILE
Expand All @@ -31,10 +44,8 @@ jobs:
sed -i "s/^SERVICE_MONGODB_USER=.*$/SERVICE_MONGODB_USER=$SERVICE_USERNAME/" $ENV_FILE
sed -i "s/^SERVICE_MONGODB_PASSWORD=.*$/SERVICE_MONGODB_PASSWORD=$SERVICE_PASSWORD/" $ENV_FILE
sed -i "s/^MARKET_GITHUB_TOKEN=.*$/MARKET_GITHUB_TOKEN=$GH_TOKEN/" $ENV_FILE
sed -i "s/^MARKETPLACE_INSTALLATION_URL=.*$/MARKETPLACE_INSTALLATION_URL=$MARKETPLACE_INSTALLATION_URL/" $ENV_FILE
- name: Refresh Docker images
- name: Build and bring up containers without cache
working-directory: ./marketplace-build
run: |
docker compose down
docker compose up -d
docker compose up --build --force-recreate -d
21 changes: 21 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,46 @@ env:
jobs:

build:
name: Build Docker images
uses: ./.github/workflows/docker-build.yml

release:
name: Tag and publish image to GH packages
needs: build
runs-on: self-hosted
permissions:
packages: write
contents: read

steps:
- name: Wait for containers to be up and running
working-directory: ./marketplace-build
run: |
# Wait for up to 300 seconds for the containers to be up
timeout=300
start_time=$(date +%s)
while [ $(($(date +%s) - start_time)) -lt $timeout ]; do
if docker compose ps | grep -q "Up"; then
echo "Containers are up and running."
exit 0
fi
echo "Waiting for containers to start..."
sleep 5
done
echo "Containers did not start within the timeout period."
exit 1
- 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=${{ github.event.inputs.image_version }}
# 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
Expand Down
2 changes: 1 addition & 1 deletion marketplace-build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ services:
- mongodb

volumes:
mongodata:
mongodata:
3 changes: 2 additions & 1 deletion marketplace-build/release/sprint-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ services:
service:
image: ghcr.io/axonivy-market/marketplace-service:sprint
restart: always
volumes:
- /home/axonivy/marketplace/data/market-installations.json:/home/data/market-installation.json
environment:
- MONGODB_HOST=${SERVICE_MONGODB_HOST}
- MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE}
- MONGODB_USERNAME=${SERVICE_MONGODB_USER}
- MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD}
- MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN}
- MARKETPLACE_INSTALLATION_URL=${MARKETPLACE_INSTALLATION_URL}
volumes:
mongodata:

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.web.bind.annotation.CrossOrigin;
import java.util.List;

import static com.axonivy.market.constants.RequestMappingConstants.PRODUCT_DETAILS;
Expand All @@ -40,7 +40,8 @@ public ResponseEntity<ProductDetailModel> findProductDetailsByVersion(@PathVaria
return new ResponseEntity<>(detailModelAssembler.toModel(productDetail, tag), HttpStatus.OK);
}

@Operation(summary = "increase installation count by 1", description = "increase installation count by 1")
@Operation(summary = "increase installation count by 1", description = "update installation count when click download product files by users")
@CrossOrigin(originPatterns = "*")
@PutMapping("/installationcount/{key}")
public ResponseEntity<Integer> syncInstallationCount(@PathVariable("key") String key) {
int result = productService.updateInstallationCountForProduct(key);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.axonivy.market.github.service.impl;

import static org.apache.commons.lang3.StringUtils.EMPTY;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.kohsuke.github.GHContent;
import org.kohsuke.github.GHOrganization;
Expand Down Expand Up @@ -49,7 +52,9 @@ public GitHubServiceImpl(RestTemplateBuilder restTemplateBuilder, UserRepository

@Override
public GitHub getGitHub() throws IOException {
return new GitHubBuilder().withOAuthToken(gitHubProperty.getToken().trim().strip()).build();
return new GitHubBuilder()
.withOAuthToken(Optional.ofNullable(gitHubProperty).map(GitHubProperty::getToken).orElse(EMPTY).trim())
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ server.forward-headers-strategy=framework
springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.path=/swagger-ui.html
market.cors.allowed.origin.maxAge=3600
synchronized.installation.counts.path=${MARKETPLACE_INSTALLATION_URL}
synchronized.installation.counts.path=/home/data/market-installation.json
market.github.token=${MARKET_GITHUB_TOKEN}
logging.level.org.springframework.security=DEBUG
market.github.token=${MARKET_GITHUB_TOKEN}
logging.level.org.springframework.security=DEBUG
spring.security.oauth2.client.registration.github.client-id=<replace-with-your-client-id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.verify;

@SpringBootTest(properties = { "MARKETPLACE_INSTALLATION_URL=D:/marketplace-installation.json" })
@SpringBootTest(properties = { "MONGODB_USERNAME=user", "MONGODB_PASSWORD=password", "MONGODB_HOST=mongoHost",
"MONGODB_DATABASE=product" })
class SchedulingTasksTest {

@SpyBean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ <h4 class="analysis-title text-primary text-capitalize mb-0">
</div>
</div>
<div class="d-flex flex-column col-12 col-lg-4">
<div
class="d-flex justify-content-center justify-content-lg-end mt-md-3 m-sm-0">
<div class="d-flex text-lg-end mt-md-3 m-sm-0">
<app-product-version-action
class="w-100 d-flex d-lg-block"
(installationCount)="receiveInstallationCountData($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ <h4 class="sort-container__label text-primary d-none d-lg-flex w-auto">
<div class="input-group mb-5">
<div class="input-group-prepend">
<span
class="input-group-text text-primary bg-secondary h-100 border-0 rounded-start-4 rounded-end-0">
class="input-group-text text-primary bg-secondary h-100 border-0 rounded-end-0">
<i class="bi bi-search"></i>
</span>
</div>
<input
[(ngModel)]="searchText"
(ngModelChange)="onSearchChanged($event)"
type="text"
class="form-control input__search bg-secondary border-0 rounded-end-4 rounded-start-0 search-input"
class="form-control input__search bg-secondary border-0 rounded-start-0 ps-0 search-input"
[placeholder]="translateService.get('common.search.placeholder') | async"
[ariaLabel]="translateService.get('common.search.placeholder') | async"
aria-describedby="search"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
$rowHeight: 37px;

.input-group-text {
border-radius: 10px;
padding: 0 15px;
}

.form-control {
border-radius: 10px;
}

.filter-container {
height: $rowHeight;
}
Expand Down
13 changes: 11 additions & 2 deletions marketplace-ui/src/app/modules/product/product.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ <h4 class="text-secondary">
}
</div>
} @else {
<div class="h1 product-container text-center align-items-center">
{{ 'common.nothingFound' | translate }}
<div
class="d-flex flex-column align-items-center justify-content-center w-100">
<div class="not-found-result w-100">
<img
src="/assets/images/misc/search-off.svg"
alt="Search not found"
class="no-result-image mx-auto d-block" />
<div
class="h5 text-center not-found-text"
[innerHTML]="'common.nothingFound' | translate"></div>
</div>
</div>
}

Expand Down
24 changes: 23 additions & 1 deletion marketplace-ui/src/app/modules/product/product.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
min-height: 6em;
}

.mt-8{
.mt-8 {
margin-top: 8rem;
}

.not-found-result {
max-width: 670px;
margin-bottom: 4rem;

.not-found-text {
line-height: 140%;
color: var(--text-no-rating-color);
margin: 20px 0 0 0;
}
}

@media (max-width: 430px) {
.no-result-image {
width: 60px;
height: 60px;
}

.not-found-text {
font-size: 0.875rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@

.language-item.inactive {
color: #757575;
font-weight: 400;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<ngb-rating
class="justify-content-between rating-stars"
[rate]="rate"
(rateChange)="onRateChange($event)"
[max]="5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,25 @@
}

.adding-feedback-star {
font-size: 2.5rem;
font-size: 2.25rem;
color: #dfdfdf;
margin-right: 15px;
margin-right: 0px;
.filled {
color: #FFCB13;
color: #ffcb13;
}
}

.rating-stars {
width: 40%;
}

@media (max-width: 767px) {
.medium-star {
font-size: 16px;
margin-right: 8px;
}

.adding-feedback-star {
margin-right: 39px;
.rating-stars {
width: 100%;
}
}

@media (max-width: 400px) {
.adding-feedback-star {
margin-right: clamp(27px, 6vw, 39px);
}
}
2 changes: 1 addition & 1 deletion marketplace-ui/src/assets/i18n/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ common:
lowest: Niedrigste
search:
placeholder: Suche
nothingFound: Nichts gefunden
nothingFound: Leider hat deine Suche keinen Treffer ergeben.<br /> Ändere deinen Suchbegriff oder stöbere in unseren Kategorien nach ähnlichen Themen.
header:
download: Download
footer:
Expand Down
4 changes: 2 additions & 2 deletions marketplace-ui/src/assets/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ common:
lowest: Lowest
search:
placeholder: Search a keyword
nothingFound: Nothing found
nothingFound: Your search did not yield any results.<br /> Please modify your search terms or browse our categories for related content.
header:
download: Download
footer:
Expand Down Expand Up @@ -88,7 +88,7 @@ common:
label: Choose artifact
feedback:
label: Feedback
successMessage: Your feedback has been successfully submitted!
successMessage: Your feedback has been successfully submitted!
thankMessage: Thank you for your contribution
addFeedbackTitle: Give your feedback!
addFeedbackDescription: By giving your feedback you are enabling us to constantly improve our products and always deliver the best quality to both you and your team.
Expand Down
11 changes: 11 additions & 0 deletions marketplace-ui/src/assets/images/misc/search-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions marketplace-ui/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const environment = {
githubClientId: 'Ov23liVMliBxBqdQ7FnG',
githubAuthCallbackUrl: '/auth/github/callback',
dayInMiliseconds: 86400000

};

0 comments on commit 20d5099

Please sign in to comment.