diff --git a/README.md b/README.md index 0787330..d57e371 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ This will result in docker image called `octobot:latest` that you can deploy as * Make sure that whatever path you map `/data` to is a persistent location since this is where configuration is stored. * Create a `config.toml` file in this location before deploying (see below). +Using podman? use `build.py --use-podman` + ### Configuration There is one main config file to know about. Hopefully this examples will be sufficiently explanatory: diff --git a/build.py b/build.py index 323baa3..585d58a 100755 --- a/build.py +++ b/build.py @@ -1,11 +1,25 @@ #!/usr/bin/env python3 +import argparse import os import re import shutil import subprocess +parser = argparse.ArgumentParser(description='Build Octobot and package in a container') +parser.add_argument( + '--use-podman', + action='store_true', + help='Use podman to build container instead of docker', +) + +args = parser.parse_args() +engine = 'docker' +if args.use_podman: + engine = 'podman' + is_travis = os.environ.get('TRAVIS') is not None + class task: def __init__(self, title): self.title = title @@ -35,17 +49,17 @@ def run(cmd, ignore_fail=False, quiet=False): os.makedirs(docker_out) with task("Dockerfile.build"): - run("docker build . -f Dockerfile.build -t octobot:build") + run("{} build . -f Dockerfile.build -t octobot:build".format(engine)) with task("extract_files"): - run("docker rm -f extract", ignore_fail=True, quiet=True) - run("docker create --name extract octobot:build") - run("docker cp extract:/usr/src/app/target/release/octobot {}".format(docker_out)) - run("docker cp extract:/usr/src/app/target/release/octobot-passwd {}".format(docker_out)) - run("docker cp extract:/usr/src/app/target/release/octobot-ask-pass {}".format(docker_out)) - run("docker rm -f extract") + run("{} rm -f extract".format(engine), ignore_fail=True, quiet=True) + run("{} create --name extract octobot:build".format(engine)) + run("{} cp extract:/usr/src/app/target/release/octobot {}".format(engine, docker_out)) + run("{} cp extract:/usr/src/app/target/release/octobot-passwd {}".format(engine, docker_out)) + run("{} cp extract:/usr/src/app/target/release/octobot-ask-pass {}".format(engine, docker_out)) + run("{} rm -f extract".format(engine)) # write out the version file commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']) with open(os.path.join(docker_out, 'version'), 'wb') as f: f.write(commit_hash) with task("Dockerfile"): - run("docker build . -t octobot:latest") + run("{} build . -t octobot:latest".format(engine))