docker-frecklet-packer-template-file

Description

Packer template to create a Docker image from a frecklet.

Variables

Name Type Default Description

frecklet_path

string --

The path to the frecklet file. Required

image_name

string --

The name of the Docker image to create. Required

path

string --

The path to the file. Required

freckles_extra_args

string --

Extra base args for the freckles run.

group

string --

The group of the file.

mode

string --

The permissions of the file.

owner

string --

The owner of the file.

source_image

string ubuntu

The name of the source Docker image.

Code

doc:
  short_help: Packer template to create a Docker image from a frecklet.

args:
  image_name:
    doc:
      short_help: The name of the Docker image to create.
    type: string
    required: true
  frecklet_path:
    doc:
      short_help: The path to the frecklet file.
    type: string
    required: true
  source_image:
    doc:
      short_help: The name of the source Docker image.
    type: string
    required: false
    default: ubuntu
  freckles_extra_args:
    doc:
      short_help: Extra base args for the freckles run.
    type: string
    required: false
  _import:
  - file-with-content
frecklets:
- file-with-content:
    path: '{{:: path ::}}'
    group: '{{:: group ::}}'
    owner: '{{:: owner ::}}'
    mode: '{{:: mode ::}}'
    content: |-
      {
        "builders": [
          {
            "type": "docker",
              "image": "{{:: source_image ::}}",
              "commit": true,
              "run_command": ["--name", "packer-{{:: image_name | slugify ::}}", "-d", "-i", "-t", "--entrypoint=/bin/sh", "--", "{{:: source_image ::}}"]
          }
        ],
          "provisioners": [
              {
                  "type": "shell-local",
                  "command": "freckles -c callback=default::full {%:: if freckles_extra_args ::%}{{:: freckles_extra_args ::}}{%:: endif ::%} -t docker::packer-{{:: image_name | slugify ::}} {{:: frecklet_path ::}}"
              }
          ],
        "post-processors": [
          {
            "type": "docker-tag",
            "repository": "{{:: image_name ::}}"
          }
        ]
      }
frecklecute docker-frecklet-packer-template-file --help

Usage: frecklecute docker-frecklet-packer-template-file [OPTIONS] PATH

  Packer template to create a Docker image from a frecklet.

Options:
  --frecklet-path FRECKLET_PATH   The path to the frecklet file.  [required]
  --image-name IMAGE_NAME         The name of the Docker image to create.
                                  [required]
  --freckles-extra-args FRECKLES_EXTRA_ARGS
                                  Extra base args for the freckles run.
  --group GROUP                   The group of the file.
  --mode MODE                     The permissions of the file.
  --owner USER                    The owner of the file.
  --source-image SOURCE_IMAGE     The name of the source Docker image.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.docker_frecklet_packer_template_file.DockerFreckletPackerTemplateFile
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class DockerFreckletPackerTemplateFile(AutoPycklet):
    """Packer template to create a Docker image from a frecklet.

       Args:
         freckles_extra_args: Extra base args for the freckles run.
         frecklet_path: The path to the frecklet file.
         group: The group of the file.
         image_name: The name of the Docker image to create.
         mode: The permissions of the file.
         owner: The owner of the file.
         path: The path to the file.
         source_image: The name of the source Docker image.

    """

    FRECKLET_ID = "docker-frecklet-packer-template-file"

    freckles_extra_args: str = None
    frecklet_path: str = None
    group: str = None
    image_name: str = None
    mode: str = None
    owner: str = None
    path: str = None
    source_image: str = None


    def __post_init__(self):
        super(DockerFreckletPackerTemplateFile, self).__init__(var_names=["freckles_extra_args", "frecklet_path", "group", "image_name", "mode", "owner", "path", "source_image"])


frecklet_class = DockerFreckletPackerTemplateFile
# -*- coding: utf-8 -*-


#
# module path: pycklets.docker_frecklet_packer_template_file.DockerFreckletPackerTemplateFile
#


from pyckles import AutoPycklet

class DockerFreckletPackerTemplateFile(AutoPycklet):
    """Packer template to create a Docker image from a frecklet.

       Args:
         freckles_extra_args: Extra base args for the freckles run.
         frecklet_path: The path to the frecklet file.
         group: The group of the file.
         image_name: The name of the Docker image to create.
         mode: The permissions of the file.
         owner: The owner of the file.
         path: The path to the file.
         source_image: The name of the source Docker image.

    """

    FRECKLET_ID = "docker-frecklet-packer-template-file"

    def __init__(self, freckles_extra_args=None, frecklet_path=None, group=None, image_name=None, mode=None, owner=None, path=None, source_image="ubuntu"):

        super(DockerFreckletPackerTemplateFile, self).__init__(var_names=["freckles_extra_args", "frecklet_path", "group", "image_name", "mode", "owner", "path", "source_image"])
        self._freckles_extra_args = freckles_extra_args
        self._frecklet_path = frecklet_path
        self._group = group
        self._image_name = image_name
        self._mode = mode
        self._owner = owner
        self._path = path
        self._source_image = source_image

    @property
    def freckles_extra_args(self):
        return self._freckles_extra_args

    @freckles_extra_args.setter
    def freckles_extra_args(self, freckles_extra_args):
        self._freckles_extra_args = freckles_extra_args

    @property
    def frecklet_path(self):
        return self._frecklet_path

    @frecklet_path.setter
    def frecklet_path(self, frecklet_path):
        self._frecklet_path = frecklet_path

    @property
    def group(self):
        return self._group

    @group.setter
    def group(self, group):
        self._group = group

    @property
    def image_name(self):
        return self._image_name

    @image_name.setter
    def image_name(self, image_name):
        self._image_name = image_name

    @property
    def mode(self):
        return self._mode

    @mode.setter
    def mode(self, mode):
        self._mode = mode

    @property
    def owner(self):
        return self._owner

    @owner.setter
    def owner(self, owner):
        self._owner = owner

    @property
    def path(self):
        return self._path

    @path.setter
    def path(self, path):
        self._path = path

    @property
    def source_image(self):
        return self._source_image

    @source_image.setter
    def source_image(self, source_image):
        self._source_image = source_image



frecklet_class = DockerFreckletPackerTemplateFile