GithubHelp home page GithubHelp logo

maxgfaraday / slugbuilder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flynn-archive/slugbuilder

0.0 2.0 0.0 133 KB

Builds Heroku slugs using Docker and buildpacks

License: BSD 3-Clause "New" or "Revised" License

slugbuilder's Introduction

(Heroku-ish) Slug Builder

A tool using Docker and Buildpacks to produce a Heroku-like slug given some application source.

What does it do exactly?

It's a Docker container that takes an uncompressed tarball of an application source piped to it. The source is run through buildpacks, then if it's detected as a supported app it will be compiled into a gzipped tarball ready to be run somewhere.

Using Slug Builder

First, you need Docker. Then you can either pull the image from the public index:

$ docker pull flynn/slugbuilder

Or you can build from this source:

$ cd slugbuilder
$ make

When you run the container, it always expects a tar of your app source to be passed via stdin. So let's run it from a git repo and use git archive to produce a tar:

$ id=$(git archive master | docker run -i -a stdin flynn/slugbuilder)
$ docker wait $id
$ docker cp $id:/tmp/slug.tgz .

We run slugbuilder, wait for it to finish using the id it gave us, then copies out the slug artifact into the current directory. If we attached to the container with docker attach we could also see the build output as you would with Heroku. We can also just see the build output by running it with stdout:

$ git archive master | docker run -i -a stdin -a stdout flynn/slugbuilder

We still have to look up the id and copy the slug out of the container, but there's an easier way!

$ git archive master | docker run -i -a stdin -a stdout flynn/slugbuilder - > myslug.tgz

By running with the - argument, it will send all build output to stderr (which we didn't attach here) and then spit out the slug to stdout, which as you can see we can easily redirect into a file.

Lastly, you can also have it PUT the slug somewhere via HTTP if you give it a URL as an argument. This lets us specify a place to put it and get the build output via stdout:

$ git archive master | docker run -i -a stdin -a stdout flynn/slugbuilder http://fileserver/path/for/myslug.tgz

Caching

To speed up slug building, it's best to mount a volume specific to your app at /tmp/cache. For example, if you wanted to keep the cache for this app on your host at /tmp/app-cache, you'd mount a read-write volume by running docker with this added -v /tmp/app-cache:/tmp/cache:rw option:

docker run -v /tmp/app-cache:/tmp/cache:rw -i -a stdin -a stdout flynn/slugbuilder

Buildpacks

As you can see, slugbuilder supports a number of official and third-party Heroku buildpacks. You can change the buildpacks.txt file and rebuild the container to create a version that supports more/less buildpacks than we do here. You can also bind mount your own directory of buildpacks if you'd like:

docker run -v /my/buildpacks:/tmp/buildpacks:ro -i -a stdin -a stdout flynn/slugbuilder

Base Environment

The Docker image here is based on cedarish, an image that emulates the Heroku Cedar stack environment. All buildpacks should have everything they need to run in this environment, but if something is missing it should be added upstream to cedarish.

License

BSD

slugbuilder's People

Contributors

progrium avatar titanous avatar

Watchers

Max G. Faraday avatar James Cloos 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.