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
63
74# Pass a tag, branch or a commit using build-arg. This allows a docker image to
85# be built from a specified Git state. The default image will use the Git tip of
96# master by default.
107ARG checkout="master"
118
9+ RUN apk add --no-cache --update alpine-sdk \
10+ git \
11+ && git clone https://github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal \
12+ && cd /go/src/github.com/lightninglabs/lightning-terminal \
13+ && git checkout $checkout \
14+ && cd app \
15+ && yarn install \
16+ && yarn build
17+
18+ # The first stage is already done and all static assets should now be generated
19+ # in the app/build sub directory.
20+ FROM golang:1.15.5-alpine as golangbuilder
21+
22+ # Instead of checking out from git again, we just copy the whole working
23+ # directory of the previous stage that includes the generated static assets.
24+ COPY --from=nodejsbuilder /go/src/github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal
25+
26+ # Force Go to use the cgo based DNS resolver. This is required to ensure DNS
27+ # queries required to connect to linked containers succeed.
28+ ENV GODEBUG netdns=cgo
29+
1230# Explicitly turn on the use of modules (until this becomes the default).
1331ENV GO111MODULE on
1432
15- ENV NODE_VERSION=v12.17.0
16-
1733# Install dependencies and install/build lightning-terminal.
1834RUN apk add --no-cache --update alpine-sdk \
19- git \
2035 make \
21- curl \
22- bash \
23- binutils \
24- tar \
25- && touch ~/.bashrc \
26- && curl -sfSLO https://unofficial-builds.nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64-musl.tar.xz \
27- && tar -xf node-${NODE_VERSION}-linux-x64-musl.tar.xz -C /usr --strip 1 \
28- && rm node-${NODE_VERSION}-linux-x64-musl.tar.xz \
29- && curl -o- -L https://yarnpkg.com/install.sh | bash \
30- && . ~/.bashrc \
31- && git clone https://github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal \
32- && cd /go/src/github.com/lightninglabs/lightning-terminal \
33- && git checkout $checkout \
34- && make install \
35- && make go-install-cli
36+ && cd /go/src/github.com/lightninglabs/lightning-terminal \
37+ && make statik-only \
38+ && make go-install \
39+ && make go-install-cli
3640
3741# Start a new, final image to reduce size.
3842FROM alpine as final
@@ -44,11 +48,11 @@ VOLUME /root/.lnd
4448EXPOSE 8443 10009 9735
4549
4650# Copy the binaries and entrypoint from the builder image.
47- COPY --from=builder /go/bin/litd /bin/
48- COPY --from=builder /go/bin/lncli /bin/
49- COPY --from=builder /go/bin/frcli /bin/
50- COPY --from=builder /go/bin/loop /bin/
51- COPY --from=builder /go/bin/pool /bin/
51+ COPY --from=golangbuilder /go/bin/litd /bin/
52+ COPY --from=golangbuilder /go/bin/lncli /bin/
53+ COPY --from=golangbuilder /go/bin/frcli /bin/
54+ COPY --from=golangbuilder /go/bin/loop /bin/
55+ COPY --from=golangbuilder /go/bin/pool /bin/
5256
5357# Add bash.
5458RUN apk add --no-cache \
0 commit comments