1
- FROM golang:1.15.5-alpine as builder
2
-
3
- # Force Go to use the cgo based DNS resolver. This is required to ensure DNS
4
- # queries required to connect to linked containers succeed.
5
- ENV GODEBUG netdns=cgo
1
+ # Start with a NodeJS base image that also contains yarn.
2
+ FROM node:12.17.0-alpine as nodejsbuilder
6
3
7
4
# Pass a tag, branch or a commit using build-arg. This allows a docker image to
8
5
# be built from a specified Git state. The default image will use the Git tip of
9
6
# master by default.
10
7
ARG checkout="master"
11
8
12
- # Explicitly turn on the use of modules (until this becomes the default).
13
- ENV GO111MODULE on
9
+ # There seem to be multiple problems when using yarn for a build inside of a
10
+ # docker image:
11
+ # 1. For building and installing node-gyp, python is required. This seems to
12
+ # be missing from the NodeJS base image for ARM builds (or is just required
13
+ # when building for ARM?).
14
+ # 2. Because of a problem in the docker internal network on ARM, some TCP
15
+ # packages are being dropped and the yarn installation times out. This can
16
+ # be mitigated by switching to HTTP and increasing the network timeout.
17
+ # See https://github.com/yarnpkg/yarn/issues/5259 for more info.
18
+ RUN apk add --no-cache --update alpine-sdk \
19
+ python \
20
+ git \
21
+ && git clone https://github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal \
22
+ && cd /go/src/github.com/lightninglabs/lightning-terminal \
23
+ && git checkout $checkout \
24
+ && cd app \
25
+ && npm config set registry "http://registry.npmjs.org" \
26
+ && yarn config set registry "http://registry.npmjs.org" \
27
+ && yarn install --frozen-lockfile --network-timeout 1000000 \
28
+ && yarn build
14
29
15
- ENV NODE_VERSION=v12.17.0
30
+ # The first stage is already done and all static assets should now be generated
31
+ # in the app/build sub directory.
32
+ FROM golang:1.15.5-alpine as golangbuilder
16
33
17
- # We need some additional proto files with google annotations, the version
18
- # should match what's in lnd's scripts/install_travis_proto.sh
19
- ENV PROTOC_VERSION=3.4.0
20
- ENV PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
34
+ # Instead of checking out from git again, we just copy the whole working
35
+ # directory of the previous stage that includes the generated static assets.
36
+ COPY --from=nodejsbuilder /go/src/github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal
37
+
38
+ # Force Go to use the cgo based DNS resolver. This is required to ensure DNS
39
+ # queries required to connect to linked containers succeed.
40
+ ENV GODEBUG netdns=cgo
41
+
42
+ # Explicitly turn on the use of modules (until this becomes the default).
43
+ ENV GO111MODULE on
21
44
22
45
# Install dependencies and install/build lightning-terminal.
23
46
RUN apk add --no-cache --update alpine-sdk \
24
- git \
25
47
make \
26
- curl \
27
- bash \
28
- binutils \
29
- tar \
30
- protobuf-dev \
31
- zip \
32
- && curl -sfSLO ${PROTOC_URL} \
33
- && unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local \
34
- && rm /usr/local/bin/protoc /usr/local/readme.txt \
35
- && touch ~/.bashrc \
36
- && curl -sfSLO https://unofficial-builds.nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64-musl.tar.xz \
37
- && tar -xf node-${NODE_VERSION}-linux-x64-musl.tar.xz -C /usr --strip 1 \
38
- && rm node-${NODE_VERSION}-linux-x64-musl.tar.xz \
39
- && curl -o- -L https://yarnpkg.com/install.sh | bash \
40
- && . ~/.bashrc \
41
- && git clone https://github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal \
42
- && cd /go/src/github.com/lightninglabs/lightning-terminal \
43
- && git checkout $checkout \
44
- && make install \
45
- && make go-install-cli
48
+ && cd /go/src/github.com/lightninglabs/lightning-terminal \
49
+ && make statik-only \
50
+ && make go-install \
51
+ && make go-install-cli
46
52
47
53
# Start a new, final image to reduce size.
48
54
FROM alpine as final
@@ -54,11 +60,11 @@ VOLUME /root/.lnd
54
60
EXPOSE 8443 10009 9735
55
61
56
62
# Copy the binaries and entrypoint from the builder image.
57
- COPY --from=builder /go/bin/litd /bin/
58
- COPY --from=builder /go/bin/lncli /bin/
59
- COPY --from=builder /go/bin/frcli /bin/
60
- COPY --from=builder /go/bin/loop /bin/
61
- COPY --from=builder /go/bin/pool /bin/
63
+ COPY --from=golangbuilder /go/bin/litd /bin/
64
+ COPY --from=golangbuilder /go/bin/lncli /bin/
65
+ COPY --from=golangbuilder /go/bin/frcli /bin/
66
+ COPY --from=golangbuilder /go/bin/loop /bin/
67
+ COPY --from=golangbuilder /go/bin/pool /bin/
62
68
63
69
# Add bash.
64
70
RUN apk add --no-cache \
0 commit comments