# カスタムアプリケーションのホスティング

> カスタムアプリケーションのホスティング - DataRobotの実行環境を使用して、StreamlitアプリなどのカスタムアプリケーションをDataRobotでホストします。

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-07-15T05:55:44.895961+00:00` (UTC).

## Primary page

- [カスタムアプリケーションのホスティング](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md): Full documentation for this topic (Markdown sidecar).

## Sections on this page

- [DRApps CLIツールのインストール](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#install-the-drapps-cli-tool): In-page section heading.
- [DRApps CLIの使用](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#use-the-drapps-cli): In-page section heading.
- [createコマンド](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#create-command): In-page section heading.
- [logsコマンド](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#logs-command): In-page section heading.
- [lsコマンド](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#ls-command): In-page section heading.
- [terminateコマンド](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#terminate-command): In-page section heading.
- [external-shareコマンド](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#external-share-command): In-page section heading.
- [サンプルアプリのデプロイ](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#deploy-an-example-app): In-page section heading.
- [機能に関する注意事項](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/custom-apps-hosting.html.md#feature-considerations): In-page section heading.

## Documentation content

DRAppsはシンプルなコマンドラインインターフェイス（CLI）です。DataRobotでDataRobotの実行環境を使用するStreamlitアプリなどのアプリケーションをホストするのに必要なツールを提供します。 これにより、独自のDockerイメージを構築せずにアプリを実行できます。 アプリケーションはストレージを提供しません。ただし、DataRobotの全APIやその他のサービスにアクセスできます。 または、Dockerコンテナ内で [AIアプリ（Classic）](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/app-upload-custom.html.md) や [アプリケーション（NextGen）](https://docs.datarobot.com/ja/docs/classic-ui/app-builder/custom-apps/index.html.md) をアップロードすることもできます。

> [!NOTE] 休止状態のアプリケーション
> アプリケーションは、一定期間操作がないと休止状態になります。 休止状態のアプリケーションに初めてアクセスすると、再起動中にロード画面が表示されます。

## DRApps CLIツールのインストール

DRApps CLIツールをインストールするには、次のいずれかのコマンドを実行します。

**ユーザー:**
```
pip install git+https://github.com/datarobot/dr-apps 
```

**投稿者:**
まず、 [dr-appsリポジトリ](https://github.com/datarobot/dr-apps/tree/main) のクローンを作成し、次のコマンドを実行します。

```
python setup.py install 
```


## DRApps CLIの使用

DRApps CLIツールをインストールすると、 `drapps --help` コマンドを使用して次の情報にアクセスできます。

```
$ drapps --help     
Usage: drapps [OPTIONS] COMMAND [ARGS]...

  CLI tools for applications.

  You can use drapps COMMAND --help for getting more info about a command.

Options:
  --help  Show this message and exit.

  Commands:
    create          Creates new custom application from docker image or...
    create-env      Creates an execution environment and a first version.
    external-share  Share a custom application with a user.
    logs            Provides logs for custom application.
    ls              Provides list of custom applications or execution...
    publish         Updates a custom application.
    revert-publish  Reverts updates to a custom application.
    terminate       Stops custom application and removes it from the list. 
```

さらに、このページにリストされている各コマンドに対して `--help` を使用できます。

### createコマンド

構築済みのイメージ（ `docker build` と `docker save` の出力）から新しいアプリケーションを作成します。 アプリケーションがプロジェクトフォルダーから作成された場合、アプリケーションのイメージが作成されるか、既存のアプリケーションが更新されます。 詳細については、 `drapps create --help` コマンドを使用してください。

```
$ drapps create --help
Usage: drapps create [OPTIONS] APPLICATION_NAME

  Creates a new custom application from  a pre-built image (the output of docker build and docker save).

Options:
  -t, --token TEXT      Pubic API access token. You can use
                        DATAROBOT_API_TOKEN env instead.
  -E, --endpoint TEXT   DataRobot Public API endpoint. You can use
                        DATAROBOT_ENDPOINT instead. Default:
                        https://app.datarobot.com/api/v2
  -e, --base-env TEXT   Name or ID for execution environment.
  -p, --path DIRECTORY  Path to folder with files that should be uploaded.
  -i, --image FILE      Path to tar archive with custom application docker
                        images.
  --skip-wait           Do not wait for ready status.
  --help                Show this message and exit. 
