forked from lightningnetwork/lnd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Vutov/master
Docker for BTCPay
- Loading branch information
Showing
5 changed files
with
113 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Dockerfile | ||
BTCPayServer.Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Declare files that will always have CRLF line endings on checkout. | ||
*.sh text eol=lf | ||
*.go text eol=lf | ||
Makefile text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM golang:alpine as builder | ||
|
||
# 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 | ||
|
||
# Install dependencies and build the binaries. | ||
RUN apk add --no-cache \ | ||
git \ | ||
make | ||
|
||
WORKDIR /go/src/github.com/shelvenzhou/lnd | ||
COPY . . | ||
|
||
RUN make \ | ||
&& make install | ||
|
||
# Start a new, final image. | ||
FROM alpine as final | ||
|
||
# Add bash and ca-certs, for quality of life and SSL-related reasons. | ||
RUN apk --no-cache add \ | ||
bash \ | ||
ca-certificates | ||
|
||
ENV LND_DATA /data | ||
ENV LND_BITCOIND /deps/.bitcoingold | ||
ENV LND_BTCD /deps/.btcd | ||
|
||
RUN mkdir "$LND_DATA" && mkdir "/deps" && mkdir "$LND_BITCOIND" && mkdir "$LND_BTCD" && \ | ||
ln -sfn "$LND_DATA" /root/.lnd && ln -sfn "$LND_BITCOIND" /root/.bitcoingold && ln -sfn "$LND_BTCD" /root/.btcd | ||
|
||
# Define a root volume for data persistence. | ||
VOLUME /data | ||
|
||
# Copy the binaries from the builder image. | ||
COPY --from=builder /go/bin/lncli /bin/ | ||
COPY --from=builder /go/bin/lnd /bin/ | ||
|
||
COPY docker-entrypoint.sh /docker-entrypoint.sh | ||
# Specify the start command and entrypoint as the lnd daemon. | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
CMD ["lnd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [[ "$1" == "lnd" || "$1" == "lncli" ]]; then | ||
mkdir -p "$LND_DATA" | ||
|
||
cat <<-EOF > "$LND_DATA/lnd.conf" | ||
${LND_EXTRA_ARGS} | ||
EOF | ||
|
||
if [[ $LND_CHAIN && $LND_ENVIRONMENT ]]; then | ||
echo "LND_CHAIN=$LND_CHAIN" | ||
echo "LND_ENVIRONMENT=$LND_ENVIRONMENT" | ||
|
||
NETWORK="" | ||
|
||
shopt -s nocasematch | ||
if [[ $LND_CHAIN == "btg" ]]; then | ||
NETWORK="bitcoingold" | ||
else | ||
echo "Unknwon value for LND_CHAIN, expected btc or ltc" | ||
fi | ||
|
||
ENV="" | ||
# Make sure we use correct casing for LND_Environment | ||
if [[ $LND_ENVIRONMENT == "mainnet" ]]; then | ||
ENV="mainnet" | ||
elif [[ $LND_ENVIRONMENT == "testnet" ]]; then | ||
ENV="testnet" | ||
elif [[ $LND_ENVIRONMENT == "regtest" ]]; then | ||
ENV="regtest" | ||
else | ||
echo "Unknwon value for LND_ENVIRONMENT, expected mainnet, testnet or regtest" | ||
fi | ||
shopt -u nocasematch | ||
|
||
if [[ $ENV && $NETWORK ]]; then | ||
echo " | ||
$NETWORK.active=1 | ||
$NETWORK.$LND_ENVIRONMENT=1 | ||
" >> "$LND_DATA/lnd.conf" | ||
echo "Added $NETWORK.active and $NETWORK.$LND_ENVIRONMENT to config file $LND_DATA/lnd.conf" | ||
else | ||
echo "LND_CHAIN or LND_ENVIRONMENT is not set correctly" | ||
fi | ||
fi | ||
|
||
ln -sfn "$LND_DATA" /root/.lnd | ||
ln -sfn "$LND_BITCOIND" /root/.bitcoingold | ||
ln -sfn "$LND_BTCD" /root/.btcd | ||
exec "$@" | ||
else | ||
exec "$@" | ||
fi |