Skip to content

How to customize "module.json" file

Wei Shen edited this page Dec 18, 2019 · 5 revisions

"module.json" is a file which helps to manage the version and platform for edge module. This file is used as the source information when building an edge module. In this file, it describes

  • image.repository : The repository of the module
  • image.tag.version : The version of the module
  • image.tag.platforms : Each entry is a pair <platform key>:<dockerfile>. The platform name and its corresponding docker file used for the platform
  • image.buildOptions : The build arguments when running "docker build"
  • image.contextPath : The context path when running "docker build". By default it is the current folder of the "module.json" file. If your docker build needs files outside the current folder, please config the "contextPath" to the path which is the top of all necessary files. And make sure in the docker file, the files are copied.
  • language : The language of the module

The final tag of the image is combined with both version and platform as <repository>:<version>-<platform key>

Following is a sample "module.json" file. And the image tag for "amd64.debug" is "localhost:5000/csharpmod:0.0.1-amd64.debug"

{
    "$schema-version": "0.0.1",
    "description": "",
    "image": {
        "repository": "localhost:5000/csharpmod",
        "tag": {
            "version": "0.0.1",
            "platforms": {
                "amd64": "./Dockerfile.amd64", 
                "amd64.debug": "./Dockerfile.amd64.debug",
                "arm32v7": "./Dockerfile.arm32v7",
                "arm32v7.debug": "./Dockerfile.arm32v7.debug",
                "windows-amd64": "./Dockerfile.windows-amd64"
            }
        },
        "buildOptions": ["--add-host=docker:10.180.0.1"],
        "contextPath": "./"
    },
    "language": "csharp"
}

Note: you could add your platform names as key under the "platforms" and also put the corresponding docker file path as the value.

When running command "Azure IoT Edge: Build IoT Edge Module Image" or build the solution with specific platform, for example "amd64.debug". The actual command run to build image is

docker build --add-host=docker:10.180.0.1 --rm -f "<pathToFileDir>\Dockerfile.amd64.debug" -t localhost:5000/csharpmod:0.0.1-amd64.debug "<pathToModulesDir>\csharpmod"