5. ソースコードからすべてをビルド

FogFlow は、ARM プロセッサと x86 プロセッサ (32ビットと64ビット) の両方の Linux でビルドおよびインストールできます。

5.1. 依存関係をインストール

  1. FogFlowをビルドするには、最初に次の依存関係をインストールします。

  2. インストールされているバージョンを確認します。

    go version   #output  go version go1.9 linux/amd64
    nodejs -v    #output    v6.10.2
    npm -v       #output  3.10.10
    
  3. 環境変数 GOPATH を設定します。

    注釈

    GOPATH は、go ベースのプロジェクトのワークスペースを定義します。go ワークスペース フォルダーには "src" フォルダーが必要であり、FogFlow コード リポジトリはこの "src" フォルダーに複製される必要があることに注意してください。たとえば、ホームフォルダが "/home/smartfog" であると仮定して、ワークスペースとして新しいフォルダ "go" を作成します。この場合、最初に "/home/smartfog/go" の下に "src" (正確にこの名前である必要があります) を作成してから、"/home/smartfog/go/src フォルダー内の FogFlow コード リポジトリをチェック アウトする必要があります。

    export GOPATH="/home/smartfog/go"
    
  4. コード リポジトリをチェック アウトします。

    cd /home/smartfog/go/src/
    git clone https://github.com/smartfog/fogflow.git
    
  5. 以下のようにソースコードからすべてのコンポーネントをビルドします。

5.2. IoT Discovery をビルド

  • ネイティブ実行可能プログラムをビルドします。

    # go the discovery folder
    cd /home/smartfog/go/src/fogflow/discovery
    # download its third-party library dependencies
    go get
    # build the source code
    go build
    
  • Docker イメージを作成します。

    # Simply ./build  can be run to perform the following commands
    
    # download its third-party library dependencies
    go get
    # build the source code and link all libraries statically
    CGO_ENABLED=0 go build -a
    # create the docker image; sudo might have to be used to run this command
    # if the docker user is not in the sudo group
    docker build -t "fogflow/discovery" .
    

5.3. IoT Broker をビルド

  • ネイティブ実行可能プログラムをビルドします。

    # go the broker folder
    cd /home/smartfog/go/src/fogflow/broker
    # download its third-party library dependencies
    go get
    # build the source code
    go build
    
  • Docker イメージを作成します。

    # simply ./build can be run to perform the following commands
    
    # download its third-party library dependencies
    go get
    # build the source code and link all libraries statically
    CGO_ENABLED=0 go build -a
    # create the docker image; sudo might have to be used to run this command
    # if the docker user is not in the sudo group
    docker build -t "fogflow/broker" .
    

5.4. Topology Master をビルド

  • ネイティブ実行可能プログラムをビルドします。

    # go the master folder
    cd /home/smartfog/go/src/fogflow/master
    # download its third-party library dependencies
    go get
    # build the source code
    go build
    
  • Docker イメージを作成します。

    # simply ./build can be run to perform the following commands
    
    # download its third-party library dependencies
    go get
    # build the source code and link all libraries statically
    CGO_ENABLED=0 go build -a
    # create the docker image; sudo might have to be used to run this command
    # if the docker user is not in the sudo group
    docker build -t "fogflow/master" .
    

5.5. Worker をビルド

  • ネイティブ実行可能プログラムをビルドします。

    # go the worker folder
    cd /home/smartfog/go/src/fogflow/worker
    # download its third-party library dependencies
    go get
    # build the source code
    go build
    
  • Docker イメージを作成します。

    # simply ./build  can be run to perform the following commands
    
    # download its third-party library dependencies
    go get
    # build the source code and link all libraries statically
    CGO_ENABLED=0 go build -a
    # create the docker image; sudo might have to be used to run this command
    # if the docker user is not in the sudo group
    docker build -t "fogflow/worker" .
    

5.6. Task Designer をビルド

  • サードパーティのライブラリの依存関係をインストールします。

    # go the designer folder
    cd /home/smartfog/go/src/fogflow/designer
    
    # install all required libraries
    npm install
    
  • Docker イメージを作成します。

    # simply ./build can be run to perform the following commands
    
    # install all required libraries
    npm install
    
    # create the docker image; sudo might have to be used to run this command
    # if the docker user is not in the sudo group
    docker build -t "fogflow/designer"  .