首页 > 解决方案 > dockerize express gatsby 应用程序的正确方法是什么?

问题描述

问题:我有一个 express-gatsby 应用程序,我需要使用 github 操作构建和部署,据我了解,我需要将我的应用程序容器化以便将其推送到 Heroku。为此,我创建了一个 Dockerfile,但要构建一个映像,我需要为我的 express 和 gatsby 应用程序安装 npm 包,然后进行构建。

当我运行 docker build 时,它会卡在 npm run install 上。对此的任何帮助将不胜感激。

docker build 的截图

包.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"]

标签: typescriptexpressdockerfilegatsby

解决方案


I'd say you want to install npm packages inside client:

"install": "npm install && cd /client && npm install"

Missing npm in there...


推荐阅读