Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/MARP-809-F…
Browse files Browse the repository at this point in the history
…irefox-not-scroll-to-top-after-go-to-product-detail

# Conflicts:
#	marketplace-ui/src/app/modules/product/product-detail/product-detail.component.ts
  • Loading branch information
tutn-axonivy committed Aug 16, 2024
2 parents e493cff + 76f49c2 commit 0c14e38
Show file tree
Hide file tree
Showing 54 changed files with 525 additions and 351 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:

steps:
- name: Bring down and remove containers and images
working-directory: ./marketplace-build
continue-on-error: true
working-directory: ./marketplace-build/dev
run: |
docker compose down --rmi all
Expand All @@ -46,13 +47,12 @@ jobs:

- name: Update environment variables for .env
env:
ENV_FILE: './marketplace-build/.env'
MONGODB_HOST: ${{ secrets.MONGODB_HOST }}
ENV_FILE: './marketplace-build/dev/.env'
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_MARKET_BRANCH: ${{ secrets.MARKET_GITHUB_MARKET_BRANCH }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MARKET_JWT_SECRET_KEY: ${{ secrets.MARKET_JWT_SECRET_KEY }}
MARKET_CORS_ALLOWED_ORIGIN: ${{ secrets.MARKET_CORS_ALLOWED_ORIGIN }}
Expand All @@ -67,10 +67,9 @@ jobs:
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_MARKET_BRANCH=.*$/MARKET_GITHUB_MARKET_BRANCH=$GH_MARKET_BRANCH/" $ENV_FILE
sed -i "s/^MARKET_GITHUB_TOKEN=.*$/MARKET_GITHUB_TOKEN=$GH_TOKEN/" $ENV_FILE
sed -i "s/^MARKET_GITHUB_OAUTH_APP_CLIENT_ID=.*$/MARKET_GITHUB_OAUTH_APP_CLIENT_ID=$OAUTH_APP_CLIENT_ID/" $ENV_FILE
sed -i "s/^MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=.*$/MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=$OAUTH_APP_CLIENT_SECRET/" $ENV_FILE
Expand All @@ -88,13 +87,13 @@ jobs:
sed -i 's/"version": "[^"]*"/"version": "${{ inputs.release_version }}"/' $PACKAGE_FILE
- name: Build and bring up containers without cache
working-directory: ./marketplace-build
working-directory: ./marketplace-build/dev
run: |
if [ -n "${{ inputs.release_version }}" ]; then
BUILD_VERSION="${{ inputs.release_version }}"
else
BUILD_VERSION=$(xml sel -t -v "//_:project/_:version" ../marketplace-service/pom.xml)
BUILD_VERSION=$(xml sel -t -v "//_:project/_:version" ../../marketplace-service/pom.xml)
fi
docker compose build --no-cache --build-arg BUILD_ENV=${{ inputs.build_env }} --build-arg BUILD_VERSION=$BUILD_VERSION
docker compose build --build-arg BUILD_ENV=${{ inputs.build_env }} --build-arg BUILD_VERSION=$BUILD_VERSION
docker compose up --force-recreate -d
8 changes: 4 additions & 4 deletions marketplace-build/.env
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
MONGODB_INITDB_ROOT_USERNAME=
MONGODB_INITDB_ROOT_PASSWORD=
SERVICE_MONGODB_HOST=
SERVICE_MONGODB_HOST=mongodb
SERVICE_MONGODB_USER=
SERVICE_MONGODB_PASSWORD=
SERVICE_MONGODB_DATABASE=
SERVICE_MONGODB_DATABASE=marketplace
MARKET_GITHUB_MARKET_BRANCH=
MARKET_GITHUB_TOKEN=
MARKETPLACE_INSTALLATION_URL=
MARKET_GITHUB_OAUTH_APP_CLIENT_ID=
MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=
MARKET_JWT_SECRET_KEY=
MARKET_CORS_ALLOWED_ORIGIN=
MARKET_CORS_ALLOWED_ORIGIN=*
23 changes: 0 additions & 23 deletions marketplace-build/Marketplace Tomcat v10.1 Server.launch

This file was deleted.

10 changes: 9 additions & 1 deletion marketplace-build/README.md
Original file line number Diff line number Diff line change
@@ -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 -d`` to start MongoDB with non-auth mode and create a root admin user.
* Navigate to ``marketplace-build/config/mongodb`` and execute the ``docker-compose -f non-authen-docker-compose.yml up -d`` to start MongoDB with non-auth mode and create a root admin user.

* [Optional] Execute authentication test for the created user
```
Expand All @@ -13,10 +13,18 @@ This command should return the ``OK`` code
* Down the non-authen instance to start the main docker compose file by run ``docker-compose down``

### Docker build for DEV environment
#### Start from scratch:
* Navigate to ``marketplace-build``

* Run ``docker-compose up -d --build`` to start a Marketplace DEV at the local

#### If you already have MongoDB on your local machine with public port `27017`
* Navigate to ``marketplace-build/dev``

* Run ``docker-compose up -d --build`` to start a Marketplace DEV at the local

> In case you want to set up the MongoDB as a standalone compose. Please run `docker-compose -f authen-docker-compose.yml up -d` in ``marketplace-build/config/mongodb``
### 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.
Expand Down
19 changes: 19 additions & 0 deletions marketplace-build/config/mongodb/authen-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: marketplace-db

services:
mongodb:
container_name: mongodb
build:
dockerfile: Dockerfile
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
- ./mongod.conf:/etc/mongod.conf

volumes:
mongodata:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This docker-compose to init MongoDB as free access and create a volume as name + mongodata
# Then insert the admin user as defined at mogo-init.js
# Change the name to other if you want to create more volumes. e.g: marketplace-dev
name: marketplace
name: marketplace-db

services:
mongodb:
Expand Down
12 changes: 12 additions & 0 deletions marketplace-build/dev/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MONGODB_INITDB_ROOT_USERNAME=octopus
MONGODB_INITDB_ROOT_PASSWORD=
SERVICE_MONGODB_HOST=10.193.8.78
SERVICE_MONGODB_USER=octopus
SERVICE_MONGODB_PASSWORD=
SERVICE_MONGODB_DATABASE=marketplace-dev
MARKET_GITHUB_MARKET_BRANCH=
MARKET_GITHUB_TOKEN=
MARKET_GITHUB_OAUTH_APP_CLIENT_ID=
MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=
MARKET_JWT_SECRET_KEY=
MARKET_CORS_ALLOWED_ORIGIN=*
43 changes: 43 additions & 0 deletions marketplace-build/dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: marketplace

services:
ui:
container_name: marketplace-ui
build:
context: ../../marketplace-ui
additional_contexts:
assets: ../../marketplace-build/
dockerfile: Dockerfile
args:
- BUILD_ENV=${BUILD_ENV}
restart: always
volumes:
- ../../marketplace-build/config/nginx/nginx.conf:/etc/nginx/nginx.conf
ports:
- "4200:80"
depends_on:
- service

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}
- MONGODB_USERNAME=${SERVICE_MONGODB_USER}
- MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD}
- MARKET_GITHUB_MARKET_BRANCH=${MARKET_GITHUB_MARKET_BRANCH}
- MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN}
- MARKET_GITHUB_OAUTH_APP_CLIENT_ID=${MARKET_GITHUB_OAUTH_APP_CLIENT_ID}
- MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=${MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET}
- MARKET_JWT_SECRET_KEY=${MARKET_JWT_SECRET_KEY}
- MARKET_CORS_ALLOWED_ORIGIN=${MARKET_CORS_ALLOWED_ORIGIN}
build:
context: ../../marketplace-service
dockerfile: Dockerfile
args:
- BUILD_VERSION=${BUILD_VERSION}
ports:
- "8080:8080"
1 change: 1 addition & 0 deletions marketplace-build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ services:
- MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE}
- MONGODB_USERNAME=${SERVICE_MONGODB_USER}
- MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD}
- MARKET_GITHUB_MARKET_BRANCH=${MARKET_GITHUB_MARKET_BRANCH}
- MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN}
- MARKET_GITHUB_OAUTH_APP_CLIENT_ID=${MARKET_GITHUB_OAUTH_APP_CLIENT_ID}
- MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=${MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET}
Expand Down
6 changes: 3 additions & 3 deletions marketplace-build/release/.env
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
RELEASE_VERSION=sprint
MONGODB_INITDB_ROOT_USERNAME=octopus
MONGODB_INITDB_ROOT_PASSWORD=
SERVICE_MONGODB_HOST=mongodb
SERVICE_MONGODB_HOST=localhost
SERVICE_MONGODB_USER=octopus
SERVICE_MONGODB_PASSWORD=
SERVICE_MONGODB_DATABASE=
SERVICE_MONGODB_DATABASE=marketplace
MARKET_GITHUB_MARKET_BRANCH=master
MARKET_GITHUB_TOKEN=
MARKETPLACE_INSTALLATION_URL=
MARKET_GITHUB_OAUTH_APP_CLIENT_ID=
MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=
MARKET_JWT_SECRET_KEY=
Expand Down
5 changes: 3 additions & 2 deletions marketplace-build/release/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ services:
context: ../config/mongodb
dockerfile: Dockerfile
restart: always
ports:
- "27017:27017"
expose:
- 27017
environment:
MONGODB_INITDB_ROOT_USERNAME: ${MONGODB_INITDB_ROOT_USERNAME}
MONGODB_INITDB_ROOT_PASSWORD: ${MONGODB_INITDB_ROOT_PASSWORD}
Expand All @@ -33,6 +33,7 @@ services:
- MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE}
- MONGODB_USERNAME=${SERVICE_MONGODB_USER}
- MONGODB_PASSWORD=${SERVICE_MONGODB_PASSWORD}
- MARKET_GITHUB_MARKET_BRANCH=${MARKET_GITHUB_MARKET_BRANCH}
- MARKET_GITHUB_TOKEN=${MARKET_GITHUB_TOKEN}
- MARKET_GITHUB_OAUTH_APP_CLIENT_ID=${MARKET_GITHUB_OAUTH_APP_CLIENT_ID}
- MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET=${MARKET_GITHUB_OAUTH_APP_CLIENT_SECRET}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class GitHubConstants {
public static final String AXONIVY_MARKET_ORGANIZATION_NAME = "axonivy-market";
public static final String AXONIVY_MARKETPLACE_REPO_NAME = "market";
public static final String AXONIVY_MARKETPLACE_PATH = "market";
public static final String DEFAULT_BRANCH = "feature/MARP-463-Multilingualism-for-Website";
public static final String PRODUCT_JSON_FILE_PATH_FORMAT = "%s/product.json";
public static final String GITHUB_PROVIDER_NAME = "GitHub";
public static final String GITHUB_GET_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.kohsuke.github.GHOrganization;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GHTag;

import com.axonivy.market.entity.User;
import com.axonivy.market.exceptions.model.MissingHeaderException;
Expand All @@ -23,6 +24,8 @@ public interface GitHubService {

GHRepository getRepository(String repositoryPath) throws IOException;

List<GHTag> getRepositoryTags(String repositoryPath) throws IOException;

List<GHContent> getDirectoryContent(GHRepository ghRepository, String path, String ref) throws IOException;

GHContent getGHContent(GHRepository ghRepository, String path, String ref) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.kohsuke.github.GHContent;
import org.kohsuke.github.GHOrganization;
import org.kohsuke.github.GHRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
Expand All @@ -32,6 +33,8 @@ public class GHAxonIvyMarketRepoServiceImpl implements GHAxonIvyMarketRepoServic
private GHRepository repository;

private final GitHubService gitHubService;
@Value("${market.github.market.branch}")
private String marketRepoBranch;

public GHAxonIvyMarketRepoServiceImpl(GitHubService gitHubService) {
this.gitHubService = gitHubService;
Expand All @@ -42,7 +45,7 @@ public Map<String, List<GHContent>> fetchAllMarketItems() {
Map<String, List<GHContent>> ghContentMap = new HashMap<>();
try {
List<GHContent> directoryContent = gitHubService.getDirectoryContent(getRepository(),
GitHubConstants.AXONIVY_MARKETPLACE_PATH, GitHubConstants.DEFAULT_BRANCH);
GitHubConstants.AXONIVY_MARKETPLACE_PATH, marketRepoBranch);
for (var content : directoryContent) {
extractFileInDirectoryContent(content, ghContentMap);
}
Expand Down Expand Up @@ -82,7 +85,7 @@ public GHCommit getLastCommit(long lastCommitTime) {
}

private GHCommitQueryBuilder createQueryCommitsBuilder(long lastCommitTime) {
return getRepository().queryCommits().since(lastCommitTime).from(GitHubConstants.DEFAULT_BRANCH);
return getRepository().queryCommits().since(lastCommitTime).from(marketRepoBranch);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;
import org.kohsuke.github.GHTag;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
Expand Down Expand Up @@ -77,6 +78,11 @@ public GHRepository getRepository(String repositoryPath) throws IOException {
return getGitHub().getRepository(repositoryPath);
}

@Override
public List<GHTag> getRepositoryTags(String repositoryPath) throws IOException {
return getRepository(repositoryPath).listTags().toList();
}

@Override
public GHContent getGHContent(GHRepository ghRepository, String path, String ref) throws IOException {
Assert.notNull(ghRepository, "Repository must not be null");
Expand Down Expand Up @@ -173,4 +179,4 @@ public List<Map<String, Object>> getUserOrganizations(String accessToken) throws
exception.getMessage()));
}
}
}
}
Loading

0 comments on commit 0c14e38

Please sign in to comment.