Browse Source

Merge branch 'master' into dcg-latest

feature/auto_ssh
nicolas.dorier 6 years ago
parent
commit
8786c7b395
  1. 2
      Production-NoReverseProxy/README.md
  2. 1
      README.md
  3. 14
      btcpay-setup.sh
  4. 5
      btcpay-update.sh
  5. 4
      docker-compose-generator/Dockerfile
  6. 3
      docker-compose-generator/docker-fragments/bitcoin-clightning.yml
  7. 2
      docker-compose-generator/docker-fragments/bitcoin-lnd.yml
  8. 4
      docker-compose-generator/docker-fragments/btcpayserver.yml
  9. 3
      docker-compose-generator/docker-fragments/litecoin-clightning.yml
  10. 2
      docker-compose-generator/docker-fragments/litecoin-lnd.yml
  11. 2
      docker-compose-generator/docker-fragments/nbxplorer.yml
  12. 6
      docker-compose-generator/src/DockerComposeDefinition.cs

2
Production-NoReverseProxy/README.md

@ -33,6 +33,7 @@ With Powershell:
$env:BTCPAY_ROOTPATH="/test";
$env:BTCPAY_PROTOCOL="http";
$env:BTCPAY_HOST="btcpay.example.com";
$env:BTCPAYGEN_REVERSEPROXY="none";
.\build.ps1
docker-compose -f "Generated/docker-compose.generated.yml" up --remove-orphans -d
```
@ -43,6 +44,7 @@ With Linux:
export BTCPAY_ROOTPATH="/test"
export BTCPAY_PROTOCOL="http"
export BTCPAY_HOST="btcpay.example.com"
export BTCPAYGEN_REVERSEPROXY="none"
./build.sh
docker-compose -f "Generated/docker-compose.generated.yml" up --remove-orphans -d
```

1
README.md

