Difference between revisions of "Creating Custom Docker Images"
Jump to navigation
Jump to search
(5 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
<pre> | <pre> | ||
FROM nodered/node-red | FROM nodered/node-red | ||
USER root | |||
RUN addgroup node-red dialout | |||
USER node-red | |||
# Copy package.json to the WORKDIR so npm builds all | # Copy package.json to the WORKDIR so npm builds all | ||
Line 17: | Line 21: | ||
COPY package.json . | COPY package.json . | ||
RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production | RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production | ||
RUN npm rebuild --build-from-source | |||
# Copy _your_ Node-RED project files into place | # Copy _your_ Node-RED project files into place | ||
Line 39: | Line 44: | ||
"version": "0.0.1", | "version": "0.0.1", | ||
"dependencies": { | "dependencies": { | ||
"node-red": "latest", | |||
"node-red-dashboard": "3.1.7" | |||
"node-red-node-serialport": "latest" | |||
}, | }, | ||
"scripts": { | |||
"start": "node /usr/src/node-red/node_modules/node-red/red.js" | "start": "node /usr/src/node-red/node_modules/node-red/red.js" | ||
} | |||
} | } | ||
</pre>In a command prompt, move to the directory where the files are located and run the following command to create image. | </pre> | ||
In a command prompt, move to the directory where the files are located and run the following command to create image. | |||
docker build -t zerocarboncontrol1:latest . | docker build -t zerocarboncontrol1:latest . | ||
Replace YOUR_DOCKERHUB_NAME with your Docker username. | |||
docker tag zerocarboncontrol1 YOUR_DOCKERHUB_NAME/zerocarboncontrol1 | |||
docker push YOUR_DOCKERHUB_NAME/zerocarboncontrol1:latest |
Latest revision as of 16:33, 24 September 2022
Creating a Custom Docker Image
Create a directory containing the following files:
Dockerfile
FROM nodered/node-red USER root RUN addgroup node-red dialout USER node-red # Copy package.json to the WORKDIR so npm builds all # of your added nodes modules for Node-RED COPY package.json . RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production RUN npm rebuild --build-from-source # Copy _your_ Node-RED project files into place # NOTE: This will only work if you DO NOT later mount /data as an external volume. # If you need to use an external volume for persistence then # copy your settings and flows files to that volume instead. #COPY settings.js /data/settings.js COPY flows_cred.json /data/flows_cred.json COPY flows.json /data/flows.json # You should add extra nodes via your package.json file but you can also add them here: #WORKDIR /usr/src/node-red #RUN npm install node-red-dashboard
package.json
{ "name": "zerocarboncontrol1", "description": "testing", "version": "0.0.1", "dependencies": { "node-red": "latest", "node-red-dashboard": "3.1.7" "node-red-node-serialport": "latest" }, "scripts": { "start": "node /usr/src/node-red/node_modules/node-red/red.js" } }
In a command prompt, move to the directory where the files are located and run the following command to create image.
docker build -t zerocarboncontrol1:latest .
Replace YOUR_DOCKERHUB_NAME with your Docker username.
docker tag zerocarboncontrol1 YOUR_DOCKERHUB_NAME/zerocarboncontrol1
docker push YOUR_DOCKERHUB_NAME/zerocarboncontrol1:latest