Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build.py): add cli flag to use podman instead of docker #379

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 22 additions & 8 deletions build.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
Loading