@ -124,6 +124,7 @@ You can read [the article](https://medium.com/@BtcpayServer/hosting-btcpay-serve
* `BTCPAY_HOST_SSHKEYFILE`: Optional, SSH private key that BTCPay can use to connect to this VM's SSH server. This key will be copied to BTCPay's data directory
* `BTCPAY_SSHTRUSTEDFINGERPRINTS`: Optional, BTCPay will ensure that it is connecting to the expected SSH server by checking the host's public key against these fingerprints
* `BTCPAYGEN_DOCKER_IMAGE`: Optional, Specify which generator image to use if you have customized the C# generator. Set to `btcpayserver/docker-compose-generator:local` to build the generator locally at runtime.
* `BTCPAY_IMAGE`: Optional, Specify which btcpayserver image to use if you have a customized btcpayserver.
# Tooling

14
btcpay-setup.sh

@ -61,6 +61,7 @@ Environment variables:
ACME_CA_URI: The API endpoint to ask for HTTPS certificate (default: https://acme-v01.api.letsencrypt.org/directory)
BTCPAY_HOST_SSHKEYFILE: Optional, SSH private key that BTCPay can use to connect to this VM's SSH server. This key will be copied on BTCPay's data directory
BTCPAYGEN_DOCKER_IMAGE: Allows you to specify a custom docker image for the generator (Default: btcpayserver/docker-compose-generator)
BTCPAY_IMAGE: Allows you to specify the btcpayserver docker image to use over the default version. (Default: current stable version of btcpayserver)
END
}
@ -114,6 +115,15 @@ if [[ -f "$BTCPAY_HOST_SSHKEYFILE" ]]; then
done
fi
if [[ "$BTCPAYGEN_REVERSEPROXY" == "nginx" ]]; then
DOMAIN_NAME="$(echo "$BTCPAY_HOST" | grep -P '(?=^.{4,253}$)(^(?:[a-zA-Z0-9](?:(?:[a-zA-Z0-9\-]){0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$)')"
if [[ ! "$DOMAIN_NAME" ]]; then
echo "BTCPAYGEN_REVERSEPROXY is set to nginx, so BTCPAY_HOST must be a domain name which point to this server (with port 80 and 443 open), but the current value of BTCPAY_HOST ('$BTCPAY_HOST') is not a valid domain name."
return
fi
BTCPAY_HOST="$DOMAIN_NAME"
fi
echo "
-------SETUP-----------
Parameters passed:
@ -134,6 +144,7 @@ BTCPAYGEN_CRYPTO9:$BTCPAYGEN_CRYPTO9
BTCPAYGEN_REVERSEPROXY:$BTCPAYGEN_REVERSEPROXY
BTCPAYGEN_LIGHTNING:$BTCPAYGEN_LIGHTNING
BTCPAYGEN_ADDITIONAL_FRAGMENTS:$BTCPAYGEN_ADDITIONAL_FRAGMENTS
BTCPAY_IMAGE:$BTCPAY_IMAGE
ACME_CA_URI:$ACME_CA_URI
----------------------
Additional exported variables:
@ -163,6 +174,7 @@ fi
# Put the variables in /etc/profile.d when a user log interactively
touch "/etc/profile.d/btcpay-env.sh"
echo "
export COMPOSE_HTTP_TIMEOUT=\"180\"
export BTCPAYGEN_OLD_PREGEN=\"$BTCPAYGEN_OLD_PREGEN\"
export BTCPAYGEN_CRYPTO1=\"$BTCPAYGEN_CRYPTO1\"
export BTCPAYGEN_CRYPTO2=\"$BTCPAYGEN_CRYPTO2\"
@ -182,6 +194,7 @@ export BTCPAY_ENV_FILE=\"$BTCPAY_ENV_FILE\"
export BTCPAY_HOST_SSHKEYFILE=\"$BTCPAY_HOST_SSHKEYFILE\"
if cat \$BTCPAY_ENV_FILE &> /dev/null; then
export BTCPAY_HOST=\"\$(cat \$BTCPAY_ENV_FILE | sed -n 's/^BTCPAY_HOST=\(.*\)$/\1/p')\"
export BTCPAY_IMAGE=\"\$(cat \$BTCPAY_ENV_FILE | sed -n 's/^BTCPAY_IMAGE=\(.*\)$/\1/p')\"
export LETSENCRYPT_EMAIL=\"\$(cat \$BTCPAY_ENV_FILE | sed -n 's/^LETSENCRYPT_EMAIL=\(.*\)$/\1/p')\"
export NBITCOIN_NETWORK=\"\$(cat \$BTCPAY_ENV_FILE | sed -n 's/^NBITCOIN_NETWORK=\(.*\)$/\1/p')\"
export LIGHTNING_ALIAS=\"\$(cat \$BTCPAY_ENV_FILE | sed -n 's/^LIGHTNING_ALIAS=\(.*\)$/\1/p')\"
@ -198,6 +211,7 @@ echo -e "BTCPay Server environment variables successfully saved in /etc/profile.
touch $BTCPAY_ENV_FILE
echo "
BTCPAY_HOST=$BTCPAY_HOST
BTCPAY_IMAGE=$BTCPAY_IMAGE
ACME_CA_URI=$ACME_CA_URI
NBITCOIN_NETWORK=$NBITCOIN_NETWORK
LETSENCRYPT_EMAIL=$LETSENCRYPT_EMAIL

5
btcpay-update.sh

@ -22,6 +22,11 @@ if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then
cp Generated/docker-compose.generated.yml $BTCPAY_DOCKER_COMPOSE
fi
if ! grep -Fxq "export COMPOSE_HTTP_TIMEOUT=\"180\"" "/etc/profile.d/btcpay-env.sh"; then
echo "export COMPOSE_HTTP_TIMEOUT=\"180\"" >> /etc/profile.d/btcpay-env.sh
export COMPOSE_HTTP_TIMEOUT=180
echo "Adding COMPOSE_HTTP_TIMEOUT=180 in btcpay-env.sh"
fi
for scriptname in *.sh; do
if [ "$scriptname" == "build.sh" ] || \

4
docker-compose-generator/Dockerfile

@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 AS builder
FROM microsoft/dotnet:2.1.500-sdk-alpine3.7 AS builder
WORKDIR /source
COPY src/docker-compose-generator.csproj docker-compose-generator.csproj
# Cache some dependencies
@ -6,7 +6,7 @@ RUN dotnet restore
COPY src/. .
RUN dotnet publish --output /app/ --configuration Release
FROM microsoft/dotnet:2.1.5-runtime-alpine3.7
FROM microsoft/dotnet:2.1.6-runtime-alpine3.7
WORKDIR /app
RUN mkdir /datadir

3
docker-compose-generator/docker-fragments/bitcoin-clightning.yml

@ -2,7 +2,8 @@ version: "3"
services:
clightning_bitcoin:
image: nicolasdorier/clightning:v0.6.2
image: nicolasdorier/clightning:v0.6.2-3
stop_signal: SIGKILL
container_name: btcpayserver_clightning_bitcoin
restart: unless-stopped
environment:

2
docker-compose-generator/docker-fragments/bitcoin-lnd.yml

@ -2,7 +2,7 @@ version: "3"
services:
lnd_bitcoin:
image: btcpayserver/lnd:0.5-beta
image: btcpayserver/lnd:0.5-beta-2
container_name: btcpayserver_lnd_bitcoin
restart: unless-stopped
environment:

4
docker-compose-generator/docker-fragments/btcpayserver.yml

@ -4,7 +4,7 @@ services:
btcpayserver:
restart: unless-stopped
image: nicolasdorier/btcpayserver:1.0.3.4
image: ${BTCPAY_IMAGE:-nicolasdorier/btcpayserver:1.0.3.9}
expose:
- "49392"
environment:
@ -16,7 +16,7 @@ services:
BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/}
BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS}
BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE}
BTCPAY_DEBUGLOG: btcpay.log
links:
- nbxplorer
- postgres

