Skip to content

Commit a90742f

Browse files
committed
Merge branch 'feature/support_podman_update_images' into 'master'
Add support for podman and miscellaneous updates See merge request evernym/utilities/devlab!23
2 parents e436eba + e8e10e6 commit a90742f

9 files changed

Lines changed: 54 additions & 52 deletions

File tree

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ image: $CI_REGISTRY_IMAGE/devlab-build:latest
33

44
.tags:
55
tags:
6-
- docker
6+
- saas-linux-small-amd64
77

88
stages:
99
- docker-images
@@ -19,7 +19,7 @@ stages:
1919
- branches
2020
- merge_requests
2121
tags:
22-
- docker
22+
- saas-linux-small-amd64
2323
image:
2424
name: gcr.io/kaniko-project/executor:debug
2525
entrypoint: [""]

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ The configuration file has the following base structure:
105105
"project_filter": "",
106106
"reprovisionable_components": [],
107107
"runtime_images": {},
108-
"wizard_enabled": true
108+
"wizard_enabled": true,
109+
"disable_buildkit": false
109110
}
110111
```
111112

@@ -123,6 +124,7 @@ All Keys that are in **bold** are required to be in the config
123124
| reprovisionable_components | List of Strings | List of component names that need to reprovisioned (contianer stopped, and removed, then started and provisioned again) if the hosts' IP changes) |
124125
| runtime_images | Hash of Hashes | Defines custom images that components might be using. These images etc.. would provided by, and maintained by the project. First level key is a string of the name of the image. Structure conforms to [Runtime Image Structure](#runtime-image-structure) |
125126
| wizard_enabled | Boolean | Whether or not to try and execute a wizard if found in the root of the project |
127+
| disable_buildkit | Boolean | Whether the DOCKER_BUILDKIT env var should be set to `0` when building images |
126128

127129
## Component Config Structure
128130
The structure looks like this:

devlab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# vim: set syntax=python et ts=4 sw=4 sts=4:
33
"""
44
Main script for managing the devlab environment stack

devlab_bench/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
},
4343
'reprovisionable_components': [],
4444
'runtime_images': {},
45-
'paths': {}
45+
'paths': {},
46+
'disable_buildkit': False
4647
}
4748
LOGGING_LEVELS = {
4849
'debug': logging.DEBUG,

devlab_bench/actions/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def action(images='*', clean=False, no_cache=False, pull=False, skip_pull_images
166166
image_args['docker_file'] = image_args['docker_file_full_path']
167167
del image_args['docker_file_full_path']
168168
log.debug("image: '%s' context='%s' log_output='%s' other_args='%s'", image, image_context, log_output, image_args)
169-
bld_res = docker_helper_obj.build_image(image, context=image_context, log_output=log_output, network=config['network']['name'], logger=logging.getLogger('Build-{}'.format(image)), **image_args)
169+
bld_res = docker_helper_obj.build_image(image, context=image_context, log_output=log_output, network=config['network']['name'], disable_build_kit=config['disable_buildkit'], logger=logging.getLogger('Build-{}'.format(image)), **image_args)
170170
if bld_res[0] != 0:
171171
log.error("Failed building image: '%s' Aborting...", image)
172172
abort = True

devlab_bench/helpers/command.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,15 @@ def _process_output(self, max_lines=100, flush=False):
175175
stdout_dangle = self._sanitize_string(self.proc.stdout.read())
176176
if stdout_dangle:
177177
if self.log_output:
178-
self.log.info(stdout_dangle)
178+
for stdout_dangle_line in stdout_dangle.splitlines():
179+
self.log.info(stdout_dangle_line)
179180
self.stdout.append(stdout_dangle)
180181
if self.proc.stderr:
181182
stderr_dangle = self._sanitize_string(self.proc.stderr.read())
182183
if stderr_dangle:
183184
if self.log_output:
184-
self.log.error(stderr_dangle)
185+
for stderr_dangle_line in stderr_dangle.splitlines():
186+
self.log.warning(stderr_dangle_line)
185187
self.stderr.append(stderr_dangle)
186188
break
187189
except OSError:

devlab_bench/helpers/docker.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,25 @@ def __init__(self, filter_label=None, labels=None, common_domain=None, skip_chec
3535
'/usr/bin/docker',
3636
'/usr/local/bin/docker',
3737
'/usr/sbin/docker',
38-
'/bin/docker'
38+
'/bin/docker',
39+
'/opt/podman/bin/podman',
40+
'/usr/bin/podman',
41+
'/usr/local/bin/podman'
3942
)
43+
self.eng_is = 'unknown'
4044
self.filter_label = filter_label
4145
self.common_domain = common_domain
4246
self.opt_domainname = False
4347
if not skip_checks:
4448
self._pre_check()
4549
self.labels = labels
50+
path_check = Command(self.docker_bin_paths)._precheck()
51+
if path_check[0] == 0:
52+
if 'podman' in path_check[1]:
53+
self.eng_is = 'podman'
54+
if 'docker' in path_check[1]:
55+
self.eng_is = 'docker'
56+
self.log.debug("Docker engine type found is: %s", self.eng_is)
4657
def _pre_check(self):
4758
"""
4859
Checks to make sure the script is being run as the root user, or a
@@ -60,7 +71,7 @@ def _pre_check(self):
6071
dchk = Command(self.docker_bin_paths, ['run', '--help'], logger=self.log, split=False).run()
6172
if '--domainname' in dchk[1]:
6273
self.opt_domainname = True
63-
def build_image(self, name, tag, context, docker_file, apply_filter_label=True, build_opts=None, logger=None, network=None, **kwargs):
74+
def build_image(self, name, tag, context, docker_file, apply_filter_label=True, build_opts=None, disable_buildkit=False, logger=None, network=None, **kwargs):
6475
"""
6576
Build a docker image.
6677
@@ -112,10 +123,11 @@ def build_image(self, name, tag, context, docker_file, apply_filter_label=True,
112123
]
113124
if os.path.isfile(docker_file):
114125
with open(docker_file) as stdin:
115-
if 'env' in kwargs:
116-
kwargs['env'].update({'DOCKER_BUILDKIT': "0"})
117-
else:
118-
kwargs['env'] = {'DOCKER_BUILDKIT': "0"}
126+
if disable_buildkit:
127+
if 'env' in kwargs:
128+
kwargs['env'].update({'DOCKER_BUILDKIT': "0"})
129+
else:
130+
kwargs['env'] = {'DOCKER_BUILDKIT': "0"}
119131
cmd_ret = Command(
120132
self.docker_bin_paths,
121133
opts,
@@ -287,6 +299,10 @@ def get_images(self, return_all=False):
287299
opts = [
288300
'images'
289301
]
302+
podman_specific_prepends = [
303+
'localhost/', # These are podman local images
304+
'docker.io/library/' # These are docker.io hosted images
305+
]
290306
if self.filter_label and not return_all:
291307
opts.append('--filter')
292308
opts.append('label={}'.format(self.filter_label))
@@ -297,6 +313,21 @@ def get_images(self, return_all=False):
297313
opts,
298314
logger=self.log
299315
).run()
316+
if self.eng_is == 'podman':
317+
if cmd_ret[0] == 0:
318+
self.log.debug('Normalizing podman specific image output to match docker\'s format')
319+
new_list = []
320+
for cline in cmd_ret[1]:
321+
modified = False
322+
for pman_prep in podman_specific_prepends:
323+
if cline.startswith(pman_prep):
324+
new_name = cline[len(pman_prep):]
325+
new_list.append(new_name)
326+
self.log.debug("Normalized container image: '%s' -> '%s'", cline, new_name)
327+
modified = True
328+
if not modified:
329+
new_list.append(cline)
330+
cmd_ret = (cmd_ret[0], new_list)
300331
return cmd_ret
301332
def get_networks(self, return_all=False):
302333
"""

docker/base.Dockerfile

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:24.04
22
LABEL "com.lab.devlab"="base"
3-
LABEL "last_modified"=1597871407
3+
LABEL "last_modified"=1713305264
44

55
ARG APT="/usr/bin/apt-get --no-install-recommends -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef"
66
ARG PACKAGES="sudo less screen tmux vim ca-certificates git curl iproute2 less gnupg2"
@@ -10,37 +10,3 @@ RUN $APT update && \
1010
$APT upgrade -y && \
1111
$APT install -y $PACKAGES && \
1212
rm -rf /var/lib/apt/lists/*
13-
14-
# Provide Evernym CA
15-
RUN mkdir -p /usr/local/share/ca-certificates/ && \
16-
echo '-----BEGIN CERTIFICATE-----\n\
17-
MIIFJTCCAw2gAwIBAgIUMI0Z8YSLeRq8pZks40O3Dq2m8TIwDQYJKoZIhvcNAQEL\n\
18-
BQAwGjEYMBYGA1UEAxMPRXZlcm55bS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CwUAA4ICAQCwjN3ggZ98\n\
34-
BXT39fKkCX3FHb0++aFcIyMKWrcZIpYrl3GoZsNKZK4QNQ+uJOP8xmqgyrCoMfch\n\
35-
VIGPQ0RDN/IzqCLhc/U3pDmk2hXa3xTxD3gpCQZ6Bz04KlcLfZd5jzbI741bVDyF\n\
36-
a1n46bEyuqV4SsNJWI/FGokJCNcZH66njBQBaQAccZ7xB9vWU9yjIYtGQDDvSm6J\n\
37-
SC2knrQri0vv4QLUSc1LS6AlWWSQxcCpcdO+OzIFGsf5bVmYN6J4R3COY5NyQ+yn\n\
38-
pOSN2NOh5h3ZrYAxm3i4Il0orVLveVcTVDGeAgZUII4YLJi/01RHGqit3aCuApSh\n\
39-
bzFTZ5FldFss+JX9iAhqpFDbHLgae0F3QmYEnGilt/PzO4j23QJo3FZKeruQLH7P\n\
40-
L9aOgN6S2+Akbbm9YTc59yzU5TZMxANwTdaYFWFqk/8nKgZiBR1l8jnWTlWnm86A\n\
41-
qVssH3DLKwiYrWSOHRzGuN5BmPXxxtKQJlwAXt0wJE3puUkaJSRo7CJQ3QNMoKDe\n\
42-
OjzXc9WvkFIXr3Eui8UTiHB/WT7N4o8hmVN404akGfWE0YNwRVfWpjGdew6g0tZi\n\
43-
lFnjUUk49av67um43JHcinT5NFPuleZzkjaL/D8ueOrjXQDy05rwVdgmw9pXog4B\n\
44-
Tw6APXtEnjfD2H8HOpOX/7ef4gWK0O1Q7A==\n\
45-
-----END CERTIFICATE-----\n' > /usr/local/share/ca-certificates/Evernym_Root_CA.crt && \
46-
/usr/sbin/update-ca-certificates

docker/helper.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM devlab_base:latest
22
LABEL "com.lab.devlab"="base"
3-
LABEL "last_modified"=1597871407
3+
LABEL "last_modified"=1713305264
44

55

66
ARG APT="/usr/bin/apt-get --no-install-recommends -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef"
7-
ARG PACKAGES="docker.io python python3 python-yaml python3-yaml mysql-client netcat"
7+
ARG PACKAGES="docker.io python3 python3-yaml mysql-client netcat-traditional"
88
ENV DEBIAN_FRONTEND=noninteractive
99

1010
RUN $APT update && \

0 commit comments

Comments
 (0)