Skip to content

Commit

Permalink
docs: add docker compose workflow (#97)
Browse files Browse the repository at this point in the history
* docs: add docker compose workflow

* docs: update readme

* chore: fix broken links
  • Loading branch information
ashleythedeveloper authored Aug 14, 2024
1 parent b8725e8 commit 06574a1
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 1,841 deletions.
130 changes: 39 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,117 +1,65 @@
# tests-untp

UNTP mock implementation is a mock app that presents how the decentralized app works. There are three main packages in this repository: components, core, and services. The components package contains the UI components, the core package plays the role of the render page by using the components package and interacting with the services package and the services package contains the business logic.
The UNTP Test Suite is a comprehensive set of tools designed to ensure conformance to the UN Transparency Protocol (UNTP). This repository contains the following key components:

1. Mock Apps: Demonstrating how decentralized applications work within the UNTP ecosystem.
2. Test Suites: Covering three tiers of testing - technical interoperability, semantic interoperability, and graph validation.
3. Documentation Site: Providing detailed information on setup, configuration, and usage.

The Mock Apps are structured into three main packages:
- Components: Contains the UI components.
- Core: Handles rendering and interaction between components and services.
- Services: Contains the business logic.

These tools allow implementers to model value chains, test UNTP functionality in real-world scenarios, and ensure their implementations align with the UNTP specification across various aspects of interoperability and validation.

## Prerequisites

- [Node.js](https://nodejs.org/en/) version 20.12.2
- [yarn](https://yarnpkg.com/) version 1.22.22
- [Docker](https://www.docker.com/get-started) and [Docker Compose](https://docs.docker.com/compose/install/) (for running services)

### Install dependencies
## Setup

```bash
yarn install
```

### Copy the .app-config.example file to .env for the demo explorer
To set up and run the mock app:

```bash
cp packages/mock-app/src/constants/app-config.example.json packages/mock-app/src/constants/app-config.json
```
1. Install dependencies:
```bash
yarn install
```

### Update the app-config.json file with the correct values, for example:

```json
{
"services": [
{
"name": "processDPP", // Service name
"parameters": [
{
"vckit": {
"vckitAPIUrl": "https://vckit.example.com", // URL of the VC API
"issuer": "did:web:vckit.example.com" // Issuer DID
},
"dpp": {
"context": ["https://dpp.example.com/dppld.json"], // DPP context, please refer to the DPP documentation, if it is not provided, the error message will be displayed
"renderTemplate": [{ "template": "<p>Render dpp template</p>", "@type": "WebRenderingTemplate2022" }],
"type": ["DigitalProductPassport"],
"dlrLinkTitle": "Livestock Passport",
"dlrIdentificationKeyType": "gtin",
"dlrVerificationPage": "http://dlr.example.com/verify" // DLR verification page
},

"dlr": {
"dlrAPIUrl": "http://dlr.example.com", // DLR API URL
"dlrAPIKey": "5555555555555"
},
"storage": {
"url": "https://storage.example.com", // Storage API URL
"params": {
"resultPath": "" // Path to access the credential or the link to the credential within the API response
},
// Optional parameters
"options": {
"method": "POST",
"headers": {
"Content-Type": "application/json"
}
}
}
}
]
}
]
}
```
2. Build the package:
```bash
yarn build
```

### Build the package
3. Start the project:
```bash
yarn start
```

```bash
yarn build
```
## Docker Compose Configuration

### Start the project
We provide a Docker Compose configuration to easily set up the required services (Verifiable Credential Service, Storage Service, a database for the VC service) and the documentation site. To start these services:

```bash
yarn start
```

## Documentation

```
$ cd documentation
docker-compose up -d
```

### Installation
This will start pre-configured instances of the necessary services and the documentation site. The `app-config.json` mock app config file is pre-configured to work with these Docker services.

```
$ yarn
```
## Documentation

### Local Development
For detailed information about the configuration, services, and how to use the mock app, please refer to the documentation site.

```
$ yarn start
```

## Docker
The documentation site is available at [`http://localhost:3002`](http://localhost:3002) after starting the services with Docker Compose.

- Dockerfile
Build image
If you need to run the documentation site manually:

```bash
docker build --build-arg CONFIG_FILE=./app-config.json -t mock-app:latest .
```

Run image

```bash
docker run -p 3000:80 mock-app:latest
cd documentation
yarn install
yarn start
```

- Docker compose

```bash
docker-compose up -d
```
Please consult the documentation for comprehensive instructions on setting up and using the mock app, regardless of whether you're using Docker Compose or setting up services manually.
1,776 changes: 70 additions & 1,706 deletions app-config.json

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions documentation/docs/mock-apps/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,36 @@ import Disclaimer from '../.././\_disclaimer.mdx';

The Mock Apps config file is used to define the system level config, the apps within the mock app system, the apps functions and the connection to the external services.

## Example Configuration

The `app-config.json` file in the root directory contains an example configuration for a value chain called "Truffle". This configuration is pre-set to work with the services created by the Docker Compose setup.

### Pre-configured Services

Most of the service endpoints in the example configuration are already set to use the Docker Compose services. The only endpoint you might need to change is the Identity Resolver Service (IDR) endpoint.

- By default, the IDR service endpoint is set to `http://localhost:8080`.
- If you've changed this endpoint, update the `dlr` values in the config file accordingly.

### Updating the Issuer

You will need to update the `issuer` property value (did:web) inside the `vckit` object. This should be set to the identifier you created using the Verifiable Credential Service.

For example:

```json
"vckit": {
"issuer": "did:web:your-created-identifier"
}
```

## Mock App Configuration File Lifecycle

The Mock App system can be tailored to model different value chains using a configuration file. This section explains the lifecycle of this configuration file and how to apply changes.

### Location of the Configuration File

The configuration file is named `app-config.json` and is located in the root directory of the cloned Mock App repository. To navigate to this directory, use the following command:
The configuration file is named `app-config.json` and is located in the root directory of the cloned repository. To navigate to this directory, use the following command:

```bash
cd tests-untp
Expand All @@ -41,4 +64,5 @@ yarn start
### Important Notes

- Changes to the configuration file will not be reflected in the mock apps until you restart the Mock App system.
- Always ensure you save the `app-config.json` file before restarting the Mock App system.
- Always ensure you save the `app-config.json` file before restarting the Mock App system.
- If you're using the Docker Compose setup, most service endpoints are pre-configured. You only need to update the `issuer` property in the `vckit` object and potentially the IDR service endpoint if you've changed it from the default.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Key functions of the Identity Resolver Service include:
- Enabling downstream value chain actors to discover more information about products they have purchased or are considering purchasing.
- Facilitating the connection between unique identifiers and more information about the product (e.g. [Digital Product Passports](https://uncefact.github.io/spec-untp/docs/specification/DigitalProductPassport), [Traceability Events](https://uncefact.github.io/spec-untp/docs/specification/DigitalTraceabilityEvents) and [Conformity Credentials](https://uncefact.github.io/spec-untp/docs/specification/ConformityCredential)).
<!-- TODO: Update to UN IDR service once built -->
For the Mock Apps, we currently recommend and will be using the [GS1 Digital Link Resolver](https://github.com/gs1/GS1_DigitalLink_Resolver_CE).
For the Mock Apps, we currently recommend and will be using the [GS1 Digital Link Resolver v2.6](https://github.com/gs1/GS1_DigitalLink_Resolver_CE/tree/v2.6).

### Identity Resolver Service Documentation

Please go through the GS1 Digital Link Resolve documentation available [here](https://github.com/gs1/GS1_DigitalLink_Resolver_CE#fast-start) to understand how to set up and use the Identity Resolver Service.
Please go through the GS1 Digital Link Resolve documentation available [here](https://github.com/gs1/GS1_DigitalLink_Resolver_CE/tree/v2.6#fast-start) to understand how to set up and use the Identity Resolver Service.

### Requirements

Expand Down
52 changes: 52 additions & 0 deletions documentation/docs/mock-apps/dependent-services/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,55 @@ Ensure all services are configured and running before proceeding with the Mock A
- [Verifiable Credential Service](./verifiable-credential-service)
- [Storage Service](./storage-service)
- [Identity Resolver Service](./identity-resolution-service)

## Docker Compose Setup

We have created a Docker Compose file in the root directory to simplify the setup process. This Docker Compose file contains the necessary configurations to start pre-configured instances of the Verifiable Credential Service, Storage Service, a database for the VC service, and the documentation site.

To use the Docker Compose setup:

1. Ensure you have [Docker](https://www.docker.com/products/docker-desktop/) and [Docker Compose](https://docs.docker.com/compose/) installed on your system.

2. Navigate to the root directory of the project where the Docker Compose file is located:
```
cd tests-untp
```

3. Run the following command to start the services:
```
docker-compose up -d
```

This command will start all the services in detached mode.

4. To stop the services, use:

```
docker-compose down
```

Using this Docker Compose setup allows for a quick and easy deployment of the required services, ensuring they are properly configured and ready for use with the Mock App system.

## Service Endpoints

Once the services are up and running, you can access them at the following endpoints:

- [Documentation Site](http://localhost:3002)
- [Verifiable Credential Service](http://localhost:3332)
- [Storage Service](http://localhost:3334)

## Creating an Identifier (did:web)

After setting up the services, you need to create an identifier (did:web) within the Verifiable Credential Service. This step is crucial for the proper functioning of the system.

To learn how to create an identifier, please refer to the [Verifiable Credential Service](./verifiable-credential-service) page.

## Additional Information

For detailed information about each service, please refer to their respective sections:

- [Verifiable Credential Service](./verifiable-credential-service)
- [Storage Service](./storage-service)
- [Identity Resolver Service](./identity-resolution-service)

Note that the Identity Resolver Service is not currently included in the Docker Compose setup. Please refer to the [Identity Resolver Service](./identity-resolution-service) page for more details on its setup and configuration.
36 changes: 11 additions & 25 deletions documentation/docs/mock-apps/dependent-services/storage-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,30 @@ It offers the following capabilities:

For the Mock Apps, we recommend and will be using the UN's reference implementation located within the [Identity Resolver Service repository](https://github.com/uncefact/project-identity-resolver).

### Storage Service Documentation
### Setup Options

Please go through the Storage Service documentation available [here](https://github.com/uncefact/project-identity-resolver#project-identity-resolver) to understand how to set up and use the Storage Service.
#### Option 1: Using Docker Compose (Recommended)

### Examples
<!-- TODO: Remove once storage service is documented -->
#### Store the credential
If you've chosen to use the Docker Compose setup as described in the [Dependent Services](/docs/mock-apps/dependent-services/) section, the Storage Service is already configured and ready to use. You don't need to perform any additional setup steps.

```bash
curl -X POST \
http://localhost:3001/upload \
-H 'Content-Type: application/json' \
-d '{
"filename": "conformity-credentials/steel-mill-1-emissions.json",
"data": {
"Your credential data here"
}
}'
```
You would replace `"Your credential data here"` with the actual credential data you want to store (just the verifiable credential).
#### Option 2: Manual Setup

#### Fetch the credential
If you're setting up your own instance of the Storage Service, please follow these steps:

```bash
curl -X GET \
http://localhost:3001/conformity-credentials/steel-mill-1-emissions.json \
-H 'Accept: application/json'
```
### Storage Service Documentation

Please go through the Storage Service documentation available [here](https://github.com/uncefact/project-identity-resolver#project-identity-resolver) to understand how to set up and use the Storage Service.

### Requirements

To use the Storage Service with the mock apps, you will need:

1. The Storage Service API running.
2. The address of the Storage Service (e.g.http://localhost:3001/upload)
2. The address of the Storage Service (e.g., http://localhost:3334/v1/documents)
3. The API key of the Storage Service API (if applicable)

Make sure you have the Storage Service API set up and running, and note its address and API key (if applicable) before proceeding with the mock app configuration.
If you're using the Docker Compose setup, these requirements are already met, and the Storage Service is available at http://localhost:3334.

If you're setting up your own instance, make sure you have the Storage Service API set up and running, and note its address and API key (if applicable) before proceeding with the mock app configuration.

In the next section, we will explore the Identity Resolver Service and its role in the UNTP ecosystem.
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,37 @@ To learn more about why UNTP leverages verifiable credentials, refer to the [Ver

For the Mock Apps, we recommend and will be using the UN's Verifiable Credential reference implementation called [VCKit](https://github.com/uncefact/project-vckit).

### Setup Options

#### Option 1: Using Docker Compose (Recommended)

If you've chosen to use the Docker Compose setup as described in the [Dependent Services](/docs/mock-apps/dependent-services/) section, most of the configuration is already done for you. In this case, you only need to:

1. Create an identifier (did:web) within the Verifiable Credential Service.
2. Record this identifier for use in the mock app configuration.

#### Option 2: Manual Setup

If you're setting up your own instance of the Verifiable Credential Service, please follow these steps:

### VCKit Documentation

Please go through the VCKit documentation available [here](https://github.com/uncefact/project-vckit#start-the-documentation-page) to understand how to set up and use VCKit.

### Requirements

To use the Verifiable Credential Service with the mock apps, you will need:
<!-- TODO: VCkit API key missing from the app config implementation -->
1. The VCKit API running.
2. The VCKit Explorer app running.
3. An [Identifier](https://uncefact.github.io/spec-untp/docs/specification/VerifiableCredentials/#did-methods) (did:web) created and recorded for each actor in the value chain you would like to model.
4. The address of the VCKit API (e.g. http://localhost:3332/v2)
5. The API key of the VCkit API (if applicable)

2. An [Identifier](https://uncefact.github.io/spec-untp/docs/specification/VerifiableCredentials/#did-methods) (did:web) created and recorded for each actor in the value chain you would like to model.
3. The address of the VCKit API (e.g. http://localhost:3332/v2)
4. The API key of the VCkit API (if applicable)

Make sure you have these components set up and running, and note the API address, API key and Identifiers before proceeding with the mock app configuration.

### Creating an Identifier (did:web)

Regardless of which setup option you chose, you'll need to create an identifier (did:web) within the Verifiable Credential Service. This identifier is crucial for the proper functioning of the system.

To create an identifier, you'll need to use the VCKit API. Refer to the [VCKit documentation](https://github.com/uncefact/project-vckit#start-the-documentation-page) for specific instructions on how to create a did:web identifier using their API endpoints.

In the next section, we will discuss the Storage Service and its role in the UNTP ecosystem.
9 changes: 1 addition & 8 deletions documentation/docs/mock-apps/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ Once you have met the prerequisites, follow these steps to install the dependenc
yarn install
```

3. Copy the example configuration file:
```
cp packages/mock-app/src/constants/app-config.example.json packages/mock-app/src/constants/app-config.json
```

This command copies the example configuration file `app-config.example.json` to create the actual configuration file `app-config.json` that will be used by the mock apps.

After completing these steps, you will have all the necessary mock app dependencies installed and the configuration file ready for customisation.
After completing these steps, you will have all the necessary mock app dependencies installed.

In the next section, we will explore the required services and their documentation to help you understand their role in the mock apps ecosystem.
Loading

0 comments on commit 06574a1

Please sign in to comment.