-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathDockerfile
77 lines (56 loc) · 1.89 KB
/
Dockerfile
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
ARG image=zwave-js-ui
FROM alpine:3.18.4 as base
RUN apk add --no-cache \
openssl \
libusb \
tzdata \
eudev \
nodejs=18.18.2-r0
WORKDIR /usr/src/app
# STEP: 1 build
FROM base AS build-zui
RUN \
apk add --no-cache --virtual .build-dependencies \
jq \
build-base \
linux-headers \
python3-dev \
npm=9.6.6-r0
COPY . .
# if node_modules does not exist, install deps, if dist is missing, install also dev deps
RUN [ -d 'node_modules' ] && echo "Skipping install" || npm install $([ -d 'dist' ] && echo '--omit=dev' || echo '')
# Fix issue with serialport bindings #2349
RUN npm_config_build_from_source=true npm rebuild @serialport/bindings-cpp
# Build back and frontend only when not existing
RUN [ -d 'dist' ] && echo "Skipping build" || npm run build
RUN npm prune --omit=dev && \
find . -mindepth 1 -maxdepth 1 \
! -name "node_modules" \
! -name "snippets" \
! -name ".git" \
! -name "package.json" \
! -name "server" \
! -name "dist" \
-exec rm -rf {} +
# add plugin support, space separated
ARG plugins
RUN if [ ! -z "$plugins" ]; \
then echo "Installing plugins ${plugins}"; npm install ${plugins} ; fi
# when update devices arg is set update config files from zwavejs repo
ARG updateDevices
ARG zwavejs=https://github.com/zwave-js/node-zwave-js/archive/master.tar.gz
RUN if [ ! -z "$updateDevices" ]; \
then curl -sL ${zwavejs} | \
tar vxz --strip=5 -C ./node_modules/@zwave-js/config/config/devices \
node-zwave-js-master/packages/config/config/devices/ ;\
fi
RUN apk del --no-cache --purge .build-dependencies
# STEP: 2 (runtime)
FROM base AS runtime
# Copy files from previous build stage
COPY --from=build-zui /usr/src/app /usr/src/app
ENV ZWAVEJS_EXTERNAL_CONFIG=/usr/src/app/store/.config-db
ENV TAG_NAME=${image_name}
ENV NODE_ENV=production
EXPOSE 8091
CMD ["node", "server/bin/www"]