forked from lightninglabs/lightning-terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.Dockerfile
More file actions
154 lines (136 loc) · 6.13 KB
/
dev.Dockerfile
File metadata and controls
154 lines (136 loc) · 6.13 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Start with a NodeJS base image that also contains yarn.
FROM node:22.8.0-alpine@sha256:bec0ea49c2333c429b62e74e91f8ba1201b060110745c3a12ff957cd51b363c6 as nodejsbuilder
# Install dependencies to build the app
RUN apk add --no-cache --update git
# Copy in the local repository to build from.
COPY . /go/src/github.com/lightninglabs/lightning-terminal
# Set to 1 to enable this option and skip build of the web UI.
ARG NO_UI
RUN cd /go/src/github.com/lightninglabs/lightning-terminal/app \
&& if [ "$NO_UI" -eq "1" ]; then \
echo "skipping UI build";\
else \
yarn install \
&& yarn build; \
fi
# The first stage is already done and all static assets should now be generated
# in the app/build sub directory.
FROM golang:1.24.9-alpine3.22@sha256:8f8959f38530d159bf71d0b3eb0c547dc61e7959d8225d1599cf762477384923 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
# Allow forcing a specific lnd, taproot-assets, taprpc, and/or loop repo so that
# commits referenced by LND_VERSION, TAPROOT_ASSETS_VERSION, TAPRPC_VERSION, and
# LOOP_VERSION don't have to exist in the default repository. If any of these
# build arguments are not defined, the build continues using the default
# repository for that module. NOTE: If these arguments ARE defined then the
# corresponding `_VERSION` argument MUST also be defined, otherwise the build
# continues using the default repository defined for that module.
ARG LND_REPO
ARG TAPROOT_ASSETS_REPO
ARG TAPRPC_REPO
ARG LOOP_REPO
# Allow forcing a specific lnd, taproot-assets, taprpc, and/or loop version
# through a build argument.
# Please see https://go.dev/ref/mod#version-queries for the types of
# queries that can be used to define a version.
# If any of these build arguments are not defined then build uses the version
# already defined in go.mod and go.sum for that module.
# Note: If the corresponding `_REPO` argument is not defined, `go get` will
# be used along with `go mod tidy`, which sometimes may change the version you
# are trying to use because some other module requires the same requirement
# but of a different version. A trick to overcome this is to also use the
# `_REPO` argument and just put in the default repository for that module and
# that will cause a `go mod edit -replace=` to be used instead which won't have
# this issue.
ARG LND_VERSION
ARG TAPROOT_ASSETS_VERSION
ARG TAPRPC_VERSION
ARG LOOP_VERSION
# Need to restate this since running in a new container from above.
ARG NO_UI
# Allow defining the CGO_ENABLED variable so we can build binaries
# that will work in a different type of container.
# `go` assumes `CGO_ENABLED=1` if not defined, but we make it explicit here
# to be more clear of the default value.
ARG CGO_ENABLED=1
# Install dependencies and install/build lightning-terminal.
# Note: When using `docker build`, setting the environmental variable
# `DOCKER_BUILDKIT=1` is required to enable
# [BuildKit](https://docs.docker.com/build/buildkit)
# so that the cache mounts can be used.
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
apk add --no-cache --update alpine-sdk make \
&& cd /go/src/github.com/lightninglabs/lightning-terminal \
# If a custom lnd version is supplied, force it now.
&& if [ -n "$LND_VERSION" ]; then \
# If a custom lnd repo is supplied, force it now.
if [ -n "$LND_REPO" ]; then \
go mod edit -replace=github.com/lightningnetwork/lnd=$LND_REPO@$LND_VERSION; \
else \
go get -v github.com/lightningnetwork/lnd@$LND_VERSION; \
fi \
&& go mod tidy; \
fi \
# If a custom taproot-assets version is supplied, force it now.
&& if [ -n "$TAPROOT_ASSETS_VERSION" ]; then \
# If a custom taproot-assets repo is supplied, force it now.
if [ -n "$TAPROOT_ASSETS_REPO" ]; then \
go mod edit -replace=github.com/lightninglabs/taproot-assets=$TAPROOT_ASSETS_REPO@$TAPROOT_ASSETS_VERSION; \
else \
go get -v github.com/lightninglabs/taproot-assets@$TAPROOT_ASSETS_VERSION; \
fi \
&& go mod tidy; \
fi \
# If a custom taprpc version is supplied, force it now.
&& if [ -n "$TAPRPC_VERSION" ]; then \
# If a custom taprpc repo is supplied, force it now.
if [ -n "$TAPRPC_REPO" ]; then \
go mod edit -replace=github.com/lightninglabs/taproot-assets/taprpc=$TAPRPC_REPO@$TAPRPC_VERSION; \
else \
go get -v github.com/lightninglabs/taproot-assets/taprpc@$TAPRPC_VERSION; \
fi \
&& go mod tidy; \
fi \
# If a custom loop version is supplied, force it now.
&& if [ -n "$LOOP_VERSION" ]; then \
# If a custom loop repo is supplied, force it now.
if [ -n "$LOOP_REPO" ]; then \
go mod edit -replace=github.com/lightninglabs/loop=$LOOP_REPO@$LOOP_VERSION; \
else \
go get -v github.com/lightninglabs/loop@$LOOP_VERSION; \
fi \
&& go mod tidy; \
fi \
&& if [ "$NO_UI" -eq "1" ]; then \
make go-install-noui \
&& make go-install-cli-noui; \
else \
make go-install \
&& make go-install-cli; \
fi
# Start a new, final image to reduce size.
FROM alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1 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/litcli /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/
COPY --from=golangbuilder /go/bin/tapcli /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"]