アーティファクトの作成#

カスタムプロジェクトのアプリケーションアップデートアーティファクトには、以下のファイルが必要です。

  • Composeファイル(docker-compose.yml)

  • Dockerイメージのアーカイブ (プライベートリポジトリ利用時のみ)

  • Mender Configureスクリプト (Mender Configure利用時のみ)

measurementプロジェクトとはアップデートに利用するファイルが異なりますので、 custom/contents ディレクトリは以下のように格納してください。

例: Composeファイル、Mender Configureスクリプトを格納

custom/contents/docker-compose.yml
custom/contents/20-custom-apply
custom/contents/20-custom-update

例: アップデートの処理を行うスクリプト custom/custom_script.sh

function custom_artifact_install() {
      # Custom install process
      # Contents are located in $CUSTOM_CONTENTS_DIR

      # install example project
      mkdir -p /var/lib/core/docker-compose/example
      cp -f $CUSTOM_CONTENTS_DIR/docker-compose.yml /var/lib/core/docker-compose/example/

      # set boot_after to system
      curl --fail-with-body -sSL -X PATCH -d '{"boot_after": "system"}' http://localhost:8081/api/docker/composes/example

      # install mender configure scripts
      cp -f $CUSTOM_CONTENTS_DIR/20-custom-apply /usr/lib/mender-configure/apply-device-config.d/
      cp -f $CUSTOM_CONTENTS_DIR/20-custom-update /usr/lib/mender-configure/update-device-config.d/
}

カスタムプロジェクトのComposeファイルは、 /var/lib/core/docker-compose/<プロジェクト名> にインストールします。

カスタムプロジェクトの起動タイミングを、Terminal System APIの Update Docker Compose の設定項目 boot_after で設定します。 システム起動時や、指定したプロジェクトの後に自動的に起動することが可能です。

  • "system" を指定した場合、プロジェクトはシステム起動時に起動し、システム終了時に終了します。

  • "measurement" を指定した場合、プロジェクトはmeasurementプロジェクトの起動後に起動し、measurementプロジェクトの終了後に終了します。

  • "" を指定した場合、自動起動は行いません。 Start Docker Compose / Stop Docker Compose のみで起動/終了します。

Mender Configureスクリプトは、 以下のディレクトリにインストールします。

/usr/lib/mender-configure/apply-device-config.d
/usr/lib/mender-configure/update-device-config.d

注意

あらかじめ、Mender Configureスクリプトには実行権限を付けてください。

その他は measurementプロジェクトでのアーティファクト作成 と同様の手順です。