Skip to content
Snippets Groups Projects
README.md 2.57 KiB
Newer Older
# Ipfs Document Manager Service
Steffen Schulze's avatar
Steffen Schulze committed

The Ipfs Document Manager Service is a RESTful API service designed to manage documents in IPFS. It provides functionalities for creating, retrieving, and deleting documents.
Steffen Schulze's avatar
Steffen Schulze committed

## API Documentation
The API documentation is written in Swagger [Swagger Web UI](docs/swagger.json)
Steffen Schulze's avatar
Steffen Schulze committed

It can be accessed in local docker-compose environment [swagger_ui](http://localhost:8000/swagger/index.html).
Steffen Schulze's avatar
Steffen Schulze committed

It is generated using [swagger generation tool](https://github.com/swaggo/gin-swagger)
Steffen Schulze's avatar
Steffen Schulze committed

In case of changes in api definitions, it should be updated. Please run:
```cmd
go install github.com/swaggo/swag/cmd/swag@latest
swag init --parseDependency
Steffen Schulze's avatar
Steffen Schulze committed
```
## Available Endpoints
Steffen Schulze's avatar
Steffen Schulze committed

- POST `/v1/tenants/tenant_space/api/ipfs/create`: Creates a new document in IPFS.
- GET `/v1/tenants/tenant_space/api/ipfs/:id`: Retrieves an existing document from IPFS by its CID.
- DELETE `/v1/tenants/tenant_space/api/ipfs/:id`: Deletes an existing document from IPFS by its CID.
Steffen Schulze's avatar
Steffen Schulze committed

## Dependency services
Steffen Schulze's avatar
Steffen Schulze committed

[docker-compose](./deployment/docker/docker-compose.yml)
Steffen Schulze's avatar
Steffen Schulze committed

- IPFS node - [Kubo](https://docs.ipfs.tech/install/command-line/)
Steffen Schulze's avatar
Steffen Schulze committed

## Running the Service
Steffen Schulze's avatar
Steffen Schulze committed

### In [Docker container](https://docs.docker.com/engine/install/) (recommended)
Steffen Schulze's avatar
Steffen Schulze committed

1. Setup 
Add following to file [.env](.env)
```
PROJECT_NAME=ipfs_doc_manager
IPFS_HOST=ipfs-node
IPFS_API_GATEWAY_URL=http://ipfs-node:8080/ipfs
IPFS_RPC_API_PORT=5001
IPFS_LOG_LEVEL=debug
IPFSMANAGER_SERVERMODE=debug
IPFSMANAGER_LISTEN_PORT=8000
```
2. Build and run service
Steffen Schulze's avatar
Steffen Schulze committed

If necessary, copy to terminal corresponding command from [Makefile](makefile)
Steffen Schulze's avatar
Steffen Schulze committed

```make docker-compose-run```
Steffen Schulze's avatar
Steffen Schulze committed

### Locally
Steffen Schulze's avatar
Steffen Schulze committed

1. Setup
Define environment variables in terminal
```
EXPORT IPFS_HOST=0.0.0.0
EXPORT IPFS_API_GATEWAY_URL=http://0.0.0.0:8080/ipfs
EXPORT IPFS_RPC_API_PORT=5001
EXPORT IPFS_LOG_LEVEL=debug
EXPORT IPFSMANAGER_SERVERMODE=debug
EXPORT IPFSMANAGER_LISTEN_PORT=8000
EXPORT VDR_TYPE=ipfs
```
Steffen Schulze's avatar
Steffen Schulze committed

2. Build plugin
Steffen Schulze's avatar
Steffen Schulze committed

```cmd
mkdir etc
cd etc
git clone https://gitlab.eclipse.org/eclipse/xfsc/libraries/ssi/verifiable-data-registry/plugins/vdr-ipfs.git .
go mod download
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -mod=mod -buildmode=plugin -o plugins/ipfs
```
3. Build and run service
Steffen Schulze's avatar
Steffen Schulze committed

```cmd
go mod download
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o /microservice
./microservice
```
Steffen Schulze's avatar
Steffen Schulze committed

## Deploying the service
Steffen Schulze's avatar
Steffen Schulze committed

Deployment is managed using [Helm](https://helm.sh)
Steffen Schulze's avatar
Steffen Schulze committed

Charts are defined in [./deployment/helm](deployment/helm)
Steffen Schulze's avatar
Steffen Schulze committed

From root
Steffen Schulze's avatar
Steffen Schulze committed

```cmd
cd deployment
helm install ipfs-document-manager-service ./helm -n <your namespace | default> --kubeconfig <path to kubeconfig of necessary cluster>
```