简体   繁体   English

将带有 Docker 的 MERN 应用程序部署到 GCP App Engine 时出现问题 - 部署需要几个小时吗?

[英]Problem deploying MERN app with Docker to GCP App Engine - should deploy take multiple hours?

I am inexperienced with Dev Ops, which drew me to using Google App Engine to deploy my MERN application.我对 Dev Ops 缺乏经验,这促使我使用 Google App Engine 来部署我的 MERN 应用程序。 Currently, I have the following Dockerfile and entrypoint.sh :目前,我有以下Dockerfileentrypoint.sh

# Dockerfile
FROM node:13.12.0-alpine
WORKDIR /app
COPY . ./
RUN npm install --silent  
WORKDIR /app/client
RUN npm install --silent
WORKDIR /app
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT [ "/app/entrypoint.sh" ]
# Entrypoint.sh
#!/bin/sh
node /app/index.js &
cd /app/client
npm start

The React front end is in a client folder, which is located in the base directory of the Node application. React 前端位于client文件夹中,该文件夹位于 Node 应用程序的基本目录中。 I am attempting to deploy these together, and would generally prefer to deploy together rather than separate.我正在尝试将这些部署在一起,并且通常更喜欢一起部署而不是单独部署。 Running docker-compose up --build successfully redeploys my application on localhost.运行docker-compose up --build成功在本地主机上重新部署我的应用程序。

I have created a very simple app.yaml file which is needed for Google App Engine:我创建了一个非常简单的app.yaml文件,这是 Google App Engine 所需的:

# app.yaml
runtime: custom
env: standard

I read in the docs here to use runtime: custom when using a Dockerfile to configure the runtime environment.我在此处阅读文档以使用runtime: custom使用 Dockerfile 配置运行时环境时的自定义。 I initially selected a standard environment over a flexible environment, and so I've added env: standard as the other line in the app.yaml .我最初选择了标准环境而不是灵活环境,因此我添加了env: standard作为app.yaml中的另一行。

After installing and running gcloud app deploy , things kicked off, however for the last several hours this is what I've seen in my terminal window:在安装并运行gcloud app deploy之后,事情就开始了,但是在过去的几个小时里,这是我在终端 window 中看到的:

在此处输入图像描述

Hours seems like a higher magnitude of time than what seems right for deploying an application, and I've begun to think that I've done something wrong.小时似乎比部署应用程序的正确时间要长,我开始认为我做错了什么。

You are probably uploading more files than you need.您上传的文件可能比您需要的多。

Use .gcloudignore file to describe the files/folders that you do not want to upload.使用.gcloudignore文件来描述您不想上传的文件/文件夹。 LINK关联

You may need to change the file structure of your current project.您可能需要更改当前项目的文件结构。

Additionally, it might be worth researching further the use of theStandard nodejs10 runtime .此外,可能值得进一步研究标准 nodejs10 运行时的使用。 It uploads and starts much faster than the Flexible alternative (custom env is part of App Engine Flex).它的上传和启动速度比灵活的替代方案快得多(自定义环境是 App Engine Flex 的一部分)。 Then you can deploy each part to a different service .然后,您可以将每个部分部署到不同的服务

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

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