我使用了gatsby-cli给出的典型gatsby init。而且,我想使用 docker 进一步实现自动化。
.
|- src
|- gatsby-*.js
|- node_modules
|- Dockerfile
|- docker-compose.yml
|- package*.json
|- public
这是我的 Dockerfile:
FROM node:12
# Add the package.json file and build the node_modules folder
WORKDIR /app
COPY ./package*.json ./
RUN mkdir node_modules && npm install
RUN npm install --global gatsby-cli && gatsby telemetry --disable
这是我的码头工人-compose.yml
version: '3.7'
services:
gatsby:
build:
context: .
dockerfile: Dockerfile
working_dir: /app
command: gatsby develop -H 0.0.0.0
ports:
- "8000:8000"
volumes:
- .:/app
- /app/node_modules/
问题是,每当我在本地更改任何内容并且我通过进入容器内部来验证这一点以确保将更改复制到容器时,更改都不会触发构建。
我在访问本地主机中暴露的端口时没有问题。我做错了什么?我已经验证了构建确实运行,但只运行一次。在构建过程中没有错误的迹象,只有来自 npm 安装的 WARN 内容,当我在本地安装时也是如此。
我想我没有正确使用谷歌关键字。如果我只使用这个词,重新编译而不是重建。
https://github.com/gatsbyjs/gatsby/issues/10836
这使它对我有用。