-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
246 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
[1]: marketplace-ui/README.md | ||
[2]: marketplace-service/README.md | ||
[3]: marketplace-build/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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= |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.