繁体   English   中英

Google Cloud Run - Docker building container building but not accessible

[英]Google Cloud Run - Docker building container building but not accessible

GCR 的新手。 我已经从我的回购协议中设置了持续部署。 图像构建得很好,没有任何错误记录到 GCR 控制台,我得到了一个通过的构建。 但是当我尝试通过他们的 URL 链接在线查看我的活动容器时,它说构建失败。 对我应该做什么完全感到困惑? 谁能帮帮我,下面是我的 dockerfile。 据我所知,该文件按预期工作。 但我仍然是一个菜鸟。

云构建日志:

   starting build "3e8d7c0f-57ca-4a9f-b30d-d49d364ab286"

    FETCHSOURCE
    hint: Using 'master' as the name for the initial branch. This default branch name
    hint: is subject to change. To configure the initial branch name to use in all
    hint: of your new repositories, which will suppress this warning, call:
    hint: 
    hint:   git config --global init.defaultBranch <name>
    hint: 
    hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
    hint: 'development'. The just-created branch can be renamed via this command:
    hint: 
    hint:   git branch -m <name>
    Initialized empty Git repository in /workspace/.git/
    From https://source.developers.google.com/p/swift-media-322516/r/github_lewismorgans_portfolio
     * branch            79c27520b788b3631ca0eece3a6107502df402ed -> FETCH_HEAD
    HEAD is now at 79c2752 change exposed port
    BUILD
    Already have image (with digest): gcr.io/cloud-builders/docker
    Sending build context to Docker daemon  40.43MB

    Step 1/10 : FROM node:10-alpine as build-step
    10-alpine: Pulling from library/node
    ddad3d7c1e96: Pulling fs layer
    de915e575d22: Pulling fs layer
    7150aa69525b: Pulling fs layer
    d7aa47be044e: Pulling fs layer
    d7aa47be044e: Waiting
    ddad3d7c1e96: Verifying Checksum
    ddad3d7c1e96: Download complete
    7150aa69525b: Verifying Checksum
    7150aa69525b: Download complete
    d7aa47be044e: Verifying Checksum
    d7aa47be044e: Download complete
    de915e575d22: Verifying Checksum
    de915e575d22: Download complete
    ddad3d7c1e96: Pull complete
    de915e575d22: Pull complete
    7150aa69525b: Pull complete
    d7aa47be044e: Pull complete
    Digest: sha256:dc98dac24efd4254f75976c40bce46944697a110d06ce7fa47e7268470cf2e28
    Status: Downloaded newer image for node:10-alpine
     ---> aa67ba258e18
    Step 2/10 : RUN mkdir -p /app
     ---> Running in 646a1564cb80
    Removing intermediate container 646a1564cb80
     ---> 67294f6ec083
    Step 3/10 : WORKDIR /app
     ---> Running in 199afd3b91f1
    Removing intermediate container 199afd3b91f1
     ---> 089af75a6a2b
    Step 4/10 : COPY package.json /app
     ---> e857fe951ed0
    Step 5/10 : RUN npm install
     ---> Running in d9ad09cd2206
    [91mnpm[0m[91m [0m[91mWARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
    [0m[91mnpm[0m[91m [0m[91mWARN[0m[91m [0m[91mdeprecated[0m[91m ini@1.3.5: Please update to ini >=1.3.6 to avoid a prototype pollution issue
    [0m[91mnpm[0m[91m [0m[91mWARN[0m[91m [0m[91mdeprecated[0m[91m uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
    [0m[91mnpm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
    [0m[91mnpm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
    [0m[91mnpm[0m[91m WARN[0m[91m [0m[91mdeprecated har-validator@5.1.5: this library is no longer supported
    [0m[91mnpm [0m[91mWARN[0m[91m deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
    [0m[91mnpm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
    [0m[91mnpm [0m[91mWARN [0m[91mdeprecated[0m[91m urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
    [0m[91mnpm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
    [0m
    > core-js@3.6.4 postinstall /app/node_modules/@angular-devkit/build-angular/node_modules/core-js
    > node -e "try{require('./postinstall')}catch(e){}"

    [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m

    [96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
    [96m>[94m https://opencollective.com/core-js [0m
    [96m>[94m https://www.patreon.com/zloirock [0m

    [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m


    > @fortawesome/fontawesome-common-types@0.2.36 postinstall /app/node_modules/@fortawesome/fontawesome-common-types
    > node attribution.js

    Font Awesome Free 0.2.36 by @fontawesome - https://fontawesome.com
    License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


    > core-js@3.16.2 postinstall /app/node_modules/@syncfusion/ej2-angular-base/node_modules/core-js
    > node -e "try{require('./postinstall')}catch(e){}"

    [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m

    [96mThe project needs your help! Please consider supporting of core-js:[0m
    [96m>[94m https://opencollective.com/core-js [0m
    [96m>[94m https://patreon.com/zloirock [0m
    [96m>[94m https://paypal.me/zloirock [0m
    [96m>[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz [0m

    [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m


    > @angular/cli@9.0.7 postinstall /app/node_modules/@angular/cli
    > node ./bin/postinstall/script.js


    > @fortawesome/fontawesome-free@5.15.4 postinstall /app/node_modules/@fortawesome/fontawesome-free
    > node attribution.js

    Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
    License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


    > @fortawesome/fontawesome-svg-core@1.2.36 postinstall /app/node_modules/@fortawesome/fontawesome-svg-core
    > node attribution.js

    Font Awesome Free 1.2.36 by @fontawesome - https://fontawesome.com
    License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


    > @fortawesome/free-solid-svg-icons@5.15.4 postinstall /app/node_modules/@fortawesome/free-solid-svg-icons
    > node attribution.js

    Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
    License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


    > core-js@2.6.12 postinstall /app/node_modules/core-js
    > node -e "try{require('./postinstall')}catch(e){}"

    [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m

    [96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
    [96m>[94m https://opencollective.com/core-js [0m
    [96m>[94m https://www.patreon.com/zloirock [0m

    [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m

    [91mnpm WARN lifecycle portfolio@0.0.0~postinstall: cannot run in wd portfolio@0.0.0 ng build --prod --aot=false --build-optimizer=false (wd=/app)
    [0m[91mnpm notice created a lockfile as package-lock.json. You should commit this file.
    [0m[91mnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
    npm WARN [0m[91mnotsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    [0m[91mnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup[0m[91m SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    [0m[91mnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup[0m[91m SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    [0m[91mnpm WARN[0m[91m @angular/flex-layout@9.0.0-beta.31 requires a peer of @angular/core@>=9.1.5 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @angular/flex-layout@9.0.0-beta.31 requires a peer of @angular/common@>=9.1.5 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @angular/flex-layout@9.0.0-beta.31 requires a peer of @angular/platform-browser@>=9.1.5 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN bootstrap@4.6.0 requires a peer of popper.js@^1.16.1 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN ng-circle-progress@1.6.0 requires a peer of @angular/common@>=9.1.0 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN ng-circle-progress@1.6.0 requires a peer of @angular/core@>=9.1.0 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @syncfusion/ej2-angular-base@17.4.55 requires a peer of @angular/common@4.10.0 - 9.0.2 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @syncfusion/ej2-angular-base@17.4.55 requires a peer of @angular/compiler@4.10.0 - 9.0.2 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @syncfusion/ej2-angular-base@17.4.55 requires a peer of @angular/core@4.10.0 - 9.0.2 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @syncfusion/ej2-angular-base@17.4.55 requires a peer of @angular/forms@4.10.0 - 9.0.2 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @syncfusion/ej2-angular-base@17.4.55 requires a peer of @angular/platform-browser@4.10.0 - 9.0.2 but none is installed. You must install peer dependencies yourself.
    [0m[91mnpm WARN @syncfusion/ej2-angular-base@17.4.55 requires a peer of @angular/platform-browser-dynamic@4.10.0 - 9.0.2 but none is installed. You must install peer dependencies yourself.
    [0m[91m
    [0madded 1426 packages from 1188 contributors and audited 1431 packages in 58.941s

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

    found 51 vulnerabilities (6 low, 39 moderate, 5 high, 1 critical)
      run `npm audit fix` to fix them, or `npm audit` for details
    Removing intermediate container d9ad09cd2206
     ---> 72cf28fa5a7c
    Step 6/10 : COPY . /app
     ---> 034e3b8864cb
    Step 7/10 : RUN npm run build --prod
     ---> Running in 6df23cb16fa5

    > portfolio@0.0.0 build /app
    > ng build --prod --aot=false --build-optimizer=false

    [91m
    Compiling @angular/core : es2015 as esm2015
    [0m[91m
    Compiling @angular/common : es2015 as esm2015
    [0m[91m
    Compiling @angular/platform-browser : es2015 as esm2015
    [0m[91m
    Compiling @angular/platform-browser-dynamic : es2015 as esm2015
    [0m[91m
    Compiling @angular/flex-layout/core : es2015 as esm2015
    [0m[91m
    Compiling @angular/flex-layout/extended : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/bidi : es2015 as esm2015
    [0m[91m
    Compiling @angular/flex-layout/flex : es2015 as esm2015
    [0m[91m
    Compiling @angular/flex-layout/grid : es2015 as esm2015
    [0m[91m
    Compiling @angular/flex-layout : es2015 as esm2015
    [0m[91m
    Compiling @angular/forms : es2015 as esm2015
    [0m[91m
    Compiling @angular/common/http : es2015 as esm2015
    [0m[91m
    Compiling ng-circle-progress : es2015 as esm2015
    [0m[91m
    Compiling @kolkov/angular-editor : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/platform : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/collections : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/scrolling : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/portal : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/keycodes : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/overlay : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/observers : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/a11y : es2015 as esm2015
    [0m[91m
    Compiling @angular/animations : es2015 as esm2015
    [0m[91m
    Compiling @angular/animations/browser : es2015 as esm2015
    [0m[91m
    Compiling @angular/platform-browser/animations : es2015 as esm2015
    [0m[91m
    Compiling @angular/material/core : es2015 as esm2015
    [0m[91m
    Compiling @angular/material/button : es2015 as esm2015
    [0m[91m
    Compiling @angular/cdk/layout : es2015 as esm2015
    [0m[91m
    Compiling @angular/material/snack-bar : es2015 as esm2015
    [0m[91m
    Compiling @fortawesome/angular-fontawesome : es2015 as esm2015
    [0mGenerating ES5 bundles for differential loading...
    ES5 bundle generation complete.

    chunk {0} runtime-es2015.8bae5995e99ee7582e6c.js (runtime) 1.46 kB [entry] [rendered]
    chunk {0} runtime-es5.8bae5995e99ee7582e6c.js (runtime) 1.46 kB [entry] [rendered]
    chunk {1} main-es2015.dc6fe7e8995cc1772a16.js (main) 1.35 MB [initial] [rendered]
    chunk {1} main-es5.dc6fe7e8995cc1772a16.js (main) 1.4 MB [initial] [rendered]
    chunk {2} polyfills-es2015.a4660fc436b698b2ca29.js (polyfills) 61.3 kB [initial] [rendered]
    chunk {3} polyfills-es5.6b5ee25874ec64f1745e.js (polyfills-es5) 136 kB [initial] [rendered]
    chunk {4} styles.365c7f153c5be2a5f7d1.css (styles) 205 kB [initial] [rendered]
    chunk {scripts} scripts.b11bb42cb75a53297f18.js (scripts) 104 kB [entry] [rendered]
    Date: 2021-08-19T12:35:49.946Z - Hash: dd3cb71f17750c7a2cea - Time: 313326ms
    Removing intermediate container 6df23cb16fa5
     ---> d4a281a3f947
    Step 8/10 : FROM nginx:1.17.1-alpine
    1.17.1-alpine: Pulling from library/nginx
    e7c96db7181b: Already exists
    3fb6217217ef: Pulling fs layer
    3fb6217217ef: Verifying Checksum
    3fb6217217ef: Download complete
    3fb6217217ef: Pull complete
    Digest: sha256:17bd1698318e9c0f9ba2c5ed49f53d690684dab7fe3e8019b855c352528d57be
    Status: Downloaded newer image for nginx:1.17.1-alpine
     ---> ea1193fd3dde
    Step 9/10 : COPY --from=build-step /app/dist/swift-media /usr/share/nginx/html
     ---> 85b317d701b2
    Step 10/10 : EXPOSE 80
     ---> Running in 643de67acbe8
    Removing intermediate container 643de67acbe8
     ---> 355605b29dc5
    Successfully built 355605b29dc5
    Successfully tagged gcr.io/swift-media-322516/github.com/lewismorgans/portfolio:79c27520b788b3631ca0eece3a6107502df402ed
    PUSH
    Pushing gcr.io/swift-media-322516/github.com/lewismorgans/portfolio:79c27520b788b3631ca0eece3a6107502df402ed
    The push refers to repository [gcr.io/swift-media-322516/github.com/lewismorgans/portfolio]
    57057b8da8c4: Preparing
    fbe0fc9bcf95: Preparing
    f1b5933fe4b5: Preparing
    f1b5933fe4b5: Layer already exists
    fbe0fc9bcf95: Layer already exists
    57057b8da8c4: Pushed
    79c27520b788b3631ca0eece3a6107502df402ed: digest: sha256:480416113eff892f18ecd86706bd7ccfdd36fdf8d132c2b32aa4541b03e52ddc size: 951
    DONE

Dockerfile:

RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN npm run build --prod
FROM nginx:1.17.1-alpine
COPY --from=build-step /app/dist/swift-media /usr/share/nginx/html
EXPOSE 80```

正如@John Hanley所提到的。 构建没有问题,这就是日志中没有错误的原因。 问题出在您制作的容器内部。 您可以使用 Google 文档中的快速入门作为示例。 在那里你可以看到你的 Dockerfile 缺少一些参数。

它应该是这样的:

RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN npm run build --prod
FROM nginx:1.17.1-alpine
COPY --from=build-step /app/dist/swift-media /usr/share/nginx/html
EXPOSE 80```
CMD [ "node", "index.js" ]

如果您是一个完全的菜鸟,我建议您查看提到的快速入门,并查看可用于习惯 Cloud Run 的其他代码示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM