mirror of
https://github.com/aljazceru/btcpayserver-docker.git
synced 2025-12-18 20:34:20 +01:00
Generate pull-images.sh with the docker-compose.
This commit is contained in:
3
Generated/.gitignore
vendored
3
Generated/.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
*.yml
|
*.yml
|
||||||
nginx.tmpl
|
nginx.tmpl
|
||||||
*.toml
|
*.toml
|
||||||
*.json
|
*.json
|
||||||
|
pull-images.sh
|
||||||
@@ -416,7 +416,7 @@ WantedBy=multi-user.target" > /etc/systemd/system/btcpayserver.service
|
|||||||
\"log-opts\": {\"max-size\": \"5m\", \"max-file\": \"3\"}
|
\"log-opts\": {\"max-size\": \"5m\", \"max-file\": \"3\"}
|
||||||
}" > /etc/docker/daemon.json
|
}" > /etc/docker/daemon.json
|
||||||
echo "Setting limited log files in /etc/docker/daemon.json"
|
echo "Setting limited log files in /etc/docker/daemon.json"
|
||||||
systemctl restart docker
|
$START && ! $IS_CHROOT && systemctl restart docker
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "BTCPay Server systemd configured in /etc/systemd/system/btcpayserver.service\n"
|
echo -e "BTCPay Server systemd configured in /etc/systemd/system/btcpayserver.service\n"
|
||||||
@@ -465,9 +465,11 @@ if [[ ! -z "$OLD_BTCPAY_DOCKER_COMPOSE" ]] && [[ "$OLD_BTCPAY_DOCKER_COMPOSE" !=
|
|||||||
docker-compose -f "$OLD_BTCPAY_DOCKER_COMPOSE" down -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
docker-compose -f "$OLD_BTCPAY_DOCKER_COMPOSE" down -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $START; then
|
||||||
$START && btcpay_up
|
btcpay_up
|
||||||
! $START && docker-compose -f "$BTCPAY_DOCKER_COMPOSE" pull
|
else
|
||||||
|
btcpay_pull
|
||||||
|
fi
|
||||||
|
|
||||||
# Give SSH key to BTCPay
|
# Give SSH key to BTCPay
|
||||||
if [[ -f "$BTCPAY_HOST_SSHKEYFILE" ]]; then
|
if [[ -f "$BTCPAY_HOST_SSHKEYFILE" ]]; then
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ namespace DockerGenerator
|
|||||||
|
|
||||||
public string GetFilePath()
|
public string GetFilePath()
|
||||||
{
|
{
|
||||||
return Path.Combine(BuildOutputDirectory, $"docker-compose.{_Name}.yml");
|
return GetFilePath($"docker-compose.{_Name}.yml");
|
||||||
|
}
|
||||||
|
public string GetFilePath(string fileName)
|
||||||
|
{
|
||||||
|
return Path.Combine(BuildOutputDirectory, fileName);
|
||||||
}
|
}
|
||||||
public void Build()
|
public void Build()
|
||||||
{
|
{
|
||||||
@@ -83,11 +87,23 @@ namespace DockerGenerator
|
|||||||
output.Add("services", new YamlMappingNode(Merge(services)));
|
output.Add("services", new YamlMappingNode(Merge(services)));
|
||||||
output.Add("volumes", new YamlMappingNode(volumes));
|
output.Add("volumes", new YamlMappingNode(volumes));
|
||||||
output.Add("networks", new YamlMappingNode(networks));
|
output.Add("networks", new YamlMappingNode(networks));
|
||||||
|
|
||||||
|
|
||||||
|
var dockerImages = ((YamlMappingNode)output["services"]).Children.Select(kv => kv.Value["image"].ToString()).ToArray();
|
||||||
|
StringBuilder pullImageSh = new StringBuilder();
|
||||||
|
pullImageSh.Append($"#!/bin/bash\n\n");
|
||||||
|
foreach (var image in dockerImages)
|
||||||
|
{
|
||||||
|
pullImageSh.Append($"docker pull \"{image}\"\n");
|
||||||
|
}
|
||||||
|
var outputFile = GetFilePath("pull-images.sh");
|
||||||
|
File.WriteAllText(outputFile, pullImageSh.ToString());
|
||||||
|
Console.WriteLine($"Generated {outputFile}");
|
||||||
|
|
||||||
var result = serializer.Serialize(output);
|
var result = serializer.Serialize(output);
|
||||||
var outputFile = GetFilePath();
|
outputFile = GetFilePath();
|
||||||
File.WriteAllText(outputFile, result.Replace("''", ""));
|
File.WriteAllText(outputFile, result.Replace("''", ""));
|
||||||
Console.WriteLine($"Generated {outputFile}");
|
Console.WriteLine($"Generated {outputFile}");
|
||||||
Console.WriteLine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyValuePair<YamlNode, YamlNode>[] Merge(List<KeyValuePair<YamlNode, YamlNode>> services)
|
private KeyValuePair<YamlNode, YamlNode>[] Merge(List<KeyValuePair<YamlNode, YamlNode>> services)
|
||||||
|
|||||||
@@ -98,6 +98,10 @@ btcpay_up() {
|
|||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btcpay_pull() {
|
||||||
|
. $BTCPAY_BASE_DIRECTORY/Generated/pull-images.sh
|
||||||
|
}
|
||||||
|
|
||||||
btcpay_down() {
|
btcpay_down() {
|
||||||
pushd . > /dev/null
|
pushd . > /dev/null
|
||||||
cd "$(dirname "$BTCPAY_ENV_FILE")"
|
cd "$(dirname "$BTCPAY_ENV_FILE")"
|
||||||
|
|||||||
Reference in New Issue
Block a user