Mengembangkan layanan secara lokal di Cloud Code untuk IntelliJ
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dengan Cloud Code, Anda dapat mengembangkan layanan Cloud Run secara lokal di lingkungan yang mirip dengan Cloud Run. Cloud Code memantau perubahan pada sumber Anda dan dengan cepat memperbarui layanan yang sedang berjalan untuk mencerminkan perubahan ini.
Menentukan konfigurasi proses
Sebelum menjalankan layanan, Anda harus membuat konfigurasi eksekusi:
Buka pemilih konfigurasi Run/Debug di Navigation bar, lalu klik Edit Configurations.
Di bagian Cloud Code: Cloud Run, pilih Cloud Run: Run Locally.
Jika Anda ingin Cloud Code men-deploy ulang aplikasi Anda secara otomatis setelah perubahan Anda disimpan, di bagian Watch mode - rebuild and redeploy, pilih On file save. Layanan Cloud Run baru memiliki Sesuai permintaan
yang dipilih secara default. Untuk mengetahui informasi selengkapnya tentang mode smartwatch, lihat
Mode smartwatch.
Tentukan opsi builder dan setelannya yang relevan.
Cloud Code mendukung jenis artefak Docker, Jib, dan Buildpack.
Klik Oke.
Opsional: Menyesuaikan konfigurasi
Saat mengembangkan secara lokal, Anda dapat menentukan setelan tambahan seperti akun layanan, variabel lingkungan, dan koneksi SQL (saat menggunakan Cloud Run (dikelola sepenuhnya)), menggunakan bagian Setelan revisi lanjutan saat Anda memilih Edit Konfigurasi.
Variabel lingkungan
Variabel lingkungan berikut akan otomatis ditambahkan ke container yang berjalan:
Nama
Deskripsi
Contoh
PORT
Port yang akan diproses oleh server HTTP Anda.
8080
K_SERVICE
Nama layanan Cloud Run yang sedang dijalankan.
hello-world
K_REVISION
Nama revisi Cloud Run yang sedang dijalankan.
hello-world.1
K_CONFIGURATION
Nama konfigurasi Cloud Run yang membuat revisi.
hello-world
Menyimpan rahasia
Jika kode Anda menyertakan data yang berpotensi sensitif seperti kunci API, sandi, dan sertifikat, sebaiknya simpan data tersebut sebagai secret. Dengan
Cloud Code, Anda dapat menyimpan secret ini dengan aman di Secret Manager
dan mengambilnya secara terprogram saat Anda membutuhkannya. Untuk melihat secara mendetail cara membuat dan mengelola secret dengan Cloud Code, lihat panduan Secret Manager.
Menjalankan layanan Anda
Untuk menjalankan layanan, ikuti langkah-langkah berikut:
Pilih target eksekusi Cloud Run: Run Locally dari pemilih konfigurasi Run/Debug di panel Navigasi.
Klik Cloud Run: Run Locally.
Lihat log dari layanan yang sedang berjalan, yang di-streaming langsung ke jendela output.
Setelah deployment selesai, Anda dapat melihat layanan yang sedang berjalan dengan mengikuti
URL yang ditampilkan di panel Log Peristiwa. Dalam contoh di bawah, URL ini adalah
http://localhost:8080.
Mendapatkan dukungan
Untuk mengirimkan masukan atau melaporkan masalah di IDE IntelliJ, buka
Tools > Cloud Code > Help / About > Submit
feedback or report an issue untuk melaporkan masalah di GitHub.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-05 UTC."],[[["\u003cp\u003eCloud Code enables local development of Cloud Run services in a simulated environment, with real-time updates reflecting code changes.\u003c/p\u003e\n"],["\u003cp\u003eBefore running a service, users must define a run configuration in the "Edit Configurations" section, specifying options like the builder type and watch mode preference.\u003c/p\u003e\n"],["\u003cp\u003eDuring local development, users can customize configurations by adding settings such as service accounts, environment variables, and SQL connections.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code automatically adds environment variables like PORT, K_SERVICE, K_REVISION, and K_CONFIGURATION to running containers.\u003c/p\u003e\n"],["\u003cp\u003eSecrets, such as API keys and passwords, can be securely stored in Secret Manager and accessed programmatically using Cloud Code.\u003c/p\u003e\n"]]],[],null,["# Develop a service locally in Cloud Code for IntelliJ\n\nWith Cloud Code, you can develop your Cloud Run services\nlocally in a Cloud Run-like environment. Cloud Code watches\nfor changes in your source and quickly updates the running service to\nreflect these changes.\n\nDefining your run configuration\n-------------------------------\n\nBefore you run your service, you must create your run configuration:\n\n1. Navigate to Run/Debug configurations selector in the Navigation bar and click **Edit Configurations**.\n2. Under Cloud Code: Cloud Run, choose **Cloud Run: Run Locally**.\n3. If you want Cloud Code to redeploy your application automatically after your changes are saved, under **Watch mode - rebuild and\n redeploy** , select **On file save** . New Cloud Run services have **On demand** selected by default. For more information about watch modes, see [Watch modes](/code/docs/intellij/watch-modes).\n4. Specify your builder option and its relevant settings.\n\n Cloud Code supports Docker, Jib, and Buildpacks\n [artifact types](https://skaffold.dev/docs/builders/).\n5. Click **OK**.\n\n### Optional: Customizing your configuration\n\nWhen developing locally, you can specify additional settings like a service\naccount, environment variables, and SQL connections (when using\nCloud Run (fully managed)), using the Advanced revision settings section when\nyou choose **Edit Configurations**.\n\n#### Environment variables\n\nThe following environment variables are automatically added to the\nrunning containers:\n\nStoring secrets\n---------------\n\nIf your code includes potentially sensitive data like API keys, passwords, and\ncertificates, it is recommended you store them as secrets. With\nCloud Code, you can securely store these secrets in Secret Manager\nand programmatically fetch them when you need them. For a detailed look at\nhow you can create and manage secrets with Cloud Code, refer to\nthe [Secret Manager guide](/code/docs/intellij/secret-manager).\n\nRunning your service\n--------------------\n\nTo run your service, follow these steps:\n\n1. Choose the **Cloud Run: Run Locally** run target from the Run/Debug configurations selector in the Navigation bar.\n2. Click **Cloud Run: Run Locally**.\n3. View the logs from your running service, streamed directly to the **output window**.\n4. Once deployment is complete, you can view your running service by following the\n URL displayed in your Event Log panel. In the example below, this URL is\n http://localhost:8080.\n\nGet support\n-----------\n\nTo submit feedback or report an issue in your IntelliJ IDE, go to **Tools** \\\u003e **Cloud Code** \\\u003e **Help / About** \\\u003e **Submit\nfeedback or report an issue** to report an issue on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-intellij/issues)."]]