📣

TiDB Cloud Serverless が
Starter
に変わりました!このページは自動翻訳されたものです。
原文はこちらからご覧ください。

ギットポッド

ギットポッド使用すると、ボタンまたはリンクをクリックするだけでブラウザ内で完全な開発環境が得られ、すぐにコードを記述できます。

Gitpodは、コードを直接操作する開発環境向けのオープンソースKubernetesアプリケーション(GitHubリポジトリアドレス: https://github.com/gitpod-io/gitpod )です。クラウド上で、タスクごとに最新の自動化開発環境を数秒で構築します。開発環境をコードとして記述し、ブラウザまたはデスクトップIDEから直接、リモートおよびクラウドベースの開発環境を即座に開始できます。

クイックスタート

  1. TiDB アプリケーション開発用のサンプル コード リポジトリpingcap-inc/tidb-example-javaフォークします。

  2. ブラウザのアドレスバーでサンプル コード リポジトリの URL の前にhttps://gitpod.io/#を付けて、Gitpod ワークスペースを起動します。

    • たとえば、 https://gitpod.io/#https://github.com/pingcap-inc/tidb-example-java

    • URL内で環境変数を設定できます。例: https://gitpod.io/#targetFile=spring-jpa-hibernate_Makefile,targetMode=spring-jpa-hibernate/https://github.com/pingcap-inc/tidb-example-java

  3. ログインし、リストされているプロバイダーのいずれかを使用してワークスペースを起動します。例: Github

デフォルトのGitpod設定と環境を使用する

クイックスタート手順を完了した後、Gitpod がワークスペースをセットアップするまでにしばらく時間がかかります。

スプリングブートウェブのアプリケーションを例に挙げると、 https://gitpod.io/#targetFile=spring-jpa-hibernate_Makefile,targetMode=spring-jpa-hibernate/https://github.com/pingcap-inc/tidb-example-javaのURLで新しいワークスペースを作成できます。

その後、次のようなページが表示されます。

playground gitpod workspace init

このページのシナリオでは、 TiUP使用してTiDB Playgroundを構築します。ターミナル領域の左側で進行状況を確認できます。

TiDB Playground の準備が完了すると、さらにSpring JPA Hibernateタスクが実行されます。ターミナル領域の右側で進行状況を確認できます。

これらのタスクがすべて完了すると、次のようなページが表示されます。このページで、左側のナビゲーションペインのREMOTE EXPLORER領域(GitpodはURLベースのポート転送をサポートしています)を確認し、ポート8080のURLを見つけます。

playground gitpod workspace ready

カスタムGitpod構成とDockerイメージの使用

Gitpodの設定をカスタマイズする

例.gitpod.ymlを参照して、プロジェクトのルート ディレクトリに.gitpod. ymlファイルを作成し、Gitpod ワークスペースを構成します。

# This configuration file was automatically generated by Gitpod. # Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file) # and commit this file to your remote git repository to share the goodness with others. # image: # file: .gitpod.Dockerfile tasks: - name: Open Target File command: | if [ -n "$targetFile" ]; then code ${targetFile//[_]//}; fi - name: TiUP init playground command: | $HOME/.tiup/bin/tiup playground - name: Test Case openMode: split-right init: echo "*** Waiting for TiUP Playground Ready! ***" command: | gp await-port 3930 if [ "$targetMode" == "plain-java-jdbc" ] then cd plain-java-jdbc code src/main/resources/dbinit.sql code src/main/java/com/pingcap/JDBCExample.java make mysql elif [ "$targetMode" == "plain-java-hibernate" ] then cd plain-java-hibernate make elif [ "$targetMode" == "spring-jpa-hibernate" ] then cd spring-jpa-hibernate make fi ports: - port: 8080 visibility: public - port: 4000 visibility: public - port: 2379-36663 onOpen: ignore

Gitpod Dockerイメージをカスタマイズする

Gitpod はデフォルトで、Workspace-Full という標準 Docker イメージをワークスペースのベースとして使用します。このデフォルトイメージから起動されたワークスペースには、Docker、Go、 Java、Node.js、C/C++、Python、Ruby、Rust、PHP、そしてHomebrew、Tailscale、Nginx などのツールがプリインストールされています。

パブリック Docker イメージまたは Dockerfile を使用し、プロジェクトに必要な依存関係をインストールすることもできます。

たとえば、次のように Dockerfile ( .gitpod.Dockerfileも参照) を使用できます。

FROM gitpod/workspace-java-17 RUN sudo apt install mysql-client -y RUN curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

次に、 .gitpod.yml更新する必要があります。

# This configuration file was automatically generated by Gitpod. # Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file) # and commit this file to your remote git repository to share the goodness with others. image: # Import your Dockerfile here. file: .gitpod.Dockerfile tasks: - name: Open Target File command: | if [ -n "$targetFile" ]; then code ${targetFile//[_]//}; fi - name: TiUP init playground command: | $HOME/.tiup/bin/tiup playground - name: Test Case openMode: split-right init: echo "*** Waiting for TiUP Playground Ready! ***" command: | gp await-port 3930 if [ "$targetMode" == "plain-java-jdbc" ] then cd plain-java-jdbc code src/main/resources/dbinit.sql code src/main/java/com/pingcap/JDBCExample.java make mysql elif [ "$targetMode" == "plain-java-hibernate" ] then cd plain-java-hibernate make elif [ "$targetMode" == "spring-jpa-hibernate" ] then cd spring-jpa-hibernate make fi ports: - port: 8080 visibility: public - port: 4000 visibility: public - port: 2379-36663 onOpen: ignore

変更を適用する

.gitpod.ymlファイルの設定が完了したら、対応する GitHub リポジトリで最新のコードが利用可能であることを確認します。

https://gitpod.io/#<YOUR_REPO_URL>アクセスして、最新のコードが適用された新しい Gitpod ワークスペースを作成します。

確立されたすべてのワークスペースについては、 https://gitpod.io/workspaces参照してください。

まとめ

Gitpodは、完全かつ自動化された、事前設定済みのクラウドネイティブ開発環境を提供します。ローカル設定を必要とせず、ブラウザ内で直接コードを開発、実行、テストできます。

playground gitpod summary

ヘルプが必要ですか?

不和またはスラック 、あるいはサポートチケットを送信するについてコミュニティに質問してください。

このページは役に立ちましたか?