Code Monkey home page Code Monkey logo

cram's Introduction

Cram

Note: Cram has been moved into Jib as the Jib CLI utility

Cram is a little Java-based command-line utility for building Docker containers from file system content. It serves as a demonstration of Jib Core, a Java library for building containers without Docker.

(Cram was initially called Bilge, because a Jib is also a sail and... hence the rename.)

Building

mvn package

This creates a fatjar in target/cram-0.0.1-SNAPSHOT-jar-with-dependencies.jar.

Examples

nginx

The following example creates an nginx-based container to serve static content that is found in path/to/website. The result is loaded to the local Docker daemon as my-static-website:

$ java -jar cram/target/cram-0.0.1-SNAPSHOT-jar-with-dependencies.jar \
  --docker \
  nginx \
  my-static-website \
  --port 80 \
  --entrypoint "nginx,-g,daemon off;" \
  path/to/website:/usr/share/nginx/html
$ docker run -it --rm -p 8080:80 my-static-website

Java app

The following example uses cram to containerize itself. The image is pushed to a registry at localhost:5000:

$ java -jar cram/target/cram-0.0.1-SNAPSHOT-jar-with-dependencies.jar \
  --registry \
  gcr.io/distroless/java \
  localhost:5000/cram:latest \
  --insecure \
  --entrypoint "java,-jar,/app/cram.jar" \
  cram/target/cram-0.0.1-SNAPSHOT-jar-with-dependencies.jar:/app/cram.jar
$ docker run --rm localhost:5000/cram:latest

We need to use --insecure assuming the local registry does not support SSL.

Note that we'd be better off using jib-maven-plugin to create the container since it would create better layer strategy that negates the need to use a fatjar.

Compiling with Graal's native-image

$ sh build-native.sh
  • switched to using SLF4j with Apache Commons Logging facade to avoid the need to configure reflection for LogFactory
  • must explicitly enable http and https support
  • must somehow set java.library.path at compile time, or copy in $GRAALVM/jre/lib/libsunec.* into the current directory, to make the SunEC JCA extensions available.
  • the graal-jib-reflect.json must be updated as Jib Core adds new fields to Jackson JSON templates.

cram's People

Contributors

briandealwis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cram's Issues

Pass auth creds through parameters

It would be great if we can supply auth creds for registry using parameters since it removes the dependency on credential helpers.

My exact use case is: We are setting up a CI system for UI projects, where we need to push docker images (without daemon) to a local registry which has auth.

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.