-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (39 loc) · 1.58 KB
/
Dockerfile
File metadata and controls
53 lines (39 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FROM node:alpine
RUN apk add --no-cache make gcc g++ python
RUN mkdir -p /usr/src/node-red /data \
&& addgroup node-red \
&& adduser -G node-red -h /usr/src/node-red -D -H node-red \
&& chown -R node-red:node-red /usr/src/node-red
USER node-red
# package.json contains Node-RED NPM module and node dependencies
# as well as whatever other nodes are to be installed
COPY package.json /usr/src/node-red/
RUN cd /usr/src/node-red \
&& npm install
##############################
### Build run-time container
FROM node:alpine
# Create home directory for Node-RED application source code. Also
# create user data directory to contain flows, config and nodes.
# Add node-red user so we aren't running as root
RUN mkdir -p /usr/src/node-red /data \
&& addgroup node-red \
&& adduser -G node-red -h /usr/src/node-red -D -H node-red
# Copy over needed pieces from first stage container
#COPY --from=0 /usr/bin/node* /usr/bin/
COPY --from=0 /usr/lib/libgcc* /usr/lib/libstdc* /usr/lib/
WORKDIR /usr/src/node-red
COPY --from=0 /usr/src/node-red/node_modules ./node_modules
COPY --from=0 /usr/src/node-red/package*json ./
COPY --from=0 /usr/src/node-red/.npm ./.npm
COPY --from=0 /usr/src/node-red/.node-gyp ./.node-gyp
COPY --from=0 /usr/src/node-red/.config ./.config
RUN chown -R node-red:node-red /data \
&& chown -R node-red:node-red /usr/src/node-red
# Switch to node-red user for the rest
USER node-red
EXPOSE 1880
# Set up environment variables
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules
CMD ["npm", "start", "--", "--userDir", "/data"]