【问题标题】:Deploy MEAN stack application部署 MEAN 堆栈应用程序
【发布时间】:2019-11-24 11:21:24
【问题描述】:

所以,我开发了一个 Web 应用程序(企业级),使用 Vue 作为前端,Node 作为后端,MongoDB 作为数据库。在开发阶段,我们使用独立的服务器来托管 Vuejs 应用和 Nodejs 应用。

这在生产级别听起来不太对劲。我的问题是,在单个服务器(前端是 Vue 或 Angular)上托管 MEAN 堆栈应用程序的最佳方式(最首选方式)是什么。我已经阅读了很多关于服务“dist”的内容使用快递服务器的文件夹。但这是一种解决方法还是合法的解决方案?

另外,我应该考虑使用 docker 还是 kubernetes? 应用引擎和 elb 超出了范围,因为它们不支持 MongoDB,而且 Atlas 非常昂贵。

【问题讨论】:

  • 有些地方可以部署你的意思是堆栈应用程序。您是在不同项目中的服务器和前端,还是一切合二为一? (张贴文件夹图片)

标签: node.js angular express vue.js


【解决方案1】:

我最近写了一篇关于deploying the frontend的帖子。

您可以轻松地使用两个用于测试和构建的 docker 容器,但您也可以只在服务器上安装 node.js。 Mongodb 可以很容易地依赖于 docker 或任何 Linux vps。你有 Linux 经验吗?

Docker 文件配方:

# Create the container from the alpine linux image
FROM alpine:3.7

# Add nginx and nodejs
RUN apk add --update nginx nodejs

# Create the directories we will need
RUN mkdir -p /tmp/nginx/vue-single-page-app
RUN mkdir -p /var/log/nginx
RUN mkdir -p /var/www/html

# Copy the respective nginx configuration files
COPY nginx_config/nginx.conf /etc/nginx/nginx.conf
COPY nginx_config/default.conf /etc/nginx/conf.d/default.conf

# Set the directory we want to run the next commands for
WORKDIR /tmp/nginx/vue-single-page-app
# Copy our source code into the container
COPY . .
# Install the dependencies, can be commented out if you're running the same node version
RUN npm install

# run webpack and the vue-loader
RUN npm run build

# copy the built app to our served directory
RUN cp -r dist/* /var/www/html

# make all files belong to the nginx user
RUN chown nginx:nginx /var/www/html

# start nginx and keep the process from backgrounding and the container from quitting
CMD ["nginx", "-g", "daemon off;"]

【讨论】:

    猜你喜欢
    • 2018-11-08
    • 2017-03-09
    • 2017-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-10
    • 1970-01-01
    相关资源
    最近更新 更多