簡體   English   中英

Cloud Run、使用命令部署與使用 InteliJ Cloud Code 部署

[英]Cloud Run, Deploy with Commands vs Deploy with InteliJ Cloud Code

我現在真的很痛苦.. 我需要知道為什么.. 如果我使用我的命令進行部署,某些文件(可執行文件 like.exe)無法正常工作。 (並在部署后使用 IntelliJ 自動部署並完美運行)

我真的很想像 InteliJ 那樣做同樣的部署。

這是部署代碼。 上面一個是我自己做的

下面一個是 IntelliJ 做的

我真的很想對 IntelliJ Auto Deploy 做同樣的事情

請看代碼

---- 使用命令手動執行

簡而言之,我用這個

gcloud builds submit --tag gcr.io/<PROJECT-ID>

gcloud run deploy --image gcr.io/<PROJECT-ID> --platform managed

完整的代碼

PS C:\go\abc-origin> gcloud builds submit --tag gcr.io/abc-b13a0/abc-origin  
Creating temporary tarball archive of 82 file(s) totalling 9.3 MiB before compression.
Some files were not included in the source upload.                                                                                        
                                                                                                                                          
Check the gcloud log [C:\Users\abc\AppData\Roaming\gcloud\logs\2022.03.28\11.34.38.416229.log] to see which files and the contents of the
default gcloudignore file used (see `$ gcloud topic gcloudignore` to learn                                                                
more).                                                                                                                                    

