├── stack ├── base.txt ├── buildpacks.txt ├── packages.txt ├── prepare └── builder ├── .gitignore ├── Makefile ├── AUTHORS ├── LICENSE └── README.md /stack/base.txt: -------------------------------------------------------------------------------- 1 | ubuntu:quantal -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.tgz 2 | build-dir/buildpacks/* 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: build 3 | 4 | build: 5 | ./build.sh ./stack progrium/buildstep -------------------------------------------------------------------------------- /stack/buildpacks.txt: -------------------------------------------------------------------------------- 1 | https://github.com/heroku/heroku-buildpack-ruby.git 2 | https://github.com/heroku/heroku-buildpack-nodejs.git 3 | https://github.com/heroku/heroku-buildpack-java.git 4 | https://github.com/heroku/heroku-buildpack-play.git -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists all individuals having contributed content to the repository. 2 | # If you're submitting a patch, please add your name here in alphabetical order as part of the patch. 3 | # 4 | Jeff Lindsay 5 | Richard North -------------------------------------------------------------------------------- /stack/packages.txt: -------------------------------------------------------------------------------- 1 | autoconf 2 | bind9-host 3 | bison 4 | build-essential 5 | curl 6 | daemontools 7 | dnsutils 8 | ed 9 | git 10 | imagemagick 11 | iputils-tracepath 12 | libevent-dev 13 | libglib2.0-dev 14 | libjpeg-dev 15 | graphicsmagick-libmagick-dev-compat 16 | libmysqlclient-dev 17 | libpq-dev 18 | libsqlite-dev 19 | libssl-dev 20 | libssl0.9.8 21 | libxml2-dev 22 | libxslt-dev 23 | mercurial 24 | mysql-client 25 | netcat-openbsd 26 | nodejs 27 | openjdk-6-jdk 28 | openjdk-6-jre-headless 29 | openssh-client 30 | openssh-server 31 | postgresql 32 | postgresql-server-dev-9.1 33 | ruby1.9.1-dev 34 | rubygems 35 | socat 36 | sqlite3 37 | telnet 38 | zlib1g-dev -------------------------------------------------------------------------------- /stack/prepare: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Prepares the "stack" to run apps and the environment to run buildpacks 4 | # 5 | 6 | # 7 | # SYSTEM PACKAGES 8 | # 9 | apt-get update 10 | xargs apt-get install -y --force-yes < /build/packages.txt 11 | apt-get clean 12 | 13 | # 14 | # SUPPORTED BUILDPACKS 15 | # 16 | mkdir -p /build/buildpacks 17 | cd /build/buildpacks 18 | xargs -L 1 git clone < /build/buildpacks.txt 19 | 20 | # 21 | # MISC 22 | # 23 | 24 | # Ruby buildpack system configuration 25 | update-alternatives --set ruby /usr/bin/ruby1.9.1 26 | update-alternatives --set gem /usr/bin/gem1.9.1 27 | gem install bundler 28 | cd /build/buildpacks/heroku-buildpack-ruby && bundle install 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Jeff Lindsay 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Buildstep 2 | 3 | Heroku-style application builds using Docker and Buildpacks. Used by [Dokku](https://github.com/progrium/dokku) to make a mini-Heroku. 4 | 5 | ## Requirements 6 | 7 | * Docker 8 | * Git 9 | 10 | ## Building Buildstep 11 | 12 | The buildstep script uses a buildstep base container that needs to be built. It must be created before 13 | you can use the buildstep script. To create it, run: 14 | 15 | $ make build 16 | 17 | This will create a container called `progrium/buildstep` that contains all supported buildpacks and the 18 | builder script that will actually perform the build using the buildpacks. 19 | 20 | ## Building an App 21 | 22 | Running the buildstep script will take an application tar via STDIN and an application container name as 23 | an argument. It will put the application in a new container based on `progrium/buildstep` with the specified name. 24 | Then it runs the builder script inside the container. 25 | 26 | $ cat myapp.tar | ./buildstep myapp 27 | 28 | The resulting container has a built app ready to go. The builder script also parses the Procfile and produces 29 | a starter script that takes a process type. Run your app with: 30 | 31 | $ docker run -d myapp /bin/bash -c "/start web" 32 | 33 | ## Adding Buildpacks 34 | 35 | Buildstep needs to support a buildpack by installing packages needed to run the build and to run the application 36 | it builds. For example, the Python buildpack would need Python to be installed. 37 | 38 | To add a new buildpack to builstep, add commands to install the necessary packages that the buildpack and built 39 | application environment will need to stack/packages.txt and stack/prepare. Then add the buildpack Git URL to the file stack/buildpacks.txt 40 | 41 | You'll then have to re-build. 42 | 43 | ## License 44 | 45 | MIT -------------------------------------------------------------------------------- /stack/builder: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | build_root=/app 5 | cache_root=/cache 6 | buildpack_root=/build/buildpacks 7 | 8 | buildpacks=($buildpack_root/*) 9 | selected_buildpack= 10 | 11 | mkdir -p $cache_root 12 | mkdir -p $build_root/.profile.d 13 | 14 | # This is to get a custom buildpack. Probably should use profile.d though 15 | [[ -f "$build_root/.env" ]] && . "$build_root/.env" 16 | 17 | if [ -n "$BUILDPACK_URL" ]; then 18 | echo " Fetching custom buildpack" 19 | buildpack="$buildpack_root/custom" 20 | rm -rf "$buildpack" 21 | git clone --depth=1 "$BUILDPACK_URL" "$buildpack" 22 | selected_buildpack="$buildpack" 23 | buildpack_name=$($buildpack/bin/detect "$build_root") && selected_buildpack=$buildpack 24 | else 25 | for buildpack in "${buildpacks[@]}"; do 26 | buildpack_name=$($buildpack/bin/detect "$build_root") && selected_buildpack=$buildpack && break 27 | done 28 | fi 29 | 30 | if [ -n "$selected_buildpack" ]; then 31 | echo " $buildpack_name app detected" 32 | else 33 | echo " Unable to select a buildpack" 34 | exit 1 35 | fi 36 | 37 | $selected_buildpack/bin/compile "$build_root" "$cache_root" 38 | 39 | echo "-----> Discovering process types" 40 | $selected_buildpack/bin/release "$build_root" "$cache_root" > /app/.release 41 | 42 | if [[ -f "$build_root/Procfile" ]]; then 43 | types=$(ruby -e "require 'yaml';puts YAML.load_file('$build_root/Procfile').keys().join(', ')") 44 | echo " Procfile declares types -> $types" 45 | fi 46 | default_types=$(ruby -e "require 'yaml';puts (YAML.load_file('$build_root/.release')['default_process_types'] || {}).keys().join(', ')") 47 | [[ $default_types ]] && echo " Default process types for $buildpack_name -> $default_types" 48 | 49 | ruby -e "require 'yaml';(YAML.load_file('$build_root/.release')['config_vars'] || {}).each{|k,v| puts \"#{k}=#{v}\"}" > $build_root/.profile.d/config_vars 50 | 51 | cat > /start <