forked from cekit/cekit
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes cekit#363.
- Loading branch information
Showing
6 changed files
with
110 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import logging | ||
import os | ||
import subprocess | ||
|
||
from cekit.builder import Builder | ||
from cekit.errors import CekitError | ||
|
||
LOGGER = logging.getLogger('cekit') | ||
|
||
|
||
class PodmanBuilder(Builder): | ||
"""This class represents podman builder in build mode.""" | ||
|
||
def __init__(self, common_params, params): | ||
super(PodmanBuilder, self).__init__('podman', common_params, params) | ||
|
||
@staticmethod | ||
def dependencies(): | ||
deps = {} | ||
|
||
deps['podman'] = { | ||
'package': 'podman', | ||
'executable': 'podman' | ||
} | ||
|
||
return deps | ||
|
||
def run(self): | ||
"""Build container image using podman.""" | ||
tags = self.params.tags | ||
cmd = ["/usr/bin/podman", "build"] | ||
|
||
if self.params.pull: | ||
cmd.append('--pull-always') | ||
|
||
# Custom tags for the container image | ||
LOGGER.debug("Building image with tags: '%s'" % | ||
"', '".join(tags)) | ||
|
||
for tag in tags: | ||
cmd.extend(["-t", tag]) | ||
|
||
LOGGER.info("Building container image...") | ||
|
||
cmd.append(os.path.join(self.target, 'image')) | ||
|
||
LOGGER.debug("Running Podman build: '%s'" % " ".join(cmd)) | ||
|
||
try: | ||
subprocess.check_call(cmd) | ||
|
||
LOGGER.info("Image built and available under following tags: %s" | ||
% ", ".join(tags)) | ||
except: | ||
raise CekitError("Image build failed, see logs above.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters