-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mikael Arguedas <[email protected]>
- Loading branch information
1 parent
b45b8d1
commit bdf2f05
Showing
6 changed files
with
196 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
all: help | ||
|
||
help: | ||
@echo "" | ||
@echo "-- Help Menu" | ||
@echo "" | ||
@echo " 1. make build - build all images" | ||
@echo " 2. make pull - pull all images" | ||
@echo " 3. make clean - remove all images" | ||
@echo "" | ||
|
||
build: | ||
@docker build --tag=ignition:$release_name-$os_code_name ignition/. | ||
|
||
pull: | ||
@docker pull ignition:$release_name-$os_code_name | ||
|
||
clean: | ||
@docker rmi -f ignition:$release_name-$os_code_name |
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,13 @@ | ||
%YAML 1.1 | ||
# Ignition Dockerfile database | ||
--- | ||
images: | ||
ignition: | ||
base_image: @(os_name):@(os_code_name) | ||
maintainer_name: @(maintainer_name) | ||
template_name: docker_images/create_ignition_image.Dockerfile.em | ||
# entrypoint_name: docker_images/no_entrypoint.sh | ||
template_packages: | ||
- docker_templates | ||
ignition_packages: | ||
- ignition-@(ignition_version) |
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,13 @@ | ||
%YAML 1.1 | ||
# Ignition Dockerfile database | ||
--- | ||
platform: | ||
os_name: $os_name | ||
os_code_name: $os_code_name | ||
ignition_version: $release_name | ||
user_name: ignition | ||
maintainer_name: | ||
arch: amd64 | ||
type: distribution | ||
version: | ||
release: stable |
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,70 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import yaml | ||
|
||
try: | ||
from cStringIO import StringIO | ||
except ImportError: | ||
from io import StringIO | ||
from em import Interpreter | ||
|
||
from docker_templates.argparse import DockerfileArgParser | ||
from docker_templates.create import create_files | ||
from docker_templates.collections import OrderedLoad | ||
from docker_templates.packages import expandPackages | ||
|
||
def main(argv=sys.argv[1:]): | ||
"""Create Dockerfiles for images from platform and image yaml data""" | ||
|
||
# Create the top-level parser | ||
parser = DockerfileArgParser( | ||
description="Generate the 'Dockerfile's for the base docker images") | ||
parser.set() | ||
args = parser.parse(argv) | ||
|
||
# Read platform params | ||
with open(args.platform, 'r') as f: | ||
# use safe_load instead load | ||
platform = yaml.safe_load(f)['platform'] | ||
|
||
# Read image params using platform params | ||
images_yaml = StringIO() | ||
try: | ||
interpreter = Interpreter(output=images_yaml) | ||
interpreter.file(open(args.images, 'r'), locals=platform) | ||
images_yaml = images_yaml.getvalue() | ||
except Exception as e: | ||
print("Error processing %s" % args.images) | ||
raise | ||
finally: | ||
interpreter.shutdown() | ||
interpreter = None | ||
# Use ordered dict | ||
images = OrderedLoad(images_yaml, yaml.SafeLoader)['images'] | ||
|
||
# For each image tag | ||
for image in images: | ||
|
||
# Get data for image | ||
data = dict(images[image]) | ||
data['tag_name'] = image | ||
|
||
# Add platform params | ||
data.update(platform) | ||
|
||
# Apply package distro/version formatting | ||
expandPackages(data) | ||
|
||
# Get path to save Docker file | ||
dockerfile_dir = os.path.join(args.output, image) | ||
if not os.path.exists(dockerfile_dir): | ||
os.makedirs(dockerfile_dir) | ||
data['dockerfile_dir'] = dockerfile_dir | ||
|
||
# generate Dockerfile | ||
create_files(data) | ||
|
||
if __name__ == '__main__': | ||
main() |
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,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import yaml | ||
|
||
import create_dockerfiles | ||
|
||
from docker_templates.argparse import DockerfolderArgParser | ||
from docker_templates.collections import OrderedLoad | ||
from docker_templates.folders import populate_paths | ||
|
||
|
||
def main(argv=sys.argv[1:]): | ||
"""Create Dockerfolders for images from manifest yaml data""" | ||
|
||
# Create the top-level parser | ||
parser = DockerfolderArgParser( | ||
description="Generate the Dockerfolders for the base docker images") | ||
parser.set() | ||
args = parser.parse(argv) | ||
|
||
# Read manifest params | ||
with open(args.manifest, 'r') as f: | ||
manifest = OrderedLoad(f, yaml.SafeLoader) | ||
|
||
# Populate all paths from the manifest | ||
populate_paths(manifest, args, create_dockerfiles) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import git | ||
import os | ||
import sys | ||
import yaml | ||
|
||
import ros_buildfarm.templates | ||
|
||
from docker_templates.argparse import DockerlibraryArgParser | ||
from docker_templates.collections import OrderedLoad | ||
from docker_templates.create import expand_template_prefix_path, create_dockerlibrary | ||
from docker_templates.library import parse_manifest | ||
|
||
default_template_prefix_path = ros_buildfarm.templates.template_prefix_path | ||
PWD = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
def main(argv=sys.argv[1:]): | ||
"""Create Dockerlibrary for images from manifest yaml data""" | ||
|
||
# Create the top-level parser | ||
parser = DockerlibraryArgParser( | ||
description="Generate the 'Dockerlibrary for the base docker images") | ||
parser.set() | ||
args = parser.parse(argv) | ||
|
||
# Read manifest params | ||
with open(args.manifest, 'r') as f: | ||
manifest = OrderedLoad(f, yaml.SafeLoader) | ||
|
||
# Create a git diff for the current repo | ||
repo = git.Repo(os.path.join(PWD, '..')) # , odbt=git.GitCmdObjectDB) | ||
|
||
# Parse the manifest | ||
repo_name = os.path.basename(PWD) | ||
manifest = parse_manifest(manifest, repo, repo_name) | ||
|
||
# Flattin manifest data | ||
data = {**manifest, **manifest['meta']} | ||
|
||
# Create Docker Library | ||
template_name = data['template_name'] | ||
template_packages = data['template_packages'] | ||
expand_template_prefix_path(template_packages) | ||
create_dockerlibrary(template_name, data, args.output) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |