typescript - dockerize express gatsby 应用程序的正确方法是什么?
问题描述
问题:我有一个 express-gatsby 应用程序,我需要使用 github 操作构建和部署,据我了解,我需要将我的应用程序容器化以便将其推送到 Heroku。为此,我创建了一个 Dockerfile,但要构建一个映像,我需要为我的 express 和 gatsby 应用程序安装 npm 包,然后进行构建。
当我运行 docker build 时,它会卡在 npm run install 上。对此的任何帮助将不胜感激。
包.json
"scripts": {
"install": "npm install && cd /client && install",
"build": "cd client/ && npm run build && cd .. && node ./util/build.js",
"lint": "tslint --project \"tsconfig.json\"",
"start": "node -r module-alias/register ./dist",
"start:dev": "nodemon --config nodemon.json",
"test": "nodemon --config nodemon.test.json"
},
Dockerfile
FROM node:10-slim
WORKDIR /usr/src/app
RUN npm install -g gatsby-cli
COPY / ./
RUN npm run install
RUN npm run build
EXPOSE 8081
ENV NODE_ENV=production
ENV PORT=8081
RUN ls
CMD ["npm", "run", "start"]
解决方案
I'd say you want to install npm packages inside client:
"install": "npm install && cd /client && npm install"
Missing npm
in there...
推荐阅读
- android - Android Things 和 Google 日历 API
- redux - 在组件(小部件)中获取有关相应 redux 存储状态更新的数据
- c - 有一个没有值的 switch 语句 case 标签
- java - 为 Jackson 激活 RestTemplate 和 Spring MVC 的 JAXB 模块
- javascript - Rails 5 Seclect2 Acts_as_taggable 在第一个产品上填充标签名称,然后将 id 设置为所有其他产品上的名称
- wordpress - 无法在页面上显示自定义帖子类型类别
- laravel - 如何在引号内使用 vue 数组?
- php - 通过链接传递值并在 php 中使用它
- machine-learning - Flask Web 应用程序中的机器学习模型错误
- javascript - PHP & JS - 连接、错误消息和重定向