-
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.
MARP-224 Create dockerfiles for deployment of marketplace (#30)
Co-authored-by: Hoan Nguyen <[email protected]> Co-authored-by: ivyTeam <[email protected]> Co-authored-by: tutn <[email protected]> Co-authored-by: Dinh Nguyen <[email protected]>
- Loading branch information
1 parent
b92ce87
commit 2bb6a99
Showing
36 changed files
with
550 additions
and
155 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,40 @@ | ||
name: Docker Build | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- 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 }} | ||
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 | ||
- name: Refresh Docker images | ||
working-directory: ./marketplace-build | ||
run: | | ||
docker compose down | ||
docker compose up -d |
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,49 @@ | ||
name: Docker Release | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
workflow_dispatch: | ||
inputs: | ||
image_version: | ||
description: 'Marketplace Docker image version' | ||
required: true | ||
default: 'latest' | ||
|
||
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=${{ 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 | ||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Node | ||
**/node_modules |
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,8 @@ | ||
MONGODB_INITDB_ROOT_USERNAME= | ||
MONGODB_INITDB_ROOT_PASSWORD= | ||
SERVICE_MONGODB_HOST= | ||
SERVICE_MONGODB_USER= | ||
SERVICE_MONGODB_PASSWORD= | ||
SERVICE_MONGODB_DATABASE= | ||
MARKET_GITHUB_TOKEN= | ||
MARKETPLACE_INSTALLATION_URL= |
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 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,33 @@ | ||
# 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. | ||
|
||
* [Optional] Execute authentication test for the created user | ||
``` | ||
use admin | ||
db.auth('username','password') | ||
``` | ||
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 | ||
* Navigate to ``marketplace-build`` | ||
|
||
* 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. | ||
* 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. | ||
|
||
### 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 | ||
|
||
|
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,11 @@ | ||
# Use the base image for MongoDB | ||
FROM mongodb/mongodb-community-server:7.0.0-ubi8 | ||
|
||
# Copy the custom MongoDB configuration file into the container | ||
COPY mongod.conf /etc/mongod.conf | ||
|
||
# Expose MongoDB port | ||
EXPOSE 27017 | ||
|
||
# Define the default command to run MongoDB with the custom configuration | ||
CMD ["mongod", "--config", "/etc/mongod.conf"] |
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,18 @@ | ||
# This docker compose to init mongo for setup auth | ||
name: marketplace | ||
|
||
services: | ||
mongodb: | ||
container_name: marketplace-mongodb-non-authen | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
restart: always | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- mongodata:/data/db | ||
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro | ||
|
||
volumes: | ||
mongodata: |
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,12 @@ | ||
db = db.getSiblingDB('admin'); | ||
db.createUser( | ||
{ | ||
user: "username", | ||
pwd: "password", | ||
roles: [ | ||
{ role: "userAdminAnyDatabase", db: "admin" }, | ||
{ role: "readWriteAnyDatabase", db: "admin" }, | ||
{ role: 'root', db: 'admin' } | ||
] | ||
} | ||
) |
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,5 @@ | ||
security: | ||
authorization: enabled | ||
net: | ||
bindIpAll: true | ||
port: 27017 |
Oops, something went wrong.