forked from dappnode/DNP_DAPPMANAGER
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
94 lines (68 loc) · 2.71 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Common base so it's cached
# --platform=$BUILDPLATFORM is used build javascript source with host arch
# Otherwise webpack builds on emulated archs can be extremely slow (+1h)
#####################################
FROM --platform=${BUILDPLATFORM:-amd64} node:14.17.6-alpine as build-monorepo
WORKDIR /app
RUN apk add --no-cache python build-base bash
# Copy and install deps first to cache
COPY package.json yarn.lock lerna.json ./
COPY patches patches/
# Install lerna first
RUN yarn --frozen-lockfile --non-interactive --ignore-scripts --ignore-optional
COPY packages/admin-ui/package.json \
packages/admin-ui/yarn.lock \
packages/admin-ui/
COPY packages/dappmanager/package.json \
packages/dappmanager/yarn.lock \
packages/dappmanager/
RUN yarn bootstrap --production
# Build UI
WORKDIR /app/packages/admin-ui/
COPY packages/admin-ui/ .
ENV REACT_APP_API_URL /
RUN yarn build
# Results in build/*
WORKDIR /app/packages/dappmanager/
COPY packages/dappmanager/ .
RUN yarn build
# Results in build/index.js
# Compute git data
#####################################
FROM --platform=${BUILDPLATFORM:-amd64} node:14.17.6-alpine as git-data
WORKDIR /usr/src/app
RUN apk add --no-cache git
COPY .git .git
COPY dappnode_package.json .
COPY build/getGitData.js .
RUN node getGitData /usr/src/app/.git-data.json
# Build binaries
#####################################
FROM node:14.17.6-alpine as build-binaries
RUN apk add --no-cache bind-tools docker
# Final layer
#####################################
FROM node:14.17.6-alpine
ENV DOCKER_COMPOSE_VERSION 1.25.5
RUN apk add --no-cache curl bind-dev xz libltdl miniupnpc zip unzip dbus bind \
# See https://github.com/dappnode/DNP_DAPPMANAGER/issues/669
avahi-tools
RUN curl -L https://github.com/dappnode/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-Linux-$(uname -m) > /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
WORKDIR /usr/src/app
ENV COMPOSE_HTTP_TIMEOUT=300 \
DOCKER_CLIENT_TIMEOUT=300 \
DOCKER_HOST=unix:///var/run/docker.sock \
UI_FILES_PATH=dist \
GIT_DATA_PATH=.git-data.json
COPY --from=build-binaries /usr/bin/nsupdate /usr/bin/nsupdate
COPY --from=build-binaries /usr/bin/docker /usr/bin/docker
# Copy the src last as it's the layer most likely to change
COPY packages/dappmanager/hostScripts /usr/src/app/hostScripts
COPY packages/dappmanager/hostServices /usr/src/app/hostServices
COPY --from=build-monorepo /app/packages/admin-ui/build $UI_FILES_PATH
COPY --from=build-monorepo /app/packages/dappmanager/build /usr/src/app/
COPY --from=git-data /usr/src/app/.git-data.json $GIT_DATA_PATH
COPY build/rndc.conf /etc/bind/
COPY build/update_local_dyndns.sh /usr/local/bin/update_local_dyndns
CMD [ "node", "index" ]