• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Clojure
  • License
    Eclipse Public Li...
  • Created over 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Leiningen plugin to generate a docker image that runs a project's uberjar.

uberimage

A Leiningen plugin to generate a docker image that runs a project's uberjar.

Requires leiningen 2.4.3 or later.

Usage

Put [com.palletops/uberimage "0.4.1"] into the :plugins vector of your :user profile.

$ lein uberimage

The plugin will run 'uberjar' on your project, generate the docker image with your uberjar in it, and report the uuid of the generated image.

Note that if you have not already pulled the base image (eg. with docker pull pallet/java), then it might take some while for the image generation to complete.

Running your container

Once the image is built, you can run it via docker with

docker run generated-image-uuid

By default your image doesn't have any ports mapped. If your service needs to open incoming ports, you need to bind the container port to a host port, running your container this way instead:

docker run generated-image-uuid -p 3000:8080

where the 3000 is the port where your service listens on the container, and the 8080 is the port you want your service to listen to on the host. Then, open your browser and type http://<docker-host-ip>:8080/... to access your service.

Configuration

The project.clj :uberimage key can be used to configure the image's CMD and to place extra files into the image.

:uberimage {:cmd ["/bin/dash" "/myrunscript" "param1" "param2"]
            :instructions ["RUN apt-get update && apt-get -y dist-upgrade"]
            :files {"myrunscript" "docker/myrunscript"}
            :tag "user/repo:tag"}

The :cmd value maps directly to a Dockerfile CMD statement

The :instructions value specifies a list of Dockerfile instructions to be inserted into the generated Dockerfile immediately after the FROM instruction at the start of the Dockerfile

The :files value is a map of additional files to be copied into the docker image. Keys are docker image target paths and values are lein project source paths.

The :tag value supplies a repository name (and optionally a tag) to be applied to the resulting image in case of success.

The :base-image value is used to specify the base image from which the project image is built (defaults to pallet/java).

Options

By default, the docker API is assumed to be on http://localhost:2375. You can override this by setting the the DOCKER_HOST environment variable, or using the -H option, e.g.

lein uberimage -H http://localhost:4243

If you have DOCKER_HOST set, but don't want that value used, override it with the DOCKER_ENDPOINT environment variable.

The base image used to construct the image can be specified using -b.

lein uberimage -b your-image-with-jvm

The repository name (and optionally a tag) to be applied to the resulting image in case of success can be specified using -t.

lein uberimage -t user/repo:tag

Limitations

Currently your project needs to build with lein uberjar (as lein uberimage invokes uberjar) and you must supply a :main so that the uberjar is executable via java -jar.

Depends on leiningen 2.4.3 or later.

Using a :target-path with a %s is it seems to break the plugin.

Requires docker api on a TCP socket (eg. for plain docker or on coreos). Other examples of enabling the API: on ubuntu.

TODO

Allow choice of running AOT's with -jar, or non AOT'd with clojure.main.

Allow choice of java runtime.

Use -p to push the resulting image to a repository.

License

Copyright Β© 2014 Hugo Duncan

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

More Repositories

1

leaven

A component composition library for clojure and clojurescript
Clojure
84
star
2

lein-shorthand

Inject clojure vars into namespaces for use in the REPL
Clojure
42
star
3

ns-reload

Reload your clojure namespaces correctly
Clojure
31
star
4

bakery

A library of leaven components
JavaScript
25
star
5

clj-docker

Clojure
24
star
6

log-config

Logging configuration with timbre
Clojure
18
star
7

carapace

System command execution from clojure
Clojure
6
star
8

api-builder

A library for builder augmented api functions in clojure
Clojure
5
star
9

visaje

Clojure
5
star
10

docker-registry-swift

Dockerfile for a Docker registry with swift support
Shell
5
star
11

old-pallet-repl

A set of utilities for the REPL and beyond (lein maybe?)
4
star
12

lab.vmfest-smartos-host

Automate building SmartOS hosts on VirtualBox
Clojure
4
star
13

multi-node-project

Clojure
4
star
14

clj-fleet

A clojure API for CoreOS Fleet
Clojure
3
star
15

clara-test

Testing clara rules
Clojure
2
star
16

multi-test

An alternative test runner for clojure.test
Clojure
2
star
17

locos

Clojure
2
star
18

docker-git-client

A docker image with a git client
2
star
19

java-package-builder

A pallet project for building java6 deb packages
Clojure
1
star
20

lein-pallet-release

A lein plugin for releasing PalletOps projects
Clojure
1
star
21

graphite-crate

Clojure
1
star
22

hadoop-crate

Clojure
1
star
23

collectd-crate

Clojure
1
star
24

windows-tester

Clojure
1
star
25

hadoop-config

Clojure
1
star
26

hadoop-cluster

Clojure
1
star
27

docker-ubuntu-nodoc

A docker image without docs for installed packages
Shell
1
star
28

hadoop-book-example

Clojure
1
star
29

cache-resources

Cache for resources that need closing
Clojure
1
star