I'm new to docker and I've been trying to create a custom node-red image with custom flow for influxdb. Docker doesn't seem to use my dockerfile for the image creation.
This is my docker-compose:
node-red:
container_name: node-red
build: node-red
environment:
- TZ=Europe/Amsterdam
ports:
- "1880:1880"
volumes:
- node-red-data:/tmp/node-red_data
networks:
- node-red-net
Then, inside a folder called node-red I have this dockerfile:
FROM nodered/node-red AS base
COPY package.json .
RUN npm install --only=production
COPY nodered_flow.json /data/flows.json
CMD ["npm", "start"]
Both the package.json and the nodered_flow.json are in the same folder as the dockerfile. What am I doing wrong here?
CodePudding user response:
In service.build
, you need the path to the build context, in case the it is in the same directory you could use .
. So this should work:
node-red:
container_name: node-red
build: .
environment:
- TZ=Europe/Amsterdam
ports:
- "1880:1880"
volumes:
- node-red-data:/tmp/node-red_data
networks:
- node-red-net
For more information check: https://docs.docker.com/compose/compose-file/compose-file-v3/#build
CodePudding user response:
Your Dockerfile is wrong, it's putting your package.json
in /usr/src/node-red
and when you run npm install
it will remove Node-RED.
It should look like this:
FROM nodered/node-red AS base
WORKDIR /data
COPY package.json /data
COPY nodered_flow.json /data/flows.json
RUN npm install --only=production
WORKDIR /usr/src/node-red