All pages
Powered by GitBook
1 of 9

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Guides

Dockerization

Configuring a connector with Google Sheets

Watch this space for super exciting updates. Our bots are already hard at work using GPT-3 to create this page for you.

Flask

Configuring a connector with CSV

Overview

This tutorial will describe how to setup FarmStack connector for local csv files. Kindly follow the steps to install FarmStack requirements before proceeding with this setup.

Local CSV file

You can follow this process for any file, here we will be using a file called cities.csv present in Downloads directory in home folder.

Clone the FarmStack Github repository on your local machine and open it.

git clone https://github.com/digitalgreenorg/farmstack-open.git
cd farmstack-open

In the FarmStack repository, open example-provide-routes.yaml file in fs-config/usage-control-example/ directory.

code fs-configs/usage-control-example/example-provider-routes.xml

In the route sendData, replace sample_data1.csv with filename of your CSV file.

Next, open docker-compose-provider.yaml file in fs-config/usage-control-example/ directory.

Here comment out the lines which mount sample_data1.csv and sample_data2.csv to the docker container, and add the line to mount the cities.csv to the container, as shown here:

There is no limit on the number of CSV files that can be mounted on connector, follow the same instructions for more csv files.

Save the files and in the terminal window type the following command to run FarmStack setup:

After the setup is complete, in the browser window, open the installer frontend by typing .

Follow the steps to create your connectors, give a unique name to your connectors such as cities-provider and cities-consumer.

Start the connection by clicking Setup Connection Button.

When the connector setup is done click View transferred data link to see your data. Kindly wait a couple of minutes for the contract negotiation process of provider and consumer to complete before they can start sharing the data.

Watch this space for super exciting updates. Our bots are already hard at work to create this page for you.

This completes the tutorial for CSV file transfer through FarmStack Provider Connector. If you face any issue while setting up your own csv file kindly open a new issue in the github repository and our experts will guide you.

code fs-configs/usage-control-example/docker-compose-provider.yaml
python3 setup.py

Online CSV file

Next Steps

localhost:8000

NodeJS

Overview

This tutorial will describe how to convert your NodeJS application to docker application for compatibility with FarmStack connector.

Dockerization Process

Create a new file named Dockerfile in the application folder and open in your favorite text editor.

touch Dockerfile

Copy this code into the Dockerfile

First we are going to define the image we are going to use. Here we are using latest alpine image of node to keep the size of NodeJS application small. You can use any image available in the Node's Dockerhub.

FROM node:alpine

Next we will create a directory to copy all our application code inside the image.

# Create app directory
WORKDIR /app

Since we are using node image, node and npm are already installed in this image. We just need to copy our package.json and package-lock.json files.

Here, we copy package.json files before copying complete project. This is done to take advantage of Docker layers caching and only install dependencies if the files have changed. You can find more information about this .

Now we will copy your app's source code to docker image.

Our sample-nodejs app binds to port 8081 so we will map this port to docker daemon by using EXPOSE command. If your app uses any other port, kindly change it

In this last step, define the command to start your application. Our sample application starts withnpm start command. You can also use a shell script file here which executes to start your server.

This should be your final Dockerfile

You can find the final Dockerfile .

Create a .dockerignore file in the same directory as your Dockerfile. Add the following lines to the file:

.dockerignore file

Next Steps

here
here
Install a dockerized application with connector
# Copy package.json and package-lock.json files to image
COPY package*.json ./

RUN npm install
# Copy app's source code
COPY . .
EXPOSE 8081
ENTRYPOINT ["npm","start"]
Dockerfile
FROM node:alpine
# Create app directory
WORKDIR /app

# Copy package.json and package-lock.json files to image
ADD package*.json ./

RUN npm install

# Copy app's source code
COPY . .

EXPOSE 8081
ENTRYPOINT [ "npm", "start" ]
.dockerignore
node_modules
npm-debug.log
.npm

Django

Configuring a connector with JSON/Rest API

Watch this space for super exciting updates. Our bots are already hard at work using GPT-3 to create this page for you.

Install a dockerized application with connector

Overview

This tutorial will describe how to run the dockerized application with the connector. This tutorial does not contain information on dockerization of the app. Kindly dockerization tutorial according to your app.

You can find the sample-nodejs application used in this tutorial here.

Installing dockerized application with connector

Kindly follow the previous tutorial to locally setup and deploy FarmStack before proceeding with this next step, if not done already.

Installing Prerequisites

Clone the FarmStack repository and open in terminal, using following commands:

git clone https://github.com/digitalgreenorg/farmstack-open.git
cd farmstack-open

Open prepareConsumerApp.sh in scripts folder in your favorite editor.

Edit the following variable to according to your application:

You can also edit the parameters for the example configuration according to your requirements, but it is advised to leave these variables untouched, unless you know what you're doing.

In the terminal, execute the script from farmstack-open directory:

This script will create a docker image for your application and modify the required usage control parameters in the example-provider-routes.xml file.

In the terminal window type the following command to run FarmStack setup:

After the setup is complete, in the browser window, open the installer frontend by typing .

Follow the steps to create your connectors, give a unique name to your connectors such as cities-provider and cities-consumer.

Start the connection by clicking Setup Connection Button.

When the connector setup is done click View transferred data link to see your data. Kindly wait a couple of minutes for the contract negotiation process of provider and consumer to complete before they can start sharing the data.

This completes the tutorial for running the dockerized application with the consumer connector. If you face any issue while running your consumer app kindly open a new issue in the github repository and our experts will guide you.

localhost:8000
# Application parameters
# This should be a relative path to the config directory or an absolute path.
CONSUMER_APP_DIR=../../fs-consumer-apps/sample-nodejs
CONSUMER_APP_NAME='sample-nodejs' #change application name
CONSUMER_APP_PORT=8081 #Change port according to your application
SYSTEM_PORT=8081 # Port on the system you want to map to your application's port
# Config parameters
CONFIG_DIR='fs-configs/usage-control-example'
PROVIDER_CONFIG_FILE=example-provider-routes.xml
CONSUMER_DOCKER_COMPOSE=docker-compose-consumer.yaml
./scripts/prepareConsumerApp.sh
python3 setup.py