```

各引数の詳細については、以下の表を参照してください。

| 引数 | 説明 |
| --- | --- |
| APPLICATION_NAME | アプリケーションの名前を入力します。 この名前は、サフィックスとしてImageを追加して、アプリケーションイメージの名前を生成する際にも使用されます。 |
| --token | DataRobotアカウントのAPIのキーとツールページにあるAPIキーを入力します。 DATAROBOT_API_TOKEN環境変数を使用してAPIキーを指定することもできます。 |
| --endpoint | DataRobotパブリックAPIのURLを入力します。 デフォルト値はhttps://app.datarobot.com/api/v2です。 DATAROBOT_ENDPOINT環境変数を使用してパブリックAPIのURLを指定することもできます。 |
| --base-env | Streamlitアプリのベースとして使用される実行環境のUUIDまたは名前を入力します。 実行環境には、アプリケーションに必要なライブラリとパッケージが含まれています。 使用可能な環境のリストは、 環境ページのカスタムモデルワークショップで確認できます。 カスタムStreamlitアプリケーションの場合は、--base-env '[DataRobot] Python 3.9 Streamlit'を使用します。 |
| --path | アプリケーションの作成に使われたフォルダーへのパスを入力します。 このフォルダーのファイルはDataRobotにアップロードされ、アプリケーションイメージの作成に使用されます。 アプリケーションは、このイメージから起動されます。 現在の作業ディレクトリを使用するには、--path .を使用します。 |
| --image | アプリケーションのDockerイメージを含むアーカイブへのパスを入力します。 docker save <image_name> > <file_name>.tarコマンドを使用して、Dockerイメージをファイルに保存できます。 |
| --skip-wait | アプリケーション作成リクエストが送信された直後に、アプリケーションのセットアップが完了するまで待たずにスクリプトを終了できるようにします。 |

### logsコマンド

アプリケーション向けに生成されたログを返します。 詳細については、 `drapps logs --help` コマンドを使用してください。

```
$ drapps logs --help
Usage: drapps logs [OPTIONS] APPLICATION_ID_OR_NAME

  Provides logs for custom application.

Options:
  -t, --token TEXT     Pubic API access token. You can use
                       DATAROBOT_API_TOKEN env instead.
  -E, --endpoint TEXT  DataRobot Public API endpoint. You can use
                       DATAROBOT_ENDPOINT instead. Default:
                       https://app.datarobot.com/api/v2
  -f, --follow         Output append data as new log records appear.
  --help               Show this message and exit. 
```

| 引数 | 説明 |
| --- | --- |
| APPLICATION_ID_OR_NAME | ログを表示するアプリケーションのIDまたは名前を入力します。 |
| --token | DataRobotアカウントのAPIのキーとツールページにあるAPIキーを入力します。 DATAROBOT_API_TOKEN環境変数を使用してAPIキーを指定することもできます。 |
| --endpoint | DataRobotパブリックAPIのURLを入力します。 デフォルト値はhttps://app.datarobot.com/api/v2です。 DATAROBOT_ENDPOINT環境変数を使用してパブリックAPIのURLを指定することもできます。 |
| --follow | スクリプトを有効にして、表示される新しいログレコードを引き続きチェックします。 |

### lsコマンド

アプリケーションまたは実行環境のリストを返します。 詳細については、 `drapps ls --help` コマンドを使用してください。

```
$ drapps ls --help
Usage: drapps ls [OPTIONS] {apps|envs}

  Provides list of custom applications or execution environments.

Options:
  -t, --token TEXT     Pubic API access token. You can use
                       DATAROBOT_API_TOKEN env instead
  -E, --endpoint TEXT  DataRobot Public API endpoint. You can use
                       DATAROBOT_ENDPOINT instead. Default:
                       https://app.datarobot.com/api/v2
  --id-only            Output only ids
  --help               Show this message and exit. 
```

| 引数 | 説明 |
| --- | --- |
| --token | DataRobotアカウントのAPIのキーとツールページにあるAPIキーを入力します。 DATAROBOT_API_TOKEN環境変数を使用してAPIキーを指定することもできます。 |
| --endpoint | DataRobotパブリックAPIのURLを入力します。 デフォルト値はhttps://app.datarobot.com/api/v2です。 DATAROBOT_ENDPOINT環境変数を使用してパブリックAPIのURLを指定することもできます。 |
| --id-only | エンティティのIDのみを表示できるようにします。 このコマンドは、コマンドを終了させるパイピングと一緒に使用すると便利です。 |

### terminateコマンド

アプリケーションを停止し、アプリケーションリストから削除します。 詳細については、 `drapps terminate --help` コマンドを使用してください。

```
$ drapps terminate --help
Usage: drapps terminate [OPTIONS] APPLICATION_ID_OR_NAME...

  Stops custom application and removes it from the list.

Options:
  -t, --token TEXT     Pubic API access token. You can use
                       DATAROBOT_API_TOKEN env instead
  -E, --endpoint TEXT  DataRobot Public API endpoint. You can use
                       DATAROBOT_ENDPOINT instead. Default:
                       https://app.datarobot.com/api/v2.
  --help               Show this message and exit. 
```

| 引数 | 説明 |
| --- | --- |
| APPLICATION_ID_OR_NAME | 削除するアプリケーションのIDまたは名前のスペース区切りリストを入力します。 |
| --token | DataRobotアカウントのAPIのキーとツールページにあるAPIキーを入力します。 DATAROBOT_API_TOKEN環境変数を使用してAPIキーを指定することもできます。 |
| --endpoint | DataRobotパブリックAPIのURLを入力します。 デフォルト値はhttps://app.datarobot.com/api/v2です。 DATAROBOT_ENDPOINT環境変数を使用してパブリックAPIのURLを指定することもできます。 |

### external-shareコマンド

アプリケーションにアクセスできる外部ユーザーを管理します。 詳細については、 `drapps external-share --help` コマンドを使用してください。

```
$ drapps external-share  --help
Usage: drapps external-share [OPTIONS] APPLICATION_NAME

