Skip to content

Commit 64d53f7

Browse files
committed
Dockerfile: add production docker image
We add a new standalone Dockerfile that checks out the code from GitHub and goes through all necessary build steps from scratch. The git commit or tag that should be checked out before building can be specified as a build argument. To still allow more rapid development, the old Dockerfile that builds from the local source is renamed to dev.Dockerfile to make the distinction clear.
1 parent d18397f commit 64d53f7

File tree

2 files changed

+76
-9
lines changed

2 files changed

+76
-9
lines changed

Dockerfile

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
FROM golang:1.15.5-alpine as builder
22

3-
# Copy in the local repository to build from.
4-
COPY . /go/src/github.com/lightninglabs/lightning-terminal
5-
63
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
74
# queries required to connect to linked containers succeed.
85
ENV GODEBUG netdns=cgo
96

7+
# Pass a tag, branch or a commit using build-arg. This allows a docker image to
8+
# be built from a specified Git state. The default image will use the Git tip of
9+
# master by default.
10+
ARG checkout="master"
11+
1012
# Explicitly turn on the use of modules (until this becomes the default).
1113
ENV GO111MODULE on
1214

1315
ENV NODE_VERSION=v12.17.0
1416

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"
21+
1522
# Install dependencies and install/build lightning-terminal.
1623
RUN apk add --no-cache --update alpine-sdk \
1724
git \
@@ -21,18 +28,21 @@ RUN apk add --no-cache --update alpine-sdk \
2128
binutils \
2229
tar \
2330
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 \
2435
&& touch ~/.bashrc \
2536
&& curl -sfSLO https://unofficial-builds.nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64-musl.tar.xz \
2637
&& tar -xf node-${NODE_VERSION}-linux-x64-musl.tar.xz -C /usr --strip 1 \
2738
&& rm node-${NODE_VERSION}-linux-x64-musl.tar.xz \
2839
&& curl -o- -L https://yarnpkg.com/install.sh | bash \
2940
&& . ~/.bashrc \
30-
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
31-
&& make install \
32-
&& go install -v -trimpath github.com/lightningnetwork/lnd/cmd/lncli \
33-
&& go install -v -trimpath github.com/lightninglabs/faraday/cmd/frcli \
34-
&& go install -v -trimpath github.com/lightninglabs/loop/cmd/loop \
35-
&& go install -v -trimpath github.com/lightninglabs/pool/cmd/pool
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
3646

3747
# Start a new, final image to reduce size.
3848
FROM alpine as final

dev.Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM golang:1.15.5-alpine as builder
2+
3+
# Copy in the local repository to build from.
4+
COPY . /go/src/github.com/lightninglabs/lightning-terminal
5+
6+
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
7+
# queries required to connect to linked containers succeed.
8+
ENV GODEBUG netdns=cgo
9+
10+
# Explicitly turn on the use of modules (until this becomes the default).
11+
ENV GO111MODULE on
12+
13+
ENV NODE_VERSION=v12.17.0
14+
15+
# Install dependencies and install/build lightning-terminal.
16+
RUN apk add --no-cache --update alpine-sdk \
17+
git \
18+
make \
19+
curl \
20+
bash \
21+
binutils \
22+
tar \
23+
protobuf-dev \
24+
&& touch ~/.bashrc \
25+
&& curl -sfSLO https://unofficial-builds.nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64-musl.tar.xz \
26+
&& tar -xf node-${NODE_VERSION}-linux-x64-musl.tar.xz -C /usr --strip 1 \
27+
&& rm node-${NODE_VERSION}-linux-x64-musl.tar.xz \
28+
&& curl -o- -L https://yarnpkg.com/install.sh | bash \
29+
&& . ~/.bashrc \
30+
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
31+
&& make install \
32+
&& make go-install-cli
33+
34+
# Start a new, final image to reduce size.
35+
FROM alpine as final
36+
37+
# Define a root volume for data persistence.
38+
VOLUME /root/.lnd
39+
40+
# Expose lightning-terminal and lnd ports (server, rpc).
41+
EXPOSE 8443 10009 9735
42+
43+
# Copy the binaries and entrypoint from the builder image.
44+
COPY --from=builder /go/bin/litd /bin/
45+
COPY --from=builder /go/bin/lncli /bin/
46+
COPY --from=builder /go/bin/frcli /bin/
47+
COPY --from=builder /go/bin/loop /bin/
48+
COPY --from=builder /go/bin/pool /bin/
49+
50+
# Add bash.
51+
RUN apk add --no-cache \
52+
bash \
53+
jq \
54+
ca-certificates
55+
56+
# Specify the start command and entrypoint as the lightning-terminal daemon.
57+
ENTRYPOINT ["litd"]

0 commit comments

Comments
 (0)