mcdiscordbot/checkcompat.py
Michael Chen d8c1f81023
Initial Build
Multiarch docker build
Unified logging (replaced some crashes with error logs)
Replace all console writes with log formatted writes.

Changelog: added
2022-01-12 14:47:16 +01:00

28 lines
1.1 KiB
Python

#!python
import subprocess
import argparse
parser = argparse.ArgumentParser(description='Check platform compatibility with Python.')
parser.add_argument('tag', metavar='TAG', help='Version tag to build.')
args = parser.parse_args()
tag = args.tag
sourcetag = tag
baseimage = f'mcr.microsoft.com/dotnet/runtime:6.0'
targetimage = f'chenio/mcdiscordbot:{tag}'
platforms = ['linux/amd64', 'linux/arm64', 'linux/riscv64', 'linux/ppc64le', 'linux/s390x', 'linux/386', 'linux/mips64le', 'linux/mips64', 'linux/arm/v7', 'linux/arm/v6']
compatible_archs = []
print(f'Pulling base image {baseimage}')
subprocess.run(['docker', 'pull', baseimage], check=True)
for platform in platforms:
print(f'Try building image {targetimage} for architecture {platform}.')
proc = subprocess.run(['docker', 'buildx', 'build', '-f', 'MinecraftDiscordBot/Dockerfile', '--platform', platform, '-t', targetimage, '.'])
if proc.returncode == 0:
compatible_archs.append(platform)
print(f'Successful platforms for {baseimage}:')
for platform in compatible_archs:
print(f'\t- {platform}')