Skip to main content

""

Project description

docker-build-yaml (dbyml)

docker-build-yaml (dbyml) is a CLI tool to build a docker image with arguments loaded from yaml. Instead of running the docker build with many options, write options in config file, build your docker image with them. It helps you to manage build process more readable and flexible.

Install

pip install dbyml

Usage

Preparation

Dbyml is useful for building your docker image. To build an image, you must make your Dockerfile and config file where the build arguments are listed. For example, we will make the example Dockerfile and dbyml.yml in the same directory.

  • Dockerfile
    • Dbyml does not required any settings about Dockerfile, so you can write according to Dockerfile reference.
FROM alpine:latest
ARG key1
RUN echo key1
# You can write any process
  • dbyml.yml
    • This is a config file used by dbyml.
    • The image name field name is required.
    • The image tag field tag is optional. Default value is latest.
---
name: myimage
tag: v1.0

Build

Run dbyml to build the image from your Dockerfile.

dbyml 

If Dockerfile and config file are not in the same directory, you must set path to the Dockerfile with path field in the config.

---
name: myimage
tag: v1.0
path: path/to/Dockerfile

Configuration

The behavior of dbyml is managed by the config file written in yaml syntax.

Config file

Dbyml automatically searches for config file dbyml.yml or dbyml.yaml in the execution directory. If you want to use other filename or path, you need run dbyml with -c option to specify path to the config.

dbyml -c [path_to_config_file]

ENV variables

You can use environment variable expressions in config. ${VAR_NAME} and setting default_value ${VAR_NAME:-default_value} are supported. Error occurs when the specified env is undefined.

---
name: ${BASEIMAGE_NAME}
tag: ${VERSION:-latest}

Push to repository

Dbyml supports to push the image to docker registry v2 in local.

To push the image to be built from your Dockerfile, The push fields are required in config. You must set the hostname (or ip address) and port of the registry. Setting enabled to true enables these settings. Setting to false disables the settings, which means dose not push the image after building.

---
name: myimage
tag: v1.0

push:
    enabled: true
    registry:
        host: "myregistry" # Registry hostname or ip address 
        port: "5000" # Registry port

Running dbyml with the config will make the docker image myimage:v1.0, then push it to the registry as the image name of myregistry:5000/myimage:v1.0. You can check that the image has been successfully pushed to the registry such as registry API.

If you want to add more hierarchy in repository, set namespace field in config. The image will be pushed as {hostname}:{port}/{namespace}/{name}:{tag}.

---
name: myimage
tag: v1.0

push:
    enabled: true
    registry:
        host: "myregistry" # Registry hostname or ip address 
        port: "5000" # Registry port
    namespace: myspace

If you use the basic authentication to access to the registry build by Native basic auth, you need set username and password fields under path in the config.

---
name: myimage
tag: v1.0

push:
    enabled: true
    username: ${username}
    password: ${password}
    registry:
        host: "myregistry" # Registry hostname or ip address 
        port: "5000" # Registry port

other settings

See sample.yml for supported fields.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbyml-1.0.0.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

dbyml-1.0.0-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page