docker-image-from-frecklets
Example:
# Build a docker image with Java installed. - docker-image-from-frecklets: frecklets: - java-lang-installed name: freckles-java
Description
Build a Docker image from a frecklet.
This is just a proof-of-concept, to show that sometime like this is easily possible. It currently only works with Debian-based base images, as the pre-written Dockerfile template uses 'apt' to install curl. This would be easily changed once this is done properly.
Resources
Variables
Name | Type | Default | Description |
---|---|---|---|
|
list | -- | The frecklets to use in the Docker container. Required |
|
string | -- | The name of the image. Required |
|
string | ubuntu:18.04 | The base image to use. |
|
boolean | False | Whether to force the build to be done, even if an image with that name exists already. |
|
boolean | False | Whether to use cache when building an image. |
Examples
Example 1
Build a docker image with Java installed.
Code
- docker-image-from-frecklets: frecklets: - java-lang-installed name: freckles-java
Example 2
Build a docker image with both Java & Go installed
Code
- docker-image-from-frecklets: name: freckles-java-go frecklets: - java-lang-installed - go-lang-installed force: true no_cache: true
Description
Don't use the Docker cache, and build the image even if an image named 'freckles-java-go' already exists.
Code
doc: short_help: Build a Docker image from a frecklet. help: | Build a Docker image from a frecklet. This is just a proof-of-concept, to show that sometime like this is easily possible. It currently only works with Debian-based base images, as the pre-written Dockerfile template uses 'apt' to install curl. This would be easily changed once this is done properly. references: "'docker_image' Ansible module": https://docs.ansible.com/ansible/latest/modules/docker_image_module.html examples: - title: Build a docker image with Java installed. vars: frecklets: - java-lang-installed name: freckles-java - title: Build a docker image with both Java & Go installed desc: | Don't use the Docker cache, and build the image even if an image named 'freckles-java-go' already exists. vars: name: freckles-java-go frecklets: - java-lang-installed - go-lang-installed force: true no_cache: true args: _import: docker-image-from-folder frecklets: doc: short_help: The frecklets to use in the Docker container. type: list schema: type: string required: true empty: false cli: param_decls: - --frecklet - -f base_image: doc: short_help: The base image to use. type: string default: ubuntu:18.04 required: false frecklets: - path-is-absent: path: '/tmp/_frecklet_docker_build/{{:: name ::}}' - folder-exists: path: '/tmp/_frecklet_docker_build/{{:: name ::}}' mode: '0700' - file-with-content: path: '/tmp/_frecklet_docker_build/{{:: name ::}}/Dockerfile' content: | FROM {{:: base_image ::}} # necessary if no locale is set ENV LC_CTYPE C.UTF-8 RUN apt update && apt install -y curl RUN curl https://freckles.sh | bash {%:: for frecklet in frecklets ::%} RUN /root/.local/share/freckles/bin/frecklecute --community {{:: frecklet ::}} {%:: endfor ::%} RUN rm -rf /root/.local/share/freckles RUN rm -rf /root/.cache/freckles - docker-image-from-folder: name: '{{:: name ::}}' base_path: '/tmp/_frecklet_docker_build/{{:: name ::}}' nocache: '{{:: nocache ::}}' force: '{{:: force ::}}'
frecklecute docker-image-from-frecklets --help Usage: frecklecute docker-image-from-frecklets [OPTIONS] Build a Docker image from a frecklet. This is just a proof-of-concept, to show that sometime like this is easily possible. It currently only works with Debian-based base images, as the pre-written Dockerfile template uses 'apt' to install curl. This would be easily changed once this is done properly. Options: -f, --frecklet FRECKLETS The frecklets to use in the Docker container. [required] --name NAME The name of the image. [required] --base-image BASE_IMAGE The base image to use. --force / --no-force Whether to force the build to be done, even if an image with that name exists already. --no-cache Whether to use cache when building an image. --help Show this message and exit.
# -*- coding: utf-8 -*- # # module path: pycklets.docker_image_from_frecklets.DockerImageFromFrecklets # from dataclasses import dataclass from pyckles import AutoPycklet from typing import * # noqa @dataclass class DockerImageFromFrecklets(AutoPycklet): """Build a Docker image from a frecklet. This is just a proof-of-concept, to show that sometime like this is easily possible. It currently only works with Debian-based base images, as the pre-written Dockerfile template uses 'apt' to install curl. This would be easily changed once this is done properly. Args: base_image: The base image to use. force: Whether to force the build to be done, even if an image with that name exists already. frecklets: The frecklets to use in the Docker container. name: The name of the image. nocache: Whether to use cache when building an image. """ FRECKLET_ID = "docker-image-from-frecklets" base_image: str = None force: bool = None frecklets: List = None name: str = None nocache: bool = None def __post_init__(self): super(DockerImageFromFrecklets, self).__init__(var_names=["base_image", "force", "frecklets", "name", "nocache"]) frecklet_class = DockerImageFromFrecklets
# -*- coding: utf-8 -*- # # module path: pycklets.docker_image_from_frecklets.DockerImageFromFrecklets # from pyckles import AutoPycklet class DockerImageFromFrecklets(AutoPycklet): """Build a Docker image from a frecklet. This is just a proof-of-concept, to show that sometime like this is easily possible. It currently only works with Debian-based base images, as the pre-written Dockerfile template uses 'apt' to install curl. This would be easily changed once this is done properly. Args: base_image: The base image to use. force: Whether to force the build to be done, even if an image with that name exists already. frecklets: The frecklets to use in the Docker container. name: The name of the image. nocache: Whether to use cache when building an image. """ FRECKLET_ID = "docker-image-from-frecklets" def __init__(self, base_image="ubuntu:18.04", force=None, frecklets=None, name=None, nocache=None): super(DockerImageFromFrecklets, self).__init__(var_names=["base_image", "force", "frecklets", "name", "nocache"]) self._base_image = base_image self._force = force self._frecklets = frecklets self._name = name self._nocache = nocache @property def base_image(self): return self._base_image @base_image.setter def base_image(self, base_image): self._base_image = base_image @property def force(self): return self._force @force.setter def force(self, force): self._force = force @property def frecklets(self): return self._frecklets @frecklets.setter def frecklets(self, frecklets): self._frecklets = frecklets @property def name(self): return self._name @name.setter def name(self, name): self._name = name @property def nocache(self): return self._nocache @nocache.setter def nocache(self, nocache): self._nocache = nocache frecklet_class = DockerImageFromFrecklets