Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
0e09aaef5c | |||
29b8c59c9e | |||
bbdd5ce586 |
@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE65C879-794A-4695-B659-7376FE7DB5E3}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.gitignore = .gitignore
|
||||
build.py = build.py
|
||||
MinecraftDiscordBot\bin\Debug\net6.0\config.json = MinecraftDiscordBot\bin\Debug\net6.0\config.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -11,8 +11,11 @@ public class BotConfiguration : IBotConfiguration, IBotConfigurator {
|
||||
[JsonProperty("token", Required = Required.Always)]
|
||||
[Option('t', "token", HelpText = "The Discord bot token", Required = true)]
|
||||
public string Token { get; init; } = default!;
|
||||
[JsonProperty("address", Required = Required.Always)]
|
||||
[Option('a', "address", HelpText = "The connection string for the websocket", Required = true)]
|
||||
public string Address { get; init; } = default!;
|
||||
[JsonProperty("port", Required = Required.DisallowNull)]
|
||||
[Option('p', "port", Default = DEFAULT_PORT, HelpText = "The websocket server port")]
|
||||
[Option('p', "port", Default = DEFAULT_PORT, HelpText = "The websocket server listen port")]
|
||||
public int Port { get; init; } = DEFAULT_PORT;
|
||||
[JsonProperty("channels", Required = Required.Always)]
|
||||
[Option('c', "channel", HelpText = "The list of whitelisted channels", Required = true, Min = 1)]
|
||||
|
@ -210,6 +210,7 @@ local function playerStatusEventListener(socket)
|
||||
break
|
||||
end
|
||||
printError("playerDetector not connected!")
|
||||
sleep(5)
|
||||
end
|
||||
while true do
|
||||
local pd = peripheral.find("playerDetector")
|
||||
|
@ -6,7 +6,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<Version>1.1.3</Version>
|
||||
<Version>1.1.5</Version>
|
||||
<Authors>Michael Chen</Authors>
|
||||
<Company>$(Authors)</Company>
|
||||
<RepositoryUrl>https://gitlab.com/chenmichael/mcdiscordbot</RepositoryUrl>
|
||||
@ -20,11 +20,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
||||
<PackageReference Include="Discord.Net" Version="3.1.0" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="Discord.Net" Version="3.8.1" />
|
||||
<PackageReference Include="Fleck" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -50,7 +50,7 @@ public class Program : IDisposable, ICommandHandler<ResponseType>, IUserRoleMana
|
||||
if (stream is null) throw new FileNotFoundException("Client script could not be loaded!");
|
||||
using var sr = new StreamReader(stream);
|
||||
return sr.ReadToEnd()
|
||||
.Replace("$HOST", $"ws://{config.SocketHost}:{config.Port}");
|
||||
.Replace("$HOST", config.Address);
|
||||
}
|
||||
|
||||
private Task Broadcast(Func<ITextChannel, Task<IUserMessage>> message)
|
||||
|
38
build.py
38
build.py
@ -2,11 +2,12 @@
|
||||
import subprocess
|
||||
import argparse
|
||||
from itertools import chain
|
||||
import re
|
||||
|
||||
dockercmd = 'docker'
|
||||
|
||||
parser = argparse.ArgumentParser(description='Create custom recumock images.')
|
||||
parser.add_argument('tags', metavar='TAG', nargs='+', help='Version tags to build.')
|
||||
parser.add_argument('tags', metavar='TAG', nargs='*', help='Version tags to build.')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -15,20 +16,31 @@ platforms = ['linux/amd64', 'linux/arm64', 'linux/arm/v7']
|
||||
def pull(image):
|
||||
subprocess.run([dockercmd, 'pull', baseimage], check=True)
|
||||
|
||||
def build(image, directory, platforms, build_args = None):
|
||||
def build(images, directory, platforms, build_args = None):
|
||||
if build_args is None:
|
||||
build_args = []
|
||||
build_args = list(chain.from_iterable(['--build-arg', f'{arg}={val}'] for (arg, val) in build_args))
|
||||
tags = list(chain.from_iterable(['-t', image] for image in images))
|
||||
platformlist = ','.join(platforms)
|
||||
subprocess.run([dockercmd, 'buildx', 'build', '-f', 'MinecraftDiscordBot/Dockerfile', '--platform', platformlist, '-t', image] + build_args + ['--push', directory], check=True)
|
||||
|
||||
command = [dockercmd, 'buildx', 'build', '-f', 'MinecraftDiscordBot/Dockerfile', '--platform', platformlist, *tags] + build_args + ['--push', directory]
|
||||
print(' '.join(command))
|
||||
subprocess.run(command, check=True)
|
||||
|
||||
for tag in args.tags:
|
||||
targetimage = f'chenio/mcdiscordbot:{tag}'
|
||||
baseimage = f'mcr.microsoft.com/dotnet/runtime:6.0'
|
||||
|
||||
#print(f'Pulling base image {baseimage}')
|
||||
#pull(baseimage)
|
||||
print(f'Building image {targetimage} from {baseimage}.')
|
||||
build(targetimage, '.', platforms, [('TAG', tag)])
|
||||
|
||||
def version_from_project():
|
||||
with open(r'MinecraftDiscordBot\MinecraftDiscordBot.csproj', 'r') as f:
|
||||
project = f.read()
|
||||
|
||||
regex = r"<Version>\s*([^<]*?)\s*<\/Version>"
|
||||
matches = re.search(regex, project, re.IGNORECASE)
|
||||
if not matches:
|
||||
raise Exception("Could not read version from project file!")
|
||||
return matches.group(1)
|
||||
|
||||
if len(args.tags) == 0:
|
||||
args.tags.append(version_from_project())
|
||||
|
||||
for version in args.tags:
|
||||
parts = version.split('.')
|
||||
tags = list('.'.join(parts[:i]) for i in range(1, len(parts) + 1))
|
||||
tags.append('latest')
|
||||
build([f'chenio/mcdiscordbot:{tag}' for tag in tags], '.', platforms)
|
||||
|
Loading…
x
Reference in New Issue
Block a user