lightning-terminal/Dockerfile
Oliver Gugger a5ce60070c
docker: use stages for nodejs and golang parts
With this commit we split the build process into three stages: we start
with the JavaScript to static asset build process that requires NodeJS
then copy the result into the second stage that requires golang.
Finally, we just extract the final binaries in the third stage to keep
the shipped image as small as possible.
2020-12-10 11:04:21 +01:00

64 lines
2.2 KiB
Docker

# Start with a NodeJS base image that also contains yarn.
FROM node:12.17.0-alpine as nodejsbuilder
# Pass a tag, branch or a commit using build-arg. This allows a docker image to
# be built from a specified Git state. The default image will use the Git tip of
# master by default.
ARG checkout="master"
RUN apk add --no-cache --update alpine-sdk \
git \
&& git clone https://github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal \
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
&& git checkout $checkout \
&& cd app \
&& yarn install \
&& yarn build
# The first stage is already done and all static assets should now be generated
# in the app/build sub directory.
FROM golang:1.15.5-alpine as golangbuilder
# Instead of checking out from git again, we just copy the whole working
# directory of the previous stage that includes the generated static assets.
COPY --from=nodejsbuilder /go/src/github.com/lightninglabs/lightning-terminal /go/src/github.com/lightninglabs/lightning-terminal
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
# queries required to connect to linked containers succeed.
ENV GODEBUG netdns=cgo
# Explicitly turn on the use of modules (until this becomes the default).
ENV GO111MODULE on
# Install dependencies and install/build lightning-terminal.
RUN apk add --no-cache --update alpine-sdk \
make \
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
&& make statik-only \
&& make go-install \
&& make go-install-cli
# Start a new, final image to reduce size.
FROM alpine as final
# Define a root volume for data persistence.
VOLUME /root/.lnd
# Expose lightning-terminal and lnd ports (server, rpc).
EXPOSE 8443 10009 9735
# Copy the binaries and entrypoint from the builder image.
COPY --from=golangbuilder /go/bin/litd /bin/
COPY --from=golangbuilder /go/bin/lncli /bin/
COPY --from=golangbuilder /go/bin/frcli /bin/
COPY --from=golangbuilder /go/bin/loop /bin/
COPY --from=golangbuilder /go/bin/pool /bin/
# Add bash.
RUN apk add --no-cache \
bash \
jq \
ca-certificates
# Specify the start command and entrypoint as the lightning-terminal daemon.
ENTRYPOINT ["litd"]