├── .gitignore ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── README.md ├── buildpack └── Dockerfile ├── cordova └── Dockerfile ├── elixir └── Dockerfile ├── examples ├── buildpack ├── cordova │ ├── tsuru.yml │ └── www │ │ └── index.html ├── elixir │ ├── .gitignore │ ├── Procfile │ ├── lib │ │ ├── app.ex │ │ └── app │ │ │ ├── page_handler.ex │ │ │ └── supervisor.ex │ ├── mix.exs │ └── tsuru.yml ├── go │ ├── tsuru.yml │ └── web.go ├── java │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── webapp │ │ │ ├── WEB-INF │ │ │ └── web.xml │ │ │ └── index.jsp │ └── tsuru.yml ├── lisp │ ├── Procfile │ ├── README.txt │ ├── example-tsuru-lisp-webapp.asd │ ├── package.lisp │ ├── requirements.apt │ ├── requirements.txt │ ├── tsuru.yml │ └── web.lisp ├── nodejs │ ├── Procfile │ ├── app.js │ ├── hook.js │ ├── package.json │ └── tsuru.yml ├── php │ ├── index.php │ └── tsuru.yml ├── play │ ├── Procfile │ ├── activator │ ├── activator-launch-1.2.12.jar │ ├── app │ │ └── controllers │ │ │ └── Application.scala │ ├── build.sbt │ ├── conf │ │ ├── application.conf │ │ └── routes │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ └── tsuru.yml ├── pypy │ ├── Procfile │ ├── app.py │ ├── hook.py │ ├── requirements.txt │ └── tsuru.yml ├── python │ ├── Procfile │ ├── app.py │ ├── hook.py │ ├── requirements.txt │ └── tsuru.yml ├── python3 │ ├── Procfile │ ├── app.py │ ├── hook.py │ ├── requirements.txt │ └── tsuru.yml ├── ruby │ ├── Gemfile │ ├── Gemfile.lock │ ├── Procfile │ ├── app.rb │ ├── hook.rb │ └── tsuru.yml └── static │ ├── index.html │ └── tsuru.yml ├── go ├── Dockerfile └── README.md ├── java ├── Dockerfile └── README.md ├── nodejs ├── Dockerfile └── README.md ├── php ├── Dockerfile └── README.md ├── play └── Dockerfile ├── pypy ├── Dockerfile └── README.md ├── python ├── Dockerfile └── README.md ├── python3 ├── Dockerfile └── README.md ├── ruby ├── Dockerfile └── README.md ├── static ├── Dockerfile └── README.md └── tests ├── .gitignore ├── Vagrantfile ├── platforms.bash └── run.bash /.gitignore: -------------------------------------------------------------------------------- 1 | *.sw[a-z] 2 | *.pyc 3 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of basebuilder authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | Adam Clark 6 | Alessandro Corbelli 7 | Chino Chang 8 | Conrad Pankoff 9 | Evandro Leopoldino Gonçalves 10 | George Fleury 11 | Globo.com 12 | GUEST.it s.r.l 13 | Jannis Leidel 14 | Jason Thigpen 15 | Jonas Kac 16 | Josh Blancett 17 | Łukasz Kurowski 18 | Marc Abramowitz 19 | Nick Ricketts 20 | Robson Peixoto 21 | Samuel ROZE 22 | Tatiana Al-Chueyr 23 | Wouter van Outersterp 24 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who have contributed code to 2 | # basebuilder. 3 | # The AUTHORS file lists the copyright holders; this file lists people. 4 | # For example, Globo.com employees are listed here but not in AUTHORS, 5 | # because Globo.com holds the copyright. 6 | # 7 | # You can the list of contributors using the following command: 8 | # 9 | # % git shortlog -se 10 | # 11 | # Please keep this file sorted, and group users with multiple emails. 12 | 13 | Adam Clark 14 | Alessandro Corbelli 15 | Andrews Medina 16 | Cezar Sá Espinola 17 | Chino Chang 18 | Conrad Pankoff 19 | Cristian Oliveira da Rosa 20 | Evandro Leopoldino Gonçalves 21 | Flavia Missi 22 | Francisco Souza 23 | George Fleury 24 | GUEST.it s.r.l 25 | Guilherme Cirne 26 | Guilherme Souza 27 | Jannis Leidel 28 | Jason Thigpen 29 | Jonas Kac 30 | Josh Blancett 31 | Łukasz Kurowski 32 | Marc Abramowitz 33 | Martin Jackson 34 | N0SAN9 35 | Nick Ricketts 36 | Paulo Sousa 37 | Pedro Medeiros 38 | Roberto Soares 39 | Robson Peixoto 40 | Samuel ROZE 41 | Tarsis Azevedo 42 | Tatiana Al-Chueyr 43 | Wilson Júnior 44 | Wouter van Outersterp 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, basebuilder authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the Globo.com nor the names of its contributors 12 | may be used to endorse or promote products derived from this software without 13 | specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | basebuilder 2 | =========== 3 | 4 | This repository contains placeholder Dockerfile's for tsuru platforms, along 5 | with the tests that run nightly against all platforms. 6 | 7 | To get the source of the platforms and contribute with new platforms, go to 8 | https://github.com/tsuru/platforms. 9 | -------------------------------------------------------------------------------- /buildpack/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | FROM tsuru/buildpack 6 | -------------------------------------------------------------------------------- /cordova/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru cordova image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add cordova -d https://raw.github.com/tsuru/basebuilder/master/cordova/Dockerfile 8 | 9 | FROM tsuru/cordova 10 | -------------------------------------------------------------------------------- /elixir/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru elixir image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add elixir -d https://raw.github.com/tsuru/basebuilder/master/elixir/Dockerfile 8 | 9 | FROM tsuru/elixir 10 | -------------------------------------------------------------------------------- /examples/buildpack: -------------------------------------------------------------------------------- 1 | python -------------------------------------------------------------------------------- /examples/cordova/tsuru.yml: -------------------------------------------------------------------------------- 1 | healthcheck: 2 | path: / 3 | -------------------------------------------------------------------------------- /examples/cordova/www/index.html: -------------------------------------------------------------------------------- 1 | Hello world from tsuru 2 | -------------------------------------------------------------------------------- /examples/elixir/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /deps 3 | erl_crash.dump 4 | *.ez 5 | -------------------------------------------------------------------------------- /examples/elixir/Procfile: -------------------------------------------------------------------------------- 1 | web: mix run --no-halt 2 | -------------------------------------------------------------------------------- /examples/elixir/lib/app.ex: -------------------------------------------------------------------------------- 1 | defmodule App do 2 | use Application 3 | @moduledoc "Entry point module" 4 | 5 | def start(_type, _args) do 6 | run && App.Supervisor.start_link 7 | end 8 | 9 | def run do 10 | routes = [ {"/", App.PageHandler, []} ] 11 | dispatch = :cowboy_router.compile([{:_, routes}]) 12 | {port, _} = (System.get_env("PORT") || "5000") 13 | |> Integer.parse 14 | 15 | opts = [port: port] 16 | env = [dispatch: dispatch] 17 | 18 | {:ok, _pid} = :cowboy.start_http(:http, 100, opts, [env: env]) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /examples/elixir/lib/app/page_handler.ex: -------------------------------------------------------------------------------- 1 | defmodule App.PageHandler do 2 | def init({:tcp, :http}, req, opts) do 3 | headers = [{"content-type", "text/plain"}] 4 | body = "Hello world from tsuru" 5 | 6 | {:ok, resp} = :cowboy_req.reply(200, headers, body, req) 7 | {:ok, resp, opts} 8 | end 9 | 10 | def handle(req, state) do 11 | {:ok, req, state} 12 | end 13 | 14 | def terminate(_reason, _req, _state) do 15 | :ok 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /examples/elixir/lib/app/supervisor.ex: -------------------------------------------------------------------------------- 1 | defmodule App.Supervisor do 2 | use Supervisor 3 | 4 | @moduledoc """ 5 | This is a implementation of Supervisor. 6 | Supervisors are responsible for handler his childrens (restarting when necessary) 7 | it follows the fault tolerancy arquitecture. 8 | """ 9 | 10 | @doc "Links the supervisor with called module" 11 | def start_link do 12 | :supervisor.start_link(__MODULE__, []) 13 | end 14 | 15 | @doc """ 16 | Starts supervisor using one_for_one strategy 17 | see: http://www.erlang.org/doc/man/supervisor.html 18 | """ 19 | def init([]) do 20 | children = [] 21 | supervise children, strategy: :one_for_one 22 | end 23 | 24 | end 25 | -------------------------------------------------------------------------------- /examples/elixir/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule App.Mixfile do 2 | use Mix.Project 3 | 4 | def project do 5 | [app: :app, 6 | version: "0.0.1", 7 | elixir: ">= 1.2.0", 8 | deps: deps] 9 | end 10 | 11 | # Configuration for the OTP application 12 | # Type `mix help compile.app` for more information 13 | def application do 14 | [ mod: { App, [] }, 15 | applications: [:logger, :cowboy]] 16 | end 17 | 18 | # Dependencies can be Hex packages: 19 | # Type `mix help deps` for more examples and options 20 | defp deps do 21 | [{:cowboy, "~> 1.0.0"}] 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /examples/elixir/tsuru.yml: -------------------------------------------------------------------------------- 1 | healthcheck: 2 | path: / 3 | -------------------------------------------------------------------------------- /examples/go/tsuru.yml: -------------------------------------------------------------------------------- 1 | hooks: 2 | build: 3 | - go run web.go -h 4 | healthcheck: 5 | path: / 6 | -------------------------------------------------------------------------------- /examples/go/web.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 basebuilder authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "flag" 9 | "net/http" 10 | "os" 11 | ) 12 | 13 | var hook bool 14 | 15 | func init() { 16 | flag.BoolVar(&hook, "h", false, "run hook") 17 | } 18 | 19 | func main() { 20 | flag.Parse() 21 | if hook { 22 | println("hello") 23 | return 24 | } 25 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 26 | w.Write([]byte("Hello world from tsuru")) 27 | }) 28 | port := os.Getenv("PORT") 29 | if port == "" { 30 | port = "5000" 31 | } 32 | http.ListenAndServe(":" + port, nil) 33 | } 34 | -------------------------------------------------------------------------------- /examples/java/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | io.tsuru.sample 5 | helloweb 6 | war 7 | 1.0-SNAPSHOT 8 | helloweb Maven Webapp 9 | http://maven.apache.org 10 | 11 | 12 | junit 13 | junit 14 | 3.8.1 15 | test 16 | 17 | 18 | 19 | ROOT 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/java/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Archetype Created Web Application 7 | 8 | -------------------------------------------------------------------------------- /examples/java/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | Hello world from tsuru 2 | -------------------------------------------------------------------------------- /examples/java/tsuru.yml: -------------------------------------------------------------------------------- 1 | hooks: 2 | build: 3 | - mvn package 4 | - mv target/ROOT.war . 5 | healthcheck: 6 | path: / 7 | -------------------------------------------------------------------------------- /examples/lisp/Procfile: -------------------------------------------------------------------------------- 1 | web: sudo -H -E -u ubuntu sbcl --non-interactive --eval '(ql:quickload "example-tsuru-lisp-webapp")' --eval '(web:start)' -------------------------------------------------------------------------------- /examples/lisp/README.txt: -------------------------------------------------------------------------------- 1 | This is an example application for the tsuru PAAS using lisp and wookie. 2 | 3 | It demostrates how to use requirements.apt (for apt package dependencies), requirements.txt (for requirements that are outside quicklist, or for things you want to override in quicklisp). 4 | -------------------------------------------------------------------------------- /examples/lisp/example-tsuru-lisp-webapp.asd: -------------------------------------------------------------------------------- 1 | (asdf:defsystem #:example-tsuru-lisp-webapp 2 | :serial t 3 | :description "Example lisp app for tsuru" 4 | :author "Nick Ricketts" 5 | :license "" 6 | :depends-on ("alexandria" "wookie") 7 | :components ((:file "package") 8 | (:file "web"))) 9 | -------------------------------------------------------------------------------- /examples/lisp/package.lisp: -------------------------------------------------------------------------------- 1 | (defpackage #:web 2 | (:use #:cl #:wookie #:cl-async) 3 | (:export #:start)) 4 | -------------------------------------------------------------------------------- /examples/lisp/requirements.apt: -------------------------------------------------------------------------------- 1 | libevent-core-2.0-5 2 | libevent-extra-2.0-5 3 | libevent-openssl-2.0-5 4 | libevent-pthreads-2.0-5 -------------------------------------------------------------------------------- /examples/lisp/requirements.txt: -------------------------------------------------------------------------------- 1 | https://github.com/orthecreedence/drakma-async.git 2 | https://github.com/orthecreedence/wookie.git 3 | -------------------------------------------------------------------------------- /examples/lisp/tsuru.yml: -------------------------------------------------------------------------------- 1 | healthcheck: 2 | path: / 3 | -------------------------------------------------------------------------------- /examples/lisp/web.lisp: -------------------------------------------------------------------------------- 1 | (in-package #:web) 2 | 3 | (defroute (:get "/") (req res) 4 | (send-response res :body "Hello world from tsuru")) 5 | 6 | (defun start () 7 | (with-event-loop (:catch-app-errors t) 8 | (start-server (make-instance 'listener :port 8888)))) 9 | -------------------------------------------------------------------------------- /examples/nodejs/Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js 2 | -------------------------------------------------------------------------------- /examples/nodejs/app.js: -------------------------------------------------------------------------------- 1 | // Copyright 2015 basebuilder authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | var express = require('express'); 6 | var app = express(); 7 | 8 | app.get('/', function(req, res){ 9 | res.send('Hello world from tsuru'); 10 | }); 11 | 12 | var server = app.listen(process.env.PORT || 5000); 13 | -------------------------------------------------------------------------------- /examples/nodejs/hook.js: -------------------------------------------------------------------------------- 1 | console.log("Hello"); 2 | -------------------------------------------------------------------------------- /examples/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "description": "hello world test on tsuru", 4 | "version": "0.0.1", 5 | "private": true, 6 | "dependencies": { 7 | "express": "3.x" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/nodejs/tsuru.yml: -------------------------------------------------------------------------------- 1 | hooks: 2 | build: 3 | - node hook.js 4 | healthcheck: 5 | path: / 6 | -------------------------------------------------------------------------------- /examples/php/index.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /examples/php/tsuru.yml: -------------------------------------------------------------------------------- 1 | healthcheck: 2 | path: / 3 | -------------------------------------------------------------------------------- /examples/play/Procfile: -------------------------------------------------------------------------------- 1 | web: target/universal/stage/bin/play -Dhttp.port=${PORT} -------------------------------------------------------------------------------- /examples/play/activator: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### ------------------------------- ### 4 | ### Helper methods for BASH scripts ### 5 | ### ------------------------------- ### 6 | 7 | realpath () { 8 | ( 9 | TARGET_FILE="$1" 10 | 11 | cd $(dirname "$TARGET_FILE") 12 | TARGET_FILE=$(basename "$TARGET_FILE") 13 | 14 | COUNT=0 15 | while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ] 16 | do 17 | TARGET_FILE=$(readlink "$TARGET_FILE") 18 | cd $(dirname "$TARGET_FILE") 19 | TARGET_FILE=$(basename "$TARGET_FILE") 20 | COUNT=$(($COUNT + 1)) 21 | done 22 | 23 | if [ "$TARGET_FILE" == "." -o "$TARGET_FILE" == ".." ]; then 24 | cd "$TARGET_FILE" 25 | TARGET_FILEPATH= 26 | else 27 | TARGET_FILEPATH=/$TARGET_FILE 28 | fi 29 | 30 | # make sure we grab the actual windows path, instead of cygwin's path. 31 | if ! is_cygwin; then 32 | echo "$(pwd -P)/$TARGET_FILE" 33 | else 34 | echo $(cygwinpath "$(pwd -P)/$TARGET_FILE") 35 | fi 36 | ) 37 | } 38 | 39 | # TODO - Do we need to detect msys? 40 | 41 | # Uses uname to detect if we're in the odd cygwin environment. 42 | is_cygwin() { 43 | local os=$(uname -s) 44 | case "$os" in 45 | CYGWIN*) return 0 ;; 46 | *) return 1 ;; 47 | esac 48 | } 49 | 50 | # This can fix cygwin style /cygdrive paths so we get the 51 | # windows style paths. 52 | cygwinpath() { 53 | local file="$1" 54 | if is_cygwin; then 55 | echo $(cygpath -w $file) 56 | else 57 | echo $file 58 | fi 59 | } 60 | 61 | # Make something URI friendly 62 | make_url() { 63 | url="$1" 64 | local nospaces=${url// /%20} 65 | if is_cygwin; then 66 | echo "/${nospaces//\\//}" 67 | else 68 | echo "$nospaces" 69 | fi 70 | } 71 | 72 | # Detect if we should use JAVA_HOME or just try PATH. 73 | get_java_cmd() { 74 | if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then 75 | echo "$JAVA_HOME/bin/java" 76 | else 77 | echo "java" 78 | fi 79 | } 80 | 81 | echoerr () { 82 | echo 1>&2 "$@" 83 | } 84 | vlog () { 85 | [[ $verbose || $debug ]] && echoerr "$@" 86 | } 87 | dlog () { 88 | [[ $debug ]] && echoerr "$@" 89 | } 90 | execRunner () { 91 | # print the arguments one to a line, quoting any containing spaces 92 | [[ $verbose || $debug ]] && echo "# Executing command line:" && { 93 | for arg; do 94 | if printf "%s\n" "$arg" | grep -q ' '; then 95 | printf "\"%s\"\n" "$arg" 96 | else 97 | printf "%s\n" "$arg" 98 | fi 99 | done 100 | echo "" 101 | } 102 | 103 | exec "$@" 104 | } 105 | addJava () { 106 | dlog "[addJava] arg = '$1'" 107 | java_args=( "${java_args[@]}" "$1" ) 108 | } 109 | addApp () { 110 | dlog "[addApp] arg = '$1'" 111 | sbt_commands=( "${app_commands[@]}" "$1" ) 112 | } 113 | addResidual () { 114 | dlog "[residual] arg = '$1'" 115 | residual_args=( "${residual_args[@]}" "$1" ) 116 | } 117 | addDebugger () { 118 | addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" 119 | } 120 | addConfigOpts () { 121 | dlog "[addConfigOpts] arg = '$*'" 122 | for item in $* 123 | do 124 | addJava "$item" 125 | done 126 | } 127 | # a ham-fisted attempt to move some memory settings in concert 128 | # so they need not be messed around with individually. 129 | get_mem_opts () { 130 | local mem=${1:-1024} 131 | local meta=$(( $mem / 4 )) 132 | (( $meta > 256 )) || meta=256 133 | (( $meta < 1024 )) || meta=1024 134 | 135 | # default is to set memory options but this can be overridden by code section below 136 | memopts="-Xms${mem}m -Xmx${mem}m" 137 | if [[ "${java_version}" > "1.8" ]]; then 138 | extmemopts="-XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=${meta}m" 139 | else 140 | extmemopts="-XX:PermSize=64m -XX:MaxPermSize=${meta}m" 141 | fi 142 | 143 | if [[ "${java_opts}" == *-Xmx* ]] || [[ "${java_opts}" == *-Xms* ]] || [[ "${java_opts}" == *-XX:MaxPermSize* ]] || [[ "${java_opts}" == *-XX:ReservedCodeCacheSize* ]] || [[ "${java_opts}" == *-XX:MaxMetaspaceSize* ]]; then 144 | # if we detect any of these settings in ${java_opts} we need to NOT output our settings. 145 | # The reason is the Xms/Xmx, if they don't line up, cause errors. 146 | memopts="" 147 | extmemopts="" 148 | fi 149 | 150 | echo "${memopts} ${extmemopts}" 151 | } 152 | require_arg () { 153 | local type="$1" 154 | local opt="$2" 155 | local arg="$3" 156 | if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then 157 | die "$opt requires <$type> argument" 158 | fi 159 | } 160 | is_function_defined() { 161 | declare -f "$1" > /dev/null 162 | } 163 | 164 | # If we're *not* running in a terminal, and we don't have any arguments, then we need to add the 'ui' parameter 165 | detect_terminal_for_ui() { 166 | [[ ! -t 0 ]] && [[ "${#residual_args}" == "0" ]] && { 167 | addResidual "ui" 168 | } 169 | # SPECIAL TEST FOR MAC 170 | [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]] && [[ "${#residual_args}" == "0" ]] && { 171 | echo "Detected MAC OSX launched script...." 172 | echo "Swapping to UI" 173 | addResidual "ui" 174 | } 175 | } 176 | 177 | # Processes incoming arguments and places them in appropriate global variables. called by the run method. 178 | process_args () { 179 | while [[ $# -gt 0 ]]; do 180 | case "$1" in 181 | -h|-help) usage; exit 1 ;; 182 | -v|-verbose) verbose=1 && shift ;; 183 | -d|-debug) debug=1 && shift ;; 184 | -mem) require_arg integer "$1" "$2" && app_mem="$2" && shift 2 ;; 185 | -jvm-debug) 186 | if echo "$2" | grep -E ^[0-9]+$ > /dev/null; then 187 | addDebugger "$2" && shift 188 | else 189 | addDebugger 9999 190 | fi 191 | shift ;; 192 | -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;; 193 | -D*) addJava "$1" && shift ;; 194 | -J*) addJava "${1:2}" && shift ;; 195 | *) addResidual "$1" && shift ;; 196 | esac 197 | done 198 | 199 | is_function_defined process_my_args && { 200 | myargs=("${residual_args[@]}") 201 | residual_args=() 202 | process_my_args "${myargs[@]}" 203 | } 204 | } 205 | 206 | # Actually runs the script. 207 | run() { 208 | # TODO - check for sane environment 209 | 210 | # process the combined args, then reset "$@" to the residuals 211 | process_args "$@" 212 | detect_terminal_for_ui 213 | set -- "${residual_args[@]}" 214 | argumentCount=$# 215 | 216 | #check for jline terminal fixes on cygwin 217 | if is_cygwin; then 218 | stty -icanon min 1 -echo > /dev/null 2>&1 219 | addJava "-Djline.terminal=jline.UnixTerminal" 220 | addJava "-Dsbt.cygwin=true" 221 | fi 222 | 223 | # run sbt 224 | execRunner "$java_cmd" \ 225 | "-Dactivator.home=$(make_url "$activator_home")" \ 226 | $(get_mem_opts $app_mem) \ 227 | ${java_opts[@]} \ 228 | ${java_args[@]} \ 229 | -jar "$app_launcher" \ 230 | "${app_commands[@]}" \ 231 | "${residual_args[@]}" 232 | 233 | local exit_code=$? 234 | if is_cygwin; then 235 | stty icanon echo > /dev/null 2>&1 236 | fi 237 | exit $exit_code 238 | } 239 | 240 | # Loads a configuration file full of default command line options for this script. 241 | loadConfigFile() { 242 | cat "$1" | sed '/^\#/d' 243 | } 244 | 245 | ### ------------------------------- ### 246 | ### Start of customized settings ### 247 | ### ------------------------------- ### 248 | usage() { 249 | cat < [options] 251 | 252 | Command: 253 | ui Start the Activator UI 254 | new [name] [template-id] Create a new project with [name] using template [template-id] 255 | list-templates Print all available template names 256 | -h | -help Print this message 257 | 258 | Options: 259 | -v | -verbose Make this runner chattier 260 | -d | -debug Set sbt log level to debug 261 | -mem Set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) 262 | -jvm-debug Turn on JVM debugging, open at the given port. 263 | 264 | # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) 265 | -java-home Alternate JAVA_HOME 266 | 267 | # jvm options and output control 268 | -Dkey=val Pass -Dkey=val directly to the java runtime 269 | -J-X Pass option -X directly to the java runtime 270 | (-J is stripped) 271 | 272 | # environment variables (read from context) 273 | JAVA_OPTS Environment variable, if unset uses "" 274 | SBT_OPTS Environment variable, if unset uses "" 275 | ACTIVATOR_OPTS Environment variable, if unset uses "" 276 | 277 | In the case of duplicated or conflicting options, the order above 278 | shows precedence: environment variables lowest, command line options highest. 279 | EOM 280 | } 281 | 282 | ### ------------------------------- ### 283 | ### Main script ### 284 | ### ------------------------------- ### 285 | 286 | declare -a residual_args 287 | declare -a java_args 288 | declare -a app_commands 289 | declare -r real_script_path="$(realpath "$0")" 290 | declare -r activator_home="$(realpath "$(dirname "$real_script_path")")" 291 | declare -r app_version="1.2.12" 292 | 293 | declare -r app_launcher="${activator_home}/activator-launch-${app_version}.jar" 294 | declare -r script_name=activator 295 | declare -r java_cmd=$(get_java_cmd) 296 | declare -r java_opts=( "${ACTIVATOR_OPTS[@]}" "${SBT_OPTS[@]}" "${JAVA_OPTS[@]}" "${java_opts[@]}" ) 297 | userhome="$HOME" 298 | if is_cygwin; then 299 | # cygwin sets home to something f-d up, set to real windows homedir 300 | userhome="$USERPROFILE" 301 | fi 302 | declare -r activator_user_home_dir="${userhome}/.activator" 303 | declare -r java_opts_config_home="${activator_user_home_dir}/activatorconfig.txt" 304 | declare -r java_opts_config_version="${activator_user_home_dir}/${app_version}/activatorconfig.txt" 305 | 306 | # Now check to see if it's a good enough version 307 | declare -r java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}') 308 | if [[ "$java_version" == "" ]]; then 309 | echo 310 | echo No java installations was detected. 311 | echo Please go to http://www.java.com/getjava/ and download 312 | echo 313 | exit 1 314 | elif [[ ! "$java_version" > "1.6" ]]; then 315 | echo 316 | echo The java installation you have is not up to date 317 | echo Activator requires at least version 1.6+, you have 318 | echo version $java_version 319 | echo 320 | echo Please go to http://www.java.com/getjava/ and download 321 | echo a valid Java Runtime and install before running Activator. 322 | echo 323 | exit 1 324 | fi 325 | 326 | # if configuration files exist, prepend their contents to the java args so it can be processed by this runner 327 | # a "versioned" config trumps one on the top level 328 | if [[ -f "$java_opts_config_version" ]]; then 329 | addConfigOpts $(loadConfigFile "$java_opts_config_version") 330 | elif [[ -f "$java_opts_config_home" ]]; then 331 | addConfigOpts $(loadConfigFile "$java_opts_config_home") 332 | fi 333 | 334 | run "$@" 335 | -------------------------------------------------------------------------------- /examples/play/activator-launch-1.2.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsuru/basebuilder/45f42b4a7a17dae518774bcd3fe2c854c5e1f480/examples/play/activator-launch-1.2.12.jar -------------------------------------------------------------------------------- /examples/play/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | // Copyright 2015 basebuilder authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package controllers 6 | 7 | import play.api.mvc._ 8 | 9 | object Application extends Controller { 10 | 11 | def index = Action { 12 | Ok("Hello world from tsuru") 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /examples/play/build.sbt: -------------------------------------------------------------------------------- 1 | name := """play""" 2 | 3 | version := "1.0-SNAPSHOT" 4 | 5 | lazy val root = (project in file(".")).enablePlugins(PlayScala) 6 | 7 | scalaVersion := "2.11.1" -------------------------------------------------------------------------------- /examples/play/conf/application.conf: -------------------------------------------------------------------------------- 1 | # This is the main configuration file for the application. 2 | # ~~~~~ 3 | 4 | # Secret key 5 | # ~~~~~ 6 | # The secret key is used to secure cryptographics functions. 7 | # 8 | # This must be changed for production, but we recommend not changing it in this file. 9 | # 10 | # See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 11 | application.secret="i/Yx?0A8^<7[3F5xXj3bvks32OhaW>DDKn 1.4) 9 | rack-protection (~> 1.4) 10 | tilt (~> 1.3, >= 1.3.4) 11 | tilt (1.4.1) 12 | 13 | PLATFORMS 14 | ruby 15 | 16 | DEPENDENCIES 17 | sinatra 18 | -------------------------------------------------------------------------------- /examples/ruby/Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec ruby app.rb -o 0.0.0.0 -p $PORT 2 | -------------------------------------------------------------------------------- /examples/ruby/app.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | require 'sinatra' 6 | 7 | get "/" do 8 | "Hello world from tsuru" 9 | end 10 | -------------------------------------------------------------------------------- /examples/ruby/hook.rb: -------------------------------------------------------------------------------- 1 | puts "hello" 2 | -------------------------------------------------------------------------------- /examples/ruby/tsuru.yml: -------------------------------------------------------------------------------- 1 | hooks: 2 | build: 3 | - ruby hook.rb 4 | healthcheck: 5 | path: / 6 | -------------------------------------------------------------------------------- /examples/static/index.html: -------------------------------------------------------------------------------- 1 | Hello world from tsuru 2 | -------------------------------------------------------------------------------- /examples/static/tsuru.yml: -------------------------------------------------------------------------------- 1 | healthcheck: 2 | path: / 3 | -------------------------------------------------------------------------------- /go/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru go image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add go -d https://raw.github.com/tsuru/basebuilder/master/go/Dockerfile 8 | 9 | FROM tsuru/go 10 | -------------------------------------------------------------------------------- /go/README.md: -------------------------------------------------------------------------------- 1 | #Go platform 2 | 3 | The Go platform supports two kinds of deployment: binary deployment and code 4 | deployment, where tsuru will build your application in the target. 5 | 6 | ##Binary deployment 7 | 8 | For binary deployment, ensure your binary is named "tsuru-app" (``go build -o 9 | tsuru-app`` should do the trick) and matches the target platform (usually 10 | linux_amd64), you can have a customized name if you also deploy a Procfile, 11 | something like: 12 | 13 | % ls 14 | Procfile main.go 15 | % GOOS=linux GOARCH=amd64 go build -o myapp main.go 16 | % cat Procfile 17 | web: ./myapp 18 | % tsuru app-deploy -a [app-name] myapp Procfile 19 | 20 | ##Code deployment 21 | 22 | If you just run a ``git push`` of your code, tsuru will try to download all of 23 | your dependencies using ``go get`` and build your application. You can 24 | customize this behavior, see the next section for more details. 25 | 26 | Suppose that you have this code structure: 27 | 28 | % ls 29 | main.go 30 | % cat main.go 31 | # some code that starts a "hello world" webserver 32 | % git add main.go 33 | % git commit -m "add my webserver" 34 | % git push tsuru master 35 | 36 | After invoking ``git push``, tsuru will receive your code and tell the platform 37 | to follow the setup process, that will: 38 | 39 | - download all the dependencies using ``go get`` 40 | - build the application, expecting the root of your project to be a main 41 | package 42 | 43 | ##Code deployment with customized compilation step 44 | 45 | You can also use tsuru hooks to customize the compilation and a Procfile to 46 | customize the execution of your application, here's an example: 47 | 48 | % tree 49 | . 50 | ├── Procfile 51 | ├── src 52 | │   └── main.go 53 | └── tsuru.yaml 54 | 55 | 1 directory, 3 files 56 | % cat tsuru.yaml 57 | hooks: 58 | build: 59 | - go get github.com/bmizerany/pat 60 | - go build -o $HOME/myapp src/main.go 61 | % cat Procfile 62 | web: $HOME/myapp -host 0.0.0.0 -port $PORT 63 | % git push tsuru master 64 | 65 | At this point, tsuru will parse the tsuru.yaml file and invoke the build hooks 66 | to build your application, and then use the command specified in the Procfile 67 | to start it. 68 | -------------------------------------------------------------------------------- /java/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru java image 6 | # to run it: 7 | # 1- run: $ tsuru-admin platform-add java -d https://raw.github.com/tsuru/basebuilder/master/java/Dockerfile 8 | 9 | FROM tsuru/java 10 | -------------------------------------------------------------------------------- /java/README.md: -------------------------------------------------------------------------------- 1 | # Java platform 2 | 3 | The Java platform supports two kinds of deployment: binary using default tomcat 4 | server or code deployment. 5 | 6 | ##Binary deployment 7 | 8 | You can send a jar file, and java platform will run it with default Procfile 9 | and tomcat7. Default procfile starts with: 10 | 11 | % cat Procfile 12 | web: /var/lib/tsuru/java/start-tomcat 13 | 14 | You can set ``JAVA_MAX_MEMORY`` enviroment variable to set amount memory to run 15 | tomcat, if you don't it will start with 128MB. 16 | 17 | 18 | ##Code deployment 19 | 20 | If you just run a ``git push`` or ``tsuru app-deploy`` of your code, tsuru will try to download all of 21 | your dependencies using ``maven`` and build your application. 22 | -------------------------------------------------------------------------------- /nodejs/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru nodejs image 6 | # to run it: 7 | # 1- run $ tsuru-admin platform-add nodejs -d https://raw.github.com/tsuru/basebuilder/master/nodejs/Dockerfile 8 | 9 | FROM tsuru/nodejs 10 | -------------------------------------------------------------------------------- /nodejs/README.md: -------------------------------------------------------------------------------- 1 | # Nodejs platform 2 | 3 | The Nodejs platform uses nvm to run your code and you can choose what node 4 | version you want to run it. To define node version you have three ways: 5 | 6 | * .nvmrc 7 | $ cat .nvmrc 8 | 4.4.0 9 | * .node-version 10 | $ cat .node-version 11 | 4.4.0 12 | * package.json 13 | $ cat package.json 14 | ... 15 | "engines": { 16 | "node": "4.2.6", 17 | }, 18 | ... 19 | 20 | This file should be in the root of deploy files. 21 | 22 | $ ls 23 | Procfile app.js hook.js package.json 24 | 25 | We use npm to install your dependencies, so you have to list it in 26 | ``package.json`` file. 27 | 28 | $ cat package.json 29 | ... 30 | "dependencies": { 31 | "express": "3.x" 32 | } 33 | ... 34 | 35 | You can also cache your node_modules by setting enviroment variable 36 | ``KEEP_NODE_MODULES=true``. 37 | -------------------------------------------------------------------------------- /php/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru php image 6 | # to run it: 7 | # 1- run: $ tsuru-admin platform-add php -d https://raw.github.com/tsuru/basebuilder/master/php/Dockerfile 8 | 9 | FROM tsuru/php 10 | -------------------------------------------------------------------------------- /php/README.md: -------------------------------------------------------------------------------- 1 | # PHP platform 2 | 3 | The PHP platform is built to be able to manage multiple front-end and interpretors. You can manage them in your `tsuru.yml` configuration file. 4 | 5 | ```yml 6 | php: 7 | frontend: 8 | name: nginx 9 | interpretor: 10 | name: fpm54 11 | composer: true 12 | ``` 13 | 14 | ## Front ends 15 | 16 | The following frontends are currently supported: 17 | - `apache`: Apache 18 | - `nginx`: Nginx 19 | 20 | You can chose between them by setting the `php.frontend.name` parameter: 21 | ```yml 22 | php: 23 | frontend: 24 | name: apache 25 | ``` 26 | 27 | Each frontend supports options that can be set in the `php.frontend.options` parameters. 28 | 29 | All these options are not required, and can be used the following way: 30 | ```yml 31 | php: 32 | frontend: 33 | name: apache 34 | options: 35 | vhost_file: /path/to/vhost.conf 36 | modules: 37 | - rewrite 38 | ``` 39 | 40 | ### Apache options 41 | 42 | - `vhost_file`: The relative path of your Apache virtual host configuration file 43 | - `modules`: An array of module names, such as `rewrite` for instance 44 | 45 | ### Nginx options 46 | 47 | - `vhost_file`: The relative path of your Nginx virtual host configuration file 48 | 49 | ## Interpretors 50 | 51 | The following PHP interpretors are supported: 52 | 53 | - `fpm54`: PHP 5.4 though PHP-FPM 54 | - `fpm55`: PHP 5.5 though PHP-FPM 55 | - `hhvm`: HipHop Virtual Machine (PHP 5.4) 56 | 57 | You can chose between them by setting the `php.interpretor.name` parameter: 58 | ```yml 59 | php: 60 | interpretor: 61 | name: fpm54 62 | ``` 63 | 64 | These interpretors can also have options configured in the `php.interpretor.options` parameter. 65 | 66 | If you choose `fpm54` interpretor, use `extensions` option to install php5 extensions instead of using `requirements.apt` 67 | 68 | All these options are not required and can be used the following ways 69 | ```yml 70 | php: 71 | interpretor: 72 | name: fpm54 73 | options: 74 | ini_file: /path/to/file.ini 75 | extensions: 76 | - php5-mysql 77 | ``` 78 | 79 | ## `fpm54` options 80 | 81 | - `ini_file`: The relative path of your `php.ini` file in your project, that will replace the default one 82 | - `extensions`: A list of php5 extensions you need 83 | 84 | ## `fpm55` options 85 | 86 | - `ini_file`: The relative path of your `php.ini` file in your project, that will replace the default one 87 | - `extensions`: A list of php5 extensions you need 88 | 89 | ## `hhvm` options 90 | 91 | - `ini_file`: The relative path of your `php.ini` file in your project, that will replace the default one 92 | 93 | ## General options 94 | 95 | In addition to the `frontend` and `interpretor` options, there's an other one: 96 | 97 | - `composer`: A boolean that is by default to true. If the value is true, it'll run a `composer install` if there's a `composer.json` file at the root of your application. 98 | 99 | ## Backward compatibility 100 | 101 | To keep the backward compatibility, there's also a `apache-mod-php` frontend that is in fact the Apache with modphp enabled, that remove the need of an interpretor. 102 | That's currently the default configuration if no parameter is set. 103 | 104 | ## Next steps 105 | 106 | With the current implementation, it's quite easy to add another interpretor for instance. 107 | -------------------------------------------------------------------------------- /play/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru play image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add play -d https://raw.github.com/tsuru/basebuilder/master/play/Dockerfile 8 | 9 | FROM tsuru/play 10 | -------------------------------------------------------------------------------- /pypy/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2016 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru pypy image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add pypy -d https://raw.github.com/tsuru/basebuilder/master/pypy/Dockerfile 8 | 9 | FROM tsuru/pypy 10 | -------------------------------------------------------------------------------- /pypy/README.md: -------------------------------------------------------------------------------- 1 | # Pypy platform 2 | 3 | The Pypy platform supports Python 2.7.x. 4 | 5 | ## Code deployment 6 | 7 | If you just run a ``git push`` or ``tsuru app-deploy`` of your code, tsuru will try 8 | to download all of your depencies using ``requirements.txt`` or ``setup script``. 9 | You can customize this behavior, see the next section for more details. 10 | 11 | ## Code deployment with dependencies 12 | 13 | There are two ways to list the applications dependencies: ``requirements.txt`` or ``setup.py``. 14 | The priority order is: requirements -> setup. The file should be in the root of deploy files. 15 | 16 | ### Using requirements.txt 17 | 18 | You can define a file called ``requirements.txt`` that list all pip dependencies of your application, 19 | each line represents one dependency, here's an example: 20 | 21 | $ cat requirements.txt 22 | Flask==0.10.1 23 | gunicorn==19.3.0 24 | 25 | ### Using setup script 26 | 27 | You can also define the setup script to list your depencies, here's an example: 28 | 29 | $ cat setup.py 30 | from setuptools import setup, find_packages 31 | setup( 32 | name="app-name", 33 | packages=find_packages(), 34 | description="example", 35 | include_package_data=True, 36 | install_requires=[ 37 | "Flask==0.10.1", 38 | "gunicorn==19.3.0", 39 | ], 40 | ) 41 | 42 | After invokin ``git push`` or ``tsuru app-deploy``, tsuru will receive your code and tell the platform 43 | to install all the depencies using ``pip install -r requirements.txt`` or ``pip instal -e ./``. -------------------------------------------------------------------------------- /python/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru python image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add python -d https://raw.github.com/tsuru/basebuilder/master/python/Dockerfile 8 | 9 | from tsuru/python 10 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # Python platform 2 | 3 | The Python platform uses Python 2.7.x. 4 | 5 | ## Code deployment 6 | 7 | If you just run a ``git push`` or ``tsuru app-deploy`` of your code, tsuru will try 8 | to download all of your depencies using ``requirements.txt`` or ``setup script``. 9 | You can customize this behavior, see the next section for more details. 10 | 11 | ## Code deployment with dependencies 12 | 13 | There are two ways to list the applications dependencies: ``requirements.txt`` or ``setup.py``. 14 | The priority order is: requirements -> setup. The file should be in the root of deploy files. 15 | 16 | ### Using requirements.txt 17 | 18 | You can define a file called ``requirements.txt`` that list all pip dependencies of your application, 19 | each line represents one dependency, here's an example: 20 | 21 | $ cat requirements.txt 22 | Flask==0.10.1 23 | gunicorn==19.3.0 24 | 25 | ### Using setup script 26 | 27 | You can also define the setup script to list your depencies, here's an example: 28 | 29 | $ cat setup.py 30 | from setuptools import setup, find_packages 31 | setup( 32 | name="app-name", 33 | packages=find_packages(), 34 | description="example", 35 | include_package_data=True, 36 | install_requires=[ 37 | "Flask==0.10.1", 38 | "gunicorn==19.3.0", 39 | ], 40 | ) 41 | 42 | After invokin ``git push`` or ``tsuru app-deploy``, tsuru will receive your code and tell the platform 43 | to install all the depencies using ``pip install -r requirements.txt`` or ``pip instal -e ./``. -------------------------------------------------------------------------------- /python3/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru python3 image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add python3 -d https://raw.github.com/tsuru/basebuilder/master/python3/Dockerfile 8 | 9 | FROM tsuru/python3 10 | -------------------------------------------------------------------------------- /python3/README.md: -------------------------------------------------------------------------------- 1 | # Python3 platform 2 | 3 | The Python3 platform uses Python 3.x. 4 | 5 | ## Code deployment 6 | 7 | If you just run a ``git push`` or ``tsuru app-deploy`` of your code, tsuru will try 8 | to download all of your depencies using ``requirements.txt`` or ``setup script``. 9 | You can customize this behavior, see the next section for more details. 10 | 11 | ## Code deployment with dependencies 12 | 13 | There are two ways to list the applications dependencies: ``requirements.txt`` or ``setup.py``. 14 | The priority order is: requirements -> setup. The file should be in the root of deploy files. 15 | 16 | ### Using requirements.txt 17 | 18 | You can define a file called ``requirements.txt`` that list all pip dependencies of your application, 19 | each line represents one dependency, here's an example: 20 | 21 | $ cat requirements.txt 22 | Flask==0.10.1 23 | gunicorn==19.3.0 24 | 25 | ### Using setup script 26 | 27 | You can also define the setup script to list your depencies, here's an example: 28 | 29 | $ cat setup.py 30 | from setuptools import setup, find_packages 31 | setup( 32 | name="app-name", 33 | packages=find_packages(), 34 | description="example", 35 | include_package_data=True, 36 | install_requires=[ 37 | "Flask==0.10.1", 38 | "gunicorn==19.3.0", 39 | ], 40 | ) 41 | 42 | After invokin ``git push`` or ``tsuru app-deploy``, tsuru will receive your code and tell the platform 43 | to install all the depencies using ``pip install -r requirements.txt`` or ``pip instal -e ./``. -------------------------------------------------------------------------------- /ruby/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru ruby image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add ruby -d https://raw.github.com/tsuru/basebuilder/master/ruby/Dockerfile 8 | 9 | FROM tsuru/ruby 10 | -------------------------------------------------------------------------------- /ruby/README.md: -------------------------------------------------------------------------------- 1 | # Ruby platform 2 | 3 | The Ruby platform uses ruby 2.2.3 by default and get your dependencies from 4 | ``Gemfile``. 5 | 6 | You can define what ruby version you want to with two ways: 7 | 8 | * set ruby version in ``Gemfile``: 9 | $ cat Gemfile 10 | ... 11 | ruby 2.2 12 | ... 13 | 14 | * ``.ruby-version`` file: 15 | $ cat .ruby-version 16 | 2.2 17 | -------------------------------------------------------------------------------- /static/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # this file describes how to build tsuru static image 6 | # to run it: 7 | # 1 - tsuru-admin platform-add static -d https://raw.github.com/tsuru/basebuilder/master/static/Dockerfile 8 | 9 | from tsuru/static 10 | -------------------------------------------------------------------------------- /static/README.md: -------------------------------------------------------------------------------- 1 | # Static platform 2 | 3 | The static platform provides a nginx setup that serves anything that is in the 4 | application directory. A simple application with just an index.html file can be 5 | easily deployed to tsuru. 6 | 7 | ## Customizing nginx configuration 8 | 9 | It's possible to customize nginx configuration by simply placing a file named 10 | nginx.conf in the root of the project. The default configuration file is: 11 | 12 | $ cat nginx.conf 13 | worker_processes 4; 14 | pid /var/lib/nginx/nginx.pid; 15 | error_log stderr; 16 | 17 | events { 18 | worker_connections 1024; 19 | } 20 | 21 | http { 22 | include mime.types; 23 | default_type application/octet-stream; 24 | types_hash_max_size 2048; 25 | 26 | sendfile on; 27 | 28 | keepalive_timeout 65; 29 | access_log /dev/stdout; 30 | 31 | server { 32 | listen 8888; 33 | server_name localhost; 34 | 35 | port_in_redirect off; 36 | 37 | location / { 38 | root /home/application/current; 39 | index index.html index.htm; 40 | } 41 | } 42 | } 43 | 44 | A common practice is to copy it and then do some customizations, as it contains 45 | some mandatory directives for proper behavior on tsuru (like ``port_in_redirect 46 | off``). -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .vagrant 3 | -------------------------------------------------------------------------------- /tests/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Copyright 2015 basebuilder authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | Vagrant.configure("2") do |config| 6 | config.vm.provider :virtualbox do |vbox, override| 7 | vbox.memory = 1024 8 | override.vm.box = "ubuntu14.04" 9 | override.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box" 10 | end 11 | 12 | config.vm.provider :aws do |aws, override| 13 | override.vm.box = "dummy" 14 | override.vm.box_url = "https://raw.githubusercontent.com/mitchellh/vagrant-aws/master/dummy.box" 15 | 16 | override.ssh.username = "ubuntu" 17 | override.ssh.private_key_path = ENV["AWS_PRIVATE_KEY_PATH"] 18 | 19 | aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] 20 | aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"] 21 | aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] 22 | aws.ami = ENV["AWS_AMI"] 23 | aws.region = ENV["AWS_REGION"] 24 | aws.instance_type = ENV["AWS_INSTANCE_TYPE"] 25 | aws.instance_ready_timeout = 300 26 | aws.security_groups = [ENV["AWS_SECURITY_GROUP"]] 27 | aws.subnet_id = ENV["AWS_SUBNET_ID"] 28 | aws.associate_public_ip = true 29 | aws.block_device_mapping = [{"DeviceName" => "/dev/sda1", "Ebs.VolumeSize" => 60}] 30 | aws.tags = { 31 | "Name" => "vagrant_platform_test", 32 | } 33 | aws.user_data = "#!/bin/bash\nperl -i -pe 's/^# *(.+)(trusty|trusty-updates|trusty-security) multiverse$/$1$2 multiverse/gi' /etc/apt/sources.list" 34 | end 35 | 36 | config.vm.provider :parallels do |prl, override| 37 | prl.memory = 1024 38 | override.vm.box = "parallels/ubuntu-14.04" 39 | end 40 | 41 | config.vm.define :pre_receive, autostart: false do |pre_receive| 42 | pre_receive.vm.network :private_network, ip: "192.168.50.41" 43 | pre_receive.vm.provision :shell, path: "run.bash", args: "pre_receive" 44 | end 45 | 46 | end 47 | -------------------------------------------------------------------------------- /tests/platforms.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -el 2 | 3 | # Copyright 2015 basebuilder authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style 5 | # license that can be found in the LICENSE file. 6 | 7 | if [ -f /vagrant/.env ] 8 | then 9 | source /vagrant/.env 10 | fi 11 | 12 | function add_platform() { 13 | platform=$1 14 | echo "adding platform $platform..." 15 | output_file="/tmp/platform-update-${platform}" 16 | set +e 17 | tsuru-admin platform-add $platform | tee $output_file 18 | result=$? 19 | set -e 20 | if [[ $result != 0 ]]; then 21 | if [[ $(tail -n1 $output_file) != "Error: Duplicate platform" ]]; then 22 | echo "error adding platform $platform" 23 | exit $result 24 | fi 25 | fi 26 | } 27 | 28 | function test_platform() { 29 | platform=$1 30 | app_name=app-${platform} 31 | app_dir=/tmp/${app_name} 32 | echo "testing platform ${platform} with app ${app_name}..." 33 | 34 | if [ -d ${app_dir} ] 35 | then 36 | rm -rf ${app_dir} 37 | fi 38 | 39 | mkdir ${app_dir} 40 | git init ${app_dir} 41 | cp -r /tmp/basebuilder/examples/${platform}/* ${app_dir} 42 | git --git-dir=${app_dir}/.git --work-tree=${app_dir} add ${app_dir}/* 43 | git --git-dir=${app_dir}/.git --work-tree=${app_dir} commit -m "add files" 44 | 45 | tsuru app-create ${app_name} ${platform} -o theonepool -t admin 46 | 47 | echo "Running deploy with git push..." 48 | git --git-dir=${app_dir}/.git --work-tree=${app_dir} push git@localhost:${app_name}.git master 49 | 50 | echo "Running deploy with app-deploy..." 51 | pushd ${app_dir}; tsuru app-deploy -a ${app_name} .; popd 52 | 53 | host=`tsuru app-info -a ${app_name} | grep Address | awk '{print $2}'` 54 | 55 | set +e 56 | for i in `seq 1 5` 57 | do 58 | output=`curl -m 5 -fsSNH "Host: ${host}" localhost` 59 | if [ $? == 0 ] 60 | then 61 | break 62 | fi 63 | sleep 5 64 | done 65 | msg=`echo $output | grep -q "Hello world from tsuru" || echo "ERROR: Platform $platform - Wrong output: $output"` 66 | set -e 67 | 68 | tsuru app-remove -ya ${app_name} 69 | 70 | if [ "$msg" != "" ] 71 | then 72 | echo >&2 $msg 73 | exit 1 74 | fi 75 | } 76 | 77 | function clone_basebuilder() { 78 | if [ -d $1 ] 79 | then 80 | rm -rf $1 81 | fi 82 | git clone https://github.com/tsuru/basebuilder.git $1 83 | git config --global user.email just_testing@tsuru.io 84 | git config --global user.name "Tsuru Platform Tests" 85 | } 86 | 87 | function clean_tsuru_now() { 88 | tsuru app-remove -ya tsuru-dashboard 2>/dev/null 89 | tsuru-admin platform-remove -y python 2>/dev/null 90 | } 91 | 92 | function tsuru_login { 93 | yes $2 | tsuru login $1 94 | } 95 | 96 | export DEBIAN_FRONTEND=noninteractive 97 | sudo -E apt-get install curl -qqy 98 | 99 | export GOPATH=$HOME/go 100 | export PATH=$GOPATH/bin:$PATH 101 | export DOCKER_HOST="tcp://127.0.0.1:4243" 102 | 103 | tsuru_login admin@example.com admin123 104 | 105 | set +e 106 | clean_tsuru_now 107 | set -e 108 | 109 | clone_basebuilder /tmp/basebuilder 110 | echo -e "Host localhost\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 111 | 112 | platforms="static java nodejs php python python3 ruby cordova play go elixir buildpack" 113 | 114 | for platform in $platforms 115 | do 116 | add_platform $platform 117 | test_platform $platform 118 | done 119 | 120 | rm -rf /tmp/basebuilder 121 | rm -rf /tmp/app-* 122 | -------------------------------------------------------------------------------- /tests/run.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash -el 2 | 3 | # Copyright 2015 basebuilder authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style 5 | # license that can be found in the LICENSE file. 6 | 7 | sudo -E -iu $SUDO_USER /vagrant/platforms.bash "$1" 8 | --------------------------------------------------------------------------------