首页 > 解决方案 > 无法在 Google Run 上部署 angular-app

问题描述

用于在 Google Run 上部署应用程序。我创建了具有以下内容的 Dockerfile:

### STAGE 1: Build ###
FROM node:latest AS build
WORKDIR  /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build

### STAGE 2: Run ###
FROM nginx:1.19.9-alpine
COPY --from=build  /app/dist/aistudio /usr/share/nginx/html

线上出现的问题RUN npm run build。控制台上显示的日志是:

=> ERROR [build 4/6] RUN npm install                                                                                                       352.3s 
------
 > [build 4/6] RUN npm install:
#12 350.8 npm notice
#12 350.8 npm notice New minor version of npm available! 7.7.6 -> 7.8.0
#12 350.8 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.8.0>
#12 350.8 npm notice Run `npm install -g npm@7.8.0` to update!
#12 350.8 npm notice
#12 350.8 npm ERR! code ECONNRESET
#12 350.9 npm ERR! network aborted
#12 350.9 npm ERR! network This is a problem related to network connectivity.
#12 350.9 npm ERR! network In most cases you are behind a proxy or have bad network settings.
#12 350.9 npm ERR! network
#12 350.9 npm ERR! network If you are behind a proxy, please make sure that the
#12 350.9 npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
#12 351.3
#12 351.3 npm ERR! A complete log of this run can be found in:
#12 351.3 npm ERR!     /root/.npm/_logs/2021-04-04T08_36_13_047Z-debug.log
------
executor failed running [/bin/sh -c npm install]: exit code: 1

任何帮助,将不胜感激。这样我就可以成功构建 Angular docker 映像,然后将其部署在 Google Run 上。谢谢

已编辑

当我有下面给出的简单 Dockerfile 时,docker 映像构建并成功运行。

FROM nginx:alpine
COPY /dist/aistudio /usr/share/nginx/html

在上述情况下,前两个屏幕已正确加载,但距离 screen3 更远,我有异常 在此处输入图像描述

标签: angularnpmgoogle-cloud-platformdockerfiledevops

解决方案


推荐阅读