3
docker-compose-generator/docker-fragments/litecoin-clightning.yml

@ -2,7 +2,8 @@ version: "3"
services:
clightning_litecoin:
image: nicolasdorier/clightning:v0.6.2
image: nicolasdorier/clightning:v0.6.2-3
stop_signal: SIGKILL
container_name: btcpayserver_clightning_litecoin
restart: unless-stopped
environment:

2
docker-compose-generator/docker-fragments/litecoin-lnd.yml

@ -2,7 +2,7 @@ version: "3"
services:
lnd_litecoin:
image: btcpayserver/lnd:0.5-beta
image: btcpayserver/lnd:0.5-beta-2
container_name: btcpayserver_lnd_litecoin
restart: unless-stopped
environment:

2
docker-compose-generator/docker-fragments/nbxplorer.yml

@ -4,7 +4,7 @@ services:
nbxplorer:
restart: unless-stopped
image: nicolasdorier/nbxplorer:1.1.0.8
image: nicolasdorier/nbxplorer:1.1.0.12
expose:
- "32838"
environment:

6
docker-compose-generator/src/DockerComposeDefinition.cs

@ -57,6 +57,7 @@ namespace DockerGenerator
}
var services = new List<KeyValuePair<YamlNode, YamlNode>>();
var volumes = new List<KeyValuePair<YamlNode, YamlNode>>();
var networks = new List<KeyValuePair<YamlNode, YamlNode>>();
foreach (var doc in Fragments.Select(f => ParseDocument(f)))
{
@ -69,6 +70,10 @@ namespace DockerGenerator
{
volumes.AddRange(fragmentVolumesRoot.Children);
}
if (doc.Children.ContainsKey("networks") && doc.Children["networks"] is YamlMappingNode fragmentNetworksRoot)
{
networks.AddRange(fragmentNetworksRoot.Children);
}
}
@ -76,6 +81,7 @@ namespace DockerGenerator
output.Add("version", new YamlScalarNode("3") { Style = YamlDotNet.Core.ScalarStyle.DoubleQuoted });
output.Add("services", new YamlMappingNode(Merge(services)));
output.Add("volumes", new YamlMappingNode(volumes));
output.Add("networks", new YamlMappingNode(networks));
var result = serializer.Serialize(output);
var outputFile = GetFilePath();
File.WriteAllText(outputFile, result.Replace("''", ""));

Loading…
Cancel
Save