Giter Club home page Giter Club logo

lein-docker's Introduction

lein-docker

A Leiningen plugin to build and deploy Docker images.

Clojars Project

Usage

Add docker-deploy to your plugin list in your project.clj:

:plugins [[gorillalabs/lein-docker "1.6.0"]]

(see version badge above for newest release)

Available commands:

$ lein docker build [image-name [additional-arguments ... ]]
$ lein docker push [image-name]
$ lein docker rmi [image-name]

Configuration

You can add the following configuration options at the root of your project.clj:

:docker {:image-name "myregistry.example.org/myimage"
         :tags ["%s" "latest"] ; %s will splice the project version into the tag
         :dockerfile "target/dist/Dockerfile"
         :build-dir  "target"}

Defaults:

  • :image-name is your project's name (without the group ID)
  • :tags is your project's version
  • :dockerfile points to Dockerfile
  • :build-dir points to the project's root

Injecting environment variables into configuration

With a CI/CD pipeline such as Jenkins, you may want to generate Docker artifacts tagged against specific properties of a build run. The values in the :docker configuration options may contain bash-like references to environment variables, which will be replaced with values from the environment. For example:

:docker {:image-name "myregistry.example.org/myimage"
         :tags ["%s-${BUILD_NUMBER:-unknown}"]}

Running lein docker build command under Jenkins line will generate an image tagged with the project number and build number (e.g., 1.6.0-306). If BUILD_NUMBER is undefined, as when outside of Jenkins, then the default value ("unknown") will be spliced in instead. If the environment variable expression does not contain a default string and the referenced environment variable is not defined, the expression is replaced with the empty string.

Environment variable injection is supported for the :image-name, :tags, :dockerfile, and :build-dir entries in the project's :docker map.

Releasing your docker images

You can use Leiningen to handle your technical release process. In order to do that with your Docker image instead of your plain jar file, configure your release tasks similar to that:

:release-tasks [["vcs" "assert-committed"]
                ["change" "version" "leiningen.release/bump-version" "release"]
                ["vcs" "commit"]
                ["vcs" "tag"]
                ["clean"]
                ["uberjar"]
                ["docker" "build"]
                ["docker" "push"]
                ["change" "version" "leiningen.release/bump-version"]
                ["vcs" "commit"]
                ["vcs" "push"]]

License

MIT License

Copyright (c) 2015, Tobias Sarnowski 2018, Dr. Christian Betz

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.