Uploading tarball of [.] to [gs://abc-b13a0_cloudbuild/source/1648434878.494229-ae5063c025314197813db4b93ec85691.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/abc-b13a0/locations/global/builds/313435fd-8c72-4230-9777-c9eb12b739fa].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/313435fd-8c72-4230-9777-c9eb12b739fa?project=291094557957].
----------------------------------------------------------------------------------------- REMOTE BUILD OUTPUT ------------------------------------------------------------------------------------------
starting build "313435fd-8c72-4230-9777-c9eb12b739fa"

FETCHSOURCE
Fetching storage object: gs://abc-b13a0_cloudbuild/source/1648434878.494229-ae5063c025314197813db4b93ec85691.tgz#1648434880757751
Copying gs://abc-b13a0_cloudbuild/source/1648434878.494229-ae5063c025314197813db4b93ec85691.tgz#1648434880757751...
/ [1 files][  8.6 MiB/  8.6 MiB]
Operation completed over 1 objects/8.6 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
Sending build context to Docker daemon  899.1kB
Step 1/7 : FROM node:17-slim
17-slim: Pulling from library/node
ae13dd578326: Pulling fs layer
a0bc29d3bc64: Pulling fs layer
d0e0f1a959b4: Pulling fs layer
fe23f6dccded: Pulling fs layer
f23aa4f1504d: Pulling fs layer
fe23f6dccded: Waiting
f23aa4f1504d: Waiting
a0bc29d3bc64: Download complete
fe23f6dccded: Verifying Checksum
fe23f6dccded: Download complete
ae13dd578326: Verifying Checksum
ae13dd578326: Download complete
f23aa4f1504d: Verifying Checksum
f23aa4f1504d: Download complete
d0e0f1a959b4: Verifying Checksum
d0e0f1a959b4: Download complete
ae13dd578326: Pull complete
a0bc29d3bc64: Pull complete
d0e0f1a959b4: Pull complete
fe23f6dccded: Pull complete
f23aa4f1504d: Pull complete
Digest: sha256:3894373926629c8e2c437314fb253b5d261efa6bddb2c947474406470fee2890
Status: Downloaded newer image for node:17-slim
 ---> 83d5dcf3f6f6
Step 2/7 : WORKDIR /usr/src/app
 ---> Running in addca1bcb85e
Removing intermediate container addca1bcb85e
 ---> e0568396db62
Step 3/7 : COPY . .
 ---> ff239f669d09
Step 4/7 : COPY . ./
 ---> 78544462e12c
Step 5/7 : RUN npm install
 ---> Running in 2e558015a5d5
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated @types/mongoose@5.11.97: Mongoose publishes its own types, so you do not need to install this package.
npm WARN deprecated @types/helmet@4.0.0: This is a stub types definition. helmet provides its own type definitions, so you do not need this installed.
npm WARN deprecated @types/iconv-lite@0.0.1: This is a stub types definition for iconv-lite (https://github.com/ashtuchkin/iconv-lite). iconv-lite provides its own type definitions, so you don\'t need
 @types/iconv-lite installed!
npm WARN deprecated @hapi/pinpoint@2.0.0: Moved to 'npm install @sideway/pinpoint'
npm WARN deprecated @hapi/formula@2.0.0: Moved to 'npm install @sideway/formula'
npm WARN deprecated @hapi/address@4.1.0: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/joi@17.1.1: Switch to 'npm install joi'
npm WARN deprecated tslint@6.1.3: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.

added 1011 packages, and audited 1012 packages in 55s

77 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Removing intermediate container 2e558015a5d5
 ---> 5d7ff12b8075
Step 6/7 : RUN npm run build
 ---> Running in a2c0d89306c7

> nodejs-cloud-run-hello-world@0.0.1 build
> tsc --build
Removing intermediate container a2c0d89306c7
 ---> 96d13c4da119
Step 7/7 : CMD ["npm","start"]
 ---> Running in 3aaafeaa519c
Removing intermediate container 3aaafeaa519c
 ---> 0ffe22dfcae7
Successfully built 0ffe22dfcae7
Successfully tagged gcr.io/abc-b13a0/abc-origin:latest
PUSH
Pushing gcr.io/abc-b13a0/abc-origin
The push refers to repository [gcr.io/abc-b13a0/abc-origin]
1536374452a8: Preparing
6b04bb227785: Preparing
e86eb4a3c682: Preparing
5f8624a6a2ac: Preparing
05d059f19b02: Preparing
40ed0919f5f8: Preparing
016b2cae399b: Preparing
fd91c8bc8266: Preparing
009cb98a6eb1: Preparing
3a626bb08c24: Preparing
40ed0919f5f8: Waiting
016b2cae399b: Waiting
fd91c8bc8266: Waiting
009cb98a6eb1: Waiting
3a626bb08c24: Waiting
5f8624a6a2ac: Pushed
e86eb4a3c682: Pushed
05d059f19b02: Pushed
1536374452a8: Pushed
40ed0919f5f8: Layer already exists
009cb98a6eb1: Layer already exists
fd91c8bc8266: Layer already exists
016b2cae399b: Layer already exists
3a626bb08c24: Layer already exists
6b04bb227785: Pushed
latest: digest: sha256:926c748640d78c396863bdf6fa8c246247bf0619e5a2764e87827f605349f6bc size: 2415
DONE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ID                                    CREATE_TIME                DURATION  SOURCE                                                                                      IMAGES
            STATUS
313435fd-8c72-4230-9777-c9eb12b739fa  2022-03-28T02:34:41+00:00  1M49S     gs://abc-b13a0_cloudbuild/source/1648434878.494229-ae5063c025314197813db4b93ec85691.tgz  gcr.io/abc-b13a0/abc-origin
 (+1 more)  SUCCESS
PS C:\go\abc-origin> gcloud run deploy --image gcr.io/abc-b13a0/abc-origin --platform managed

---- INTELLIJ AUTO CLOUD RUN 部署默認

C:\Users\Abc\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\bin\gcloud.cmd run deploy abc-origin --quiet --image gcr.io/abc-b13a0/abc-origin --platform managed --project abc-b13a0 --memory 256Mi --timeout 300 --concurrency 80 --max-instances 1000 --cpu 1 --clear-env-vars --clear-cloudsql-instances --client-name "Cloud Code for IntelliJ" --client-version 22.2.1-213 --region asia-northeast1 --allow-unauthenticated --clear-vpc-connector

Preparing Google Cloud SDK (this may take several minutes for first time setup)...

Creating skaffold file: C:\Users\Abc\AppData\Local\Temp\skaffold5770358230968925998.tmp...

Configuring image push settings in C:\Users\Abc\AppData\Local\Temp\skaffold5770358230968925998.tmp...

C:\Users\Abc\AppData\Local\cloud-code\bin\versions\06e58efc4201989233a521d3211c1a2558e7db7b947e23aa203e5d2e46c990d3\skaffold.exe build --filename C:\Users\Abc\AppData\Local\Temp\skaffold5770358230968925998.tmp --tag latest --skip-tests=true
Generating tags...
 - gcr.io/abc-b13a0/abc-origin -> gcr.io/abc-b13a0/abc-origin:latest
Checking cache...
 - gcr.io/abc-b13a0/abc-origin: Not found. Building
Starting build...
Building [gcr.io/abc-b13a0/abc-origin]...
Pushing code to gs://abc-b13a0_cloudbuild/source/abc-b13a0-5556f485-72cc-4ccf-967d-bfdd1d0d5329.tar.gz
Logs are available at 
https://console.cloud.google.com/m/cloudstorage/b/abc-b13a0_cloudbuild/o/log-99f843b0-8ff0-4e4e-99d8-7abdc7bf30e4.txt
starting build "99f843b0-8ff0-4e4e-99d8-7abdc7bf30e4"

FETCHSOURCE
Fetching storage object: gs://abc-b13a0_cloudbuild/source/abc-b13a0-5556f485-72cc-4ccf-967d-bfdd1d0d5329.tar.gz#1648433508081094
Copying gs://abc-b13a0_cloudbuild/source/abc-b13a0-5556f485-72cc-4ccf-967d-bfdd1d0d5329.tar.gz#1648433508081094...
/ [1 files][  9.2 MiB/  9.2 MiB]                                                
Operation completed over 1 objects/9.2 MiB.                                      
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
Sending build context to Docker daemon  10.54MB
Step 1/7 : FROM node:17-slim
17-slim: Pulling from library/node
ae13dd578326: Pulling fs layer
a0bc29d3bc64: Pulling fs layer
d0e0f1a959b4: Pulling fs layer
fe23f6dccded: Pulling fs layer
f23aa4f1504d: Pulling fs layer
fe23f6dccded: Waiting
f23aa4f1504d: Waiting
a0bc29d3bc64: Verifying Checksum
a0bc29d3bc64: Download complete
fe23f6dccded: Verifying Checksum
fe23f6dccded: Download complete
ae13dd578326: Verifying Checksum
ae13dd578326: Download complete
f23aa4f1504d: Verifying Checksum
f23aa4f1504d: Download complete
d0e0f1a959b4: Verifying Checksum
d0e0f1a959b4: Download complete
ae13dd578326: Pull complete
a0bc29d3bc64: Pull complete
d0e0f1a959b4: Pull complete
fe23f6dccded: Pull complete
f23aa4f1504d: Pull complete
Digest: sha256:3894373926629c8e2c437314fb253b5d261efa6bddb2c947474406470fee2890
Status: Downloaded newer image for node:17-slim
 ---> 83d5dcf3f6f6
Step 2/7 : WORKDIR /usr/src/app
 ---> Running in 5c7029771a25
Removing intermediate container 5c7029771a25
 ---> 7b2ba07f192a
Step 3/7 : COPY . .
 ---> 8e1720a22a0a
Step 4/7 : COPY . ./
 ---> 3437788621d6
Step 5/7 : RUN npm install
 ---> Running in 77bc58474b9a
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated @types/helmet@4.0.0: This is a stub types definition. helmet provides its own type definitions, so you do not need this installed.
npm WARN deprecated @types/mongoose@5.11.97: Mongoose publishes its own types, so you do not need to install this package.
npm WARN deprecated @types/iconv-lite@0.0.1: This is a stub types definition for iconv-lite (https://github.com/ashtuchkin/iconv-lite). iconv-lite provides its own type definitions, so you don\'t need @types/iconv-lite installed!
npm WARN deprecated @hapi/formula@2.0.0: Moved to 'npm install @sideway/formula'
npm WARN deprecated @hapi/pinpoint@2.0.0: Moved to 'npm install @sideway/pinpoint'
npm WARN deprecated @hapi/address@4.1.0: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/joi@17.1.1: Switch to 'npm install joi'
npm WARN deprecated tslint@6.1.3: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.

added 1011 packages, and audited 1012 packages in 58s

77 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Removing intermediate container 77bc58474b9a
 ---> 716aa89b15ed
Step 6/7 : RUN npm run build
 ---> Running in 88daa40576c1

> nodejs-cloud-run-hello-world@0.0.1 build
> tsc --build

Removing intermediate container 88daa40576c1
 ---> f06d20cb4695
Step 7/7 : CMD ["npm","start"]
 ---> Running in 114dccd18b7b
Removing intermediate container 114dccd18b7b
 ---> 44eae9ff6f01
Successfully built 44eae9ff6f01
Successfully tagged gcr.io/abc-b13a0/abc-origin:latest
PUSH
Pushing gcr.io/abc-b13a0/abc-origin:latest
The push refers to repository [gcr.io/abc-b13a0/abc-origin]
5ca13cc3b48f: Preparing
7e236c8bde4e: Preparing
da179f551c57: Preparing
bf4615d388ff: Preparing
c349e402c854: Preparing
40ed0919f5f8: Preparing
016b2cae399b: Preparing
fd91c8bc8266: Preparing
009cb98a6eb1: Preparing
3a626bb08c24: Preparing
40ed0919f5f8: Waiting
016b2cae399b: Waiting
fd91c8bc8266: Waiting
009cb98a6eb1: Waiting
3a626bb08c24: Waiting
c349e402c854: Pushed
40ed0919f5f8: Layer already exists
5ca13cc3b48f: Pushed
fd91c8bc8266: Layer already exists
016b2cae399b: Layer already exists
009cb98a6eb1: Layer already exists
3a626bb08c24: Layer already exists
bf4615d388ff: Pushed
da179f551c57: Pushed
7e236c8bde4e: Pushed
latest: digest: sha256:efe017d86ad7a5f43a800b3acdb9519f1a0cf6aefc80d0291ba2f84fc32c08fa size: 2417
DONE

C:\Users\Abc\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\bin\gcloud.cmd run deploy abc-origin --quiet --image gcr.io/abc-b13a0/abc-origin --platform managed --project abc-b13a0 --memory 256Mi --timeout 300 --concurrency 80 --max-instances 1000 --cpu 1 --clear-env-vars --clear-cloudsql-instances --client-name "Cloud Code for IntelliJ" --client-version 22.2.1-213 --region asia-northeast1 --allow-unauthenticated --clear-vpc-connector
Deploying container to Cloud Run service [abc-origin] in project [abc-b13a0] 

如果 IntelliJ 這樣做,它還會聲明一個奇怪的 skaffold 構建語句。 我想關注 IntelliJ 的一切。 我究竟應該如何運行命令? 我不能每次都依賴自動部署。


DOCKERFILE

FROM node:17-slim
WORKDIR /usr/src/app
COPY . .
COPY . ./
RUN npm install
RUN npm run build  
CMD ["npm","start"]

A.tar.gz 文件始終是文件的簡單存檔,非常類似於標准的 WinZip 文件。 一般的UNIX世界里,a.tgz文件其實和a.tar.gz文件是一樣的。 你可以自由切換這兩者的擴展名,而不影響文件的解壓。 有關更多信息,您可以參考鏈接

現在,來到部署問題,如文檔中所述,

To submit a build with local source source.tgz asynchronously:

gcloud builds submit "source.tgz" --tag=gcr.io/my-project/image --async

另外,看看這個Stackoverflow 案例

我意識到 GCP 提供的 Cloud Code 比在終端中使用命令可以解決的問題更具未來感。 (以各種方式更兼容)我認為 intellij、vscode 或 shell 編輯器是最佳選擇,目前沒有其他選擇。

- 添加

我剛剛檢查了 cloud shell editor cloud run deploy using cloud code。 而且它也不起作用(不能像我在這個問題中說的那樣執行某些程序)我是從雲源存儲庫中克隆的,所以它是相同的代碼。 (我檢查了)

究竟是什么讓 IntelliJ 雲代碼與眾不同? 我想知道

為什么只有這個有效..


暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM