Google cloud platform 无法在gcp云运行上承载angular 7应用程序
我已经构建了Angular 7应用程序,当我使用docker从本地机器运行ng serve命令时,该应用程序可以正常工作。 这是一个没有数据库的简单hello world angular应用程序 当我试图在GCP云上运行我的应用程序时。它给了我端口错误 云运行时出错: 无法在端口环境变量定义的端口上启动并侦听 这是我的docker文件Google cloud platform 无法在gcp云运行上承载angular 7应用程序,google-cloud-platform,dockerfile,angular7,google-cloud-run,Google Cloud Platform,Dockerfile,Angular7,Google Cloud Run,我已经构建了Angular 7应用程序,当我使用docker从本地机器运行ng serve命令时,该应用程序可以正常工作。 这是一个没有数据库的简单hello world angular应用程序 当我试图在GCP云上运行我的应用程序时。它给了我端口错误 云运行时出错: 无法在端口环境变量定义的端口上启动并侦听 这是我的docker文件 FROM node:latest as node # set working directory WORKDIR /app COP
FROM node:latest as node
# set working directory
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod
FROM nginx:alpine
COPY --from=node /app/dist/test-case-builder usr/share/nginx/html
CMD ng serve --host 0.0.0.0
您需要侦听port env变量中定义的端口。因此,在Dockerfile中:
您需要侦听port env变量中定义的端口。因此,在Dockerfile中:
我刚刚在Google Cloud Run上发布了主机Angular8应用程序我刚刚在Google Cloud Run上发布了主机Angular8应用程序
FROM node:latest as node
# set working directory
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod
FROM nginx:alpine
COPY --from=node /app/dist/test-case-builder usr/share/nginx/html
CMD ng serve --host 0.0.0.0
CMD ng serve --host 0.0.0.0 --port $PORT