Skip to content

Add configuration to use podman when building on Fedora #1941

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 18 additions & 11 deletions docker/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@
# manually, but will be excluded by default when selecting all images.
OLD = [ 'ubuntu-14.04', 'fedora-29', 'fedora-30', 'fedora-31' ]


# Workaround for building on Fedora >=31 with cgroups v2 where docker fails
# Reference: https://www.linuxuprising.com/2019/11/how-to-install-and-use-docker-on-fedora.html
# After 'sudo dnf install podman'
# Comment and uncomment appropriate lines to use podman
docker_command='docker'
# docker_command='podman' # Uncomment this line to use podman
# Because when using podman with non root user, would need extra argument to volumes
volume_flag=':Z' if docker_command=='podman' else ''
namespace_flag='--userns=keep-id' if docker_command=='podman' else ''

@task(
aliases=['build_image', 'bi'],
Expand All @@ -45,9 +53,9 @@ def build_images(ctx, image, gui=False, include_old=False):
img_type = 'gui' if gui else 'build'
for img_name in image:
# build it
ctx.run('docker build --no-cache '
ctx.run('{command} build --no-cache '
'-f {type}/{name}/Dockerfile '
'-t wxpython4/{type}:{name} .'.format(name=img_name, type=img_type),
'-t wxpython4/{type}:{name} .'.format(command=docker_command, name=img_name, type=img_type),
pty=True, echo=True)
# test it
test_images(ctx, [img_name], gui)
Expand All @@ -74,8 +82,8 @@ def test_images(ctx, image, gui=False, include_old=False):
img_type = 'gui' if gui else 'build'
for img_name in image:
# test it
ctx.run('docker run -it --rm -v {}:/dist '
'wxpython4/{}:{} hello.sh'.format(dist, img_type, img_name),
ctx.run('{} run {} -it --rm -v {}:/dist{} '
'wxpython4/{}:{} hello.sh'.format(docker_command, namespace_flag, dist, volume_flag, img_type, img_name),
pty=True, echo=True)


Expand All @@ -100,7 +108,7 @@ def push(ctx, image, gui=False, include_old=False):
for img_name in image:
# build it
ctx.run(
'docker push wxpython4/{type}:{name}'.format(name=img_name, type=img_type),
'{command} push wxpython4/{type}:{name}'.format(command=docker_command, name=img_name, type=img_type),
pty=True, echo=True)


Expand Down Expand Up @@ -130,8 +138,8 @@ def build_wxpython(ctx, image, venv='all', port='gtk3', include_old=False, keep=
dist=os.path.abspath('../dist')
rm = '' if keep else '--rm'
for img_name in image:
ctx.run('docker run -it {} -v {}:/dist '
'wxpython4/build:{} do-build.sh {} {}'.format(rm, dist, img_name, venv, port),
ctx.run('{} run {} -it {} -v {}:/dist{} '
'wxpython4/build:{} do-build.sh {} {}'.format(docker_command, namespace_flag, rm, dist, volume_flag, img_name, venv, port),
pty=True, echo=True)


Expand All @@ -154,9 +162,8 @@ def run(ctx, image_tag, cmd=None, gui=False, port=5901, keep=False):
imgtype = 'gui' if gui else 'build'
cmd = '' if cmd is None else cmd
rm = '' if keep else '--rm'
ctx.run(
'docker run -it {} -v {}:/dist -p {}:5901 wxpython4/{}:{} {}'.format(
rm, dist, port, imgtype, image_tag, cmd),
ctx.run( '{} run {} -it {} -v {}:/dist{} -p {}:5901 wxpython4/{}:{} {}'.format(docker_command,
namespace_flag, rm, dist, volume_flag, port, imgtype, image_tag, cmd),
pty=True, echo=True)


Expand Down