mirror of
https://github.com/aljazceru/btcpayserver-docker.git
synced 2025-12-18 13:24:20 +01:00
Make build-all-images work on arm
This commit is contained in:
@@ -7,7 +7,17 @@ namespace DockerFileBuildHelper
|
||||
public class DockerFile
|
||||
{
|
||||
public string DockerFileName { get; private set; }
|
||||
public string DockerFilePath { get; private set; }
|
||||
public string DockerDirectoryPath { get; private set; }
|
||||
public string DockerFullPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DockerDirectoryPath == ".")
|
||||
return $"{DockerFileName}";
|
||||
else
|
||||
return $"{DockerDirectoryPath}/{DockerFileName}";
|
||||
}
|
||||
}
|
||||
|
||||
public static DockerFile Parse(string str)
|
||||
{
|
||||
@@ -16,11 +26,11 @@ namespace DockerFileBuildHelper
|
||||
file.DockerFileName = str.Substring(lastPart + 1);
|
||||
if (lastPart == -1)
|
||||
{
|
||||
file.DockerFilePath = ".";
|
||||
file.DockerDirectoryPath = ".";
|
||||
}
|
||||
else
|
||||
{
|
||||
file.DockerFilePath = str.Substring(0, lastPart);
|
||||
file.DockerDirectoryPath = str.Substring(0, lastPart);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -53,21 +53,58 @@ namespace DockerFileBuildHelper
|
||||
var canDownloadEverything = downloading.All(o => o.Result);
|
||||
if (!canDownloadEverything)
|
||||
return false;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var builder = new StringBuilderEx();
|
||||
builder.AppendLine("#!/bin/bash");
|
||||
builder.AppendLine();
|
||||
builder.AppendLine("# This file is automatically generated by the DockerFileBuildHelper tool, run DockerFileBuildHelper/update-repo.sh to update it");
|
||||
builder.AppendLine("set -e");
|
||||
builder.AppendLine("DOCKERFILE=\"\"");
|
||||
builder.AppendLine();
|
||||
builder.AppendLine();
|
||||
foreach (var info in dockerInfos)
|
||||
{
|
||||
builder.AppendLine($"# Build {info.Image.Name}");
|
||||
bool mightBeUnavailable = false;
|
||||
if (info.DockerFilePath != null)
|
||||
{
|
||||
var dockerFile = DockerFile.Parse(info.DockerFilePath);
|
||||
builder.AppendLine($"# {info.GetGithubLinkOf(dockerFile.DockerFullPath)}");
|
||||
builder.AppendLine($"DOCKERFILE=\"{dockerFile.DockerFullPath}\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine($"DOCKERFILE=\"\"");
|
||||
mightBeUnavailable = true;
|
||||
}
|
||||
if (info.DockerFilePathARM32v7 != null)
|
||||
{
|
||||
var dockerFile = DockerFile.Parse(info.DockerFilePathARM32v7);
|
||||
builder.AppendLine($"# {info.GetGithubLinkOf(dockerFile.DockerFullPath)}");
|
||||
builder.AppendLine($"[[ \"$(uname -m)\" == \"armv7l\" ]] && DOCKERFILE=\"{dockerFile.DockerFullPath}\"");
|
||||
}
|
||||
if (info.DockerFilePathARM64v8 != null)
|
||||
{
|
||||
var dockerFile = DockerFile.Parse(info.DockerFilePathARM64v8);
|
||||
builder.AppendLine($"# {info.GetGithubLinkOf(dockerFile.DockerFullPath)}");
|
||||
builder.AppendLine($"[[ \"$(uname -m)\" == \"aarch64\" ]] && DOCKERFILE=\"{dockerFile.DockerFullPath}\"");
|
||||
}
|
||||
if(mightBeUnavailable)
|
||||
{
|
||||
builder.AppendLine($"if [[ \"$DOCKERFILE\" ]]; then");
|
||||
builder.Indent++;
|
||||
}
|
||||
builder.AppendLine($"echo \"Building {info.Image.ToString()}\"");
|
||||
builder.AppendLine($"git clone {info.GitLink} {info.Image.Name}");
|
||||
var dockerFile = DockerFile.Parse($"{info.DockerFilePath ?? info.DockerFilePathARM32v7 ?? info.DockerFilePathARM64v8}");
|
||||
builder.AppendLine($"cd {info.Image.Name}");
|
||||
builder.AppendLine($"git checkout {info.GitRef}");
|
||||
builder.AppendLine($"cd {dockerFile.DockerFilePath}");
|
||||
builder.AppendLine($"docker build -f \"{dockerFile.DockerFileName}\" -t \"{info.Image}\" .");
|
||||
builder.AppendLine($"cd \"$(dirname $DOCKERFILE)\"");
|
||||
builder.AppendLine($"docker build -f \"$DOCKERFILE\" -t \"{info.Image}\" .");
|
||||
builder.AppendLine($"cd - && cd ..");
|
||||
if (mightBeUnavailable)
|
||||
{
|
||||
builder.Indent--;
|
||||
builder.AppendLine($"fi");
|
||||
}
|
||||
builder.AppendLine();
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
45
contrib/DockerFileBuildHelper/StringBuilderEx.cs
Normal file
45
contrib/DockerFileBuildHelper/StringBuilderEx.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace DockerFileBuildHelper
|
||||
{
|
||||
public class StringBuilderEx
|
||||
{
|
||||
StringBuilder _Builder = new StringBuilder();
|
||||
public StringBuilderEx()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int Indent { get; set; }
|
||||
|
||||
public void Append(string str)
|
||||
{
|
||||
_Builder.Append(GetIndents());
|
||||
_Builder.Append(str);
|
||||
}
|
||||
|
||||
private string GetIndents()
|
||||
{
|
||||
return new String(Enumerable.Range(0, Indent).Select(_ => '\t').ToArray());
|
||||
}
|
||||
|
||||
public void AppendLine(string str)
|
||||
{
|
||||
_Builder.Append(GetIndents());
|
||||
_Builder.AppendLine(str);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return _Builder.ToString();
|
||||
}
|
||||
|
||||
internal void AppendLine()
|
||||
{
|
||||
_Builder.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user