繁体   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