Options:
  -t, --token TEXT                Pubic API access token. You can use
                                  DATAROBOT_API_TOKEN env instead.
  -E, --endpoint TEXT             Data Robot Public API endpoint. You can use
                                  DATAROBOT_ENDPOINT instead. Default:
                                  https://app.datarobot.com/api/v2
  --set-external-sharing BOOLEAN
  --add-external-user TEXT
  --remove-external-user TEXT
  --help                          Show this message and exit. 
```

| 引数 | 説明 |
| --- | --- |
| -t, --token | （テキスト）DataRobotアカウントのAPIのキーとツールページにあるAPIキーを入力します。 DATAROBOT_API_TOKEN環境変数を使用してAPIキーを指定することもできます。 |
| -E, --endpoint | （テキスト）DataRobotパブリックAPIのURLを入力します。 デフォルト値はhttps://app.datarobot.com/api/v2です。 DATAROBOT_ENDPOINT環境変数を使用してパブリックAPIのURLを指定することもできます。 |
| --set-external-sharing | （ブーリアン）アプリケーションで外部共有を有効にするかどうかを決定します。 |
| --add-external-user | （テキスト）指定したユーザーにアプリケーションへのアクセス権を付与します。 |
| --remove-external-user | （テキスト）指定したユーザーのアプリケーションへのアクセス権を取り消します。 |
| --help | コマンドで使用可能な引数を表示します。 |

アプリで外部共有を有効にするには：

```
drapps external-share <USER_ID> --set-external-sharing True 
```

アカウントで（IDによる）外部共有を有効にするには：

```
drapps external-share <USER_ID> --add-external-user user@datarobot.com 
```

アカウントで（名前による）外部共有を有効にするには：

```
drapps external-share MyAwesomeApp --add-external-user user@email.com 
```

外部共有でユーザーを2人追加するには：

```
drapps external-share MyAwesomeApp --add-external-user user@email.com  --add-external-user person@email.com 
```

外部共有でユーザーを1人追加し、1人削除するには：

```
drapps external-share MyAwesomeApp --add-external-user user@email.com  --remove-external-user person@email.com 
```

## サンプルアプリのデプロイ

まず、 [dr-appsリポジトリ](https://github.com/datarobot/dr-apps/tree/main) のクローンを作成し、サンプルアプリにアクセスできるようにします。 その後、dr-appsリポジトリのルートから次のコマンドを使用して、Streamlitアプリの例をデプロイできます。

```
drapps create -t <your_api_token> -e "[Experimental] Python 3.9 Streamlit" -p ./examples/demo-streamlit DemoApp 
```

この例では、スクリプトは次のように動作します。

1. 指定した名前またはUUIDで/api/v2/executionEnvironments/エンドポイントから実行環境を検索し、その環境がアプリケーションに使用できるかどうかを確認し、最新の環境バージョンのIDを取得します。
2. /api/v2/customApplicationImages/エンドポイントからアプリケーションイメージを検索または作成します。このイメージの名前は、指定されたアプリケーション名にImageサフィックスを追加したものです（つまり、CustomApp Image）。
3. customApplicationImages/<appImageId>/versionsエンドポイントからアプリケーションイメージの新しいバージョンを作成して、指定したディレクトリからすべてのファイルをアップロードし、最初の手順で定義した実行環境のバージョンを設定します。
4. 前の手順で作成したアプリケーションイメージのバージョンで新しいアプリケーションを起動します。

このスクリプトが正常に実行されると、 [アプリケーション](https://app.datarobot.com/applications) ページのアプリへのリンクがターミナルに表示されます。

> [!NOTE] アプリケーションへのアクセス
> アプリケーションにアクセスするには、アプリケーションに関連付けられたDataRobotインスタンスとアカウントにログインする必要があります。

## 機能に関する注意事項

アプリケーションを作成するときは、以下の点に注意してください。

- アプリケーションのルートディレクトリには、アプリケーションサーバーを起動するためのエントリーポイントとして使用されるstart-app.shファイルが含まれている必要があります。
- アプリケーションのウェブサーバーは、ポート8080でリッスンする必要があります。
- 必要なパッケージは、アプリケーションのセットアップ時に自動的にインストールするために、アプリケーションのルートディレクトリにあるrequirements.txtファイル内にリストできます。
- アプリケーションは、DataRobotのAPIのキーとツールにあるキーを使用し、DATAROBOT_API_TOKEN環境変数を通じてDataRobot APIで認証する必要があります。 PyPIのDataRobotパッケージは、すでにこの方法で認証されています。 この環境変数は、アプリケーションサービスによって、実行中のコンテナに自動的に追加されます。
- アプリケーションは、DATAROBOT_ENDPOINT環境変数を使用して、現在の環境に対応するDataRobotパブリックAPIのURLにアクセスする必要があります。 PyPIのDataRobotパッケージは、このルートをすでに使用しています。 この環境変数は、アプリケーションサービスによって、実行中のコンテナに自動的に追加されます。
