Giter Club home page Giter Club logo

ansible-build-and-push-docker-image's Introduction

Build and Push Docker Images

This role lets you easy build (lokal) and push a docker image. Just prepare an Image (Dockerfile) in a directory within your playbook and configure the role with parameters.

It will skip te build, if the image already exists locally. So it is important, that you change the Version if you want to build a new image.

Don't change the vars in this role directly. Use role-vars (see example).

This role has the python dependency: docker-py

It will fail, if the dependency is not installed.

If you don't want to push your image into a registry, use the transfer function of this playbook. The image will be exported (docker save), transfered to the server and imported (docker load). It will even tag it on the server as it would be in a registry.

Changelog

  • v2.0.5 (19.07.2018)
    • Add default argument for docker build arguments.
  • v2.0.4 (16.07.2018)
    • Added build argument passing to Dockerfile.
  • v2.0.3 (10.04.2018)
    • Added the ability to transfer an image pulled from a registry - without build.
  • v2.0.2 (10.04.2018)
    • Just some readme fixes.
  • v2.0.1 (10.04.2018)
    • Check if version actually contains dots.
  • v2.0.0 (06.04.2018)
    • You can now also transfer an image to a server without going through a registry.

Installation

ansible-galaxy install git+https://github.com/unglaublicherdude/ansible-build-and-push-docker-image.git

Example

Simple build and push

    - {
      role: build-and-push-docker-image,
      build_and_push_image_name: "registryhost.tld/image",
      build_and_push_docker_file_path: "./files/docker/image",
      build_and_push_image_version: "1.0.0",
    }

This will build a prometheus image. Tag it with the following tags

  • 1.0.0
  • 1.0
  • 1
  • latest and push it to the given registry path.

Just build the images

You don't want the images to get Pushed?

    - {
      role: build-and-push-docker-image,
      build_and_push_image_name: "registryhost.tld/image",
      build_and_push_docker_file_path: "./files/docker/image",
      build_and_push_image_version: "1.0.0",
      build_and_push_push: false
    }

Just need a latest

    - {
      role: build-and-push-docker-image,
      build_and_push_image_name: "registryhost.tld/image",
      build_and_push_docker_file_path: "./files/docker/image",
      build_and_push_image_version: "1.0.0",
      build_and_push_push: false,
      build_and_push_tag_versions: false
    }

The explizit Version is always build. It is needed for the version comarison.

Transfer without push to a registry

    - {
      role: build-and-push-docker-image,
      build_and_push_image_name: "registryhost.tld/image",
      build_and_push_docker_file_path: "./files/docker/image",
      build_and_push_image_version: "1.0.0",
      build_and_push_push: false,
      build_and_push_transfer: true,
      build_and_push_transfer_tmp_image_dir: /tmp/docker/images # on the server
    }

Transfer without build and push

    - {
      role: build-and-push-docker-image,
      build_and_push_image_name: "jwilder/whoami",
      build_and_push_image_build: false,
      build_and_push_push: false,
      build_and_push_transfer: true,
      build_and_push_transfer_tmp_image_dir: /tmp/docker/images,
      build_and_push_image_version: "latest"
    }

Handing build arguments to the Dockerfile

    - {
      role: build-and-push-docker-image,
      build_and_push_image_name: "registryhost.tld/image",
      build_and_push_docker_file_path: "./files/docker/image",
      build_and_push_image_version: "1.0.0",
      build_and_push_args: 
      {
        some_password_from_the_vault: "{{some_password_from_the_vault}}",
        myfancypath: "{{myfancypath}}"
      }      
    }

ansible-build-and-push-docker-image's People

Contributors

unglaublicherdude avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.