├── LICENSE.md ├── README.md ├── bin ├── compile ├── detect └── release └── support └── build_perl /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Magnus Holm 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to 5 | deal in the Software without restriction, including without limitation the 6 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Perloku 2 | ======= 3 | 4 | Deploy Perl applications in seconds. 5 | 6 | ## Step 1 7 | 8 | Write an app: 9 | 10 | ```perl 11 | #!/usr/bin/env perl 12 | use Mojolicious::Lite; 13 | 14 | get '/' => sub { 15 | my $self = shift; 16 | $self->render('index'); 17 | }; 18 | 19 | app->start; 20 | __DATA__ 21 | 22 | @@ index.html.ep 23 | % layout 'default'; 24 | % title 'Welcome'; 25 | Welcome to the Mojolicious real-time web framework! 26 | 27 | @@ layouts/default.html.ep 28 | 29 | 30 | <%= title %> 31 | <%= content %> 32 | 33 | ``` 34 | 35 | ## Step 2 36 | 37 | Create a Makefile.PL with your dependencies: 38 | 39 | ```perl 40 | use strict; 41 | use warnings; 42 | 43 | use ExtUtils::MakeMaker; 44 | 45 | WriteMakefile( 46 | NAME => 'app.pl', 47 | VERSION => '1.0', 48 | AUTHOR => 'Magnus Holm ', 49 | EXE_FILES => ['app.pl'], 50 | PREREQ_PM => {'Mojolicious' => '2.0'}, 51 | test => {TESTS => 't/*.t'} 52 | ); 53 | ``` 54 | 55 | Alternately, you may create a 56 | [cpanfile](http://search.cpan.org/~miyagawa/Module-CPANfile-1.0002/lib/cpanfile.pod) 57 | that lists dependencies instead: 58 | 59 | ``` 60 | requires 'Mojolicious', '2.0'; 61 | ``` 62 | 63 | ## Step 3 64 | 65 | Create an executable file called Perloku which runs a server on the port 66 | given as an enviroment variable: 67 | 68 | ```sh 69 | #!/bin/sh 70 | ./app.pl daemon --listen http://*:$PORT 71 | ``` 72 | 73 | 74 | Test that you can start the server: 75 | 76 | ```sh 77 | chmod +x Perloku 78 | PORT=3000 ./Perloku 79 | ``` 80 | 81 | ## Step 4 82 | 83 | Deploy: 84 | 85 | ```sh 86 | git init 87 | git add . 88 | git update-index --chmod=+x Perloku (only if using Windows) 89 | git update-index --chmod=+x app.pl (only if using Windows) 90 | git commit -m "Initial version" 91 | heroku create -s cedar --buildpack http://github.com/judofyr/perloku.git 92 | git push heroku master 93 | ``` 94 | 95 | 96 | Watch: 97 | 98 | ``` 99 | Counting objects: 5, done. 100 | Delta compression using up to 8 threads. 101 | Compressing objects: 100% (4/4), done. 102 | Writing objects: 100% (5/5), 808 bytes, done. 103 | Total 5 (delta 0), reused 0 (delta 0) 104 | 105 | -----> Heroku receiving push 106 | -----> Fetching custom buildpack... done 107 | -----> Perloku app detected 108 | -----> Vendoring Perl 109 | Using Perl 5.16.2 110 | -----> Installing dependencies 111 | --> Working on /tmp/build_19tm6pb8ch1qa 112 | Configuring /tmp/build_19tm6pb8ch1qa ... OK 113 | ==> Found dependencies: Mojolicious 114 | --> Working on Mojolicious 115 | Fetching http://search.cpan.org/CPAN/authors/id/T/TE/TEMPIRE/Mojolicious-2.48.tar.gz ... OK 116 | Configuring Mojolicious-2.48 ... OK 117 | Building Mojolicious-2.48 ... OK 118 | Successfully installed Mojolicious-2.48 119 | <== Installed dependencies for /tmp/build_19tm6pb8ch1qa. Finishing. 120 | 1 distribution installed 121 | Dependencies installed 122 | -----> Discovering process types 123 | Procfile declares types -> (none) 124 | Default types for Perloku -> web 125 | -----> Compiled slug size is 12.4MB 126 | -----> Launching...gi done, v5 127 | http://perloku-example.herokuapp.com deployed to Heroku 128 | 129 | To git@heroku.com:perloku-example.git 130 | * [new branch] master -> master 131 | ``` 132 | 133 | [Enjoy!](http://perloku-example.herokuapp.com) 134 | -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | indent() { 4 | sed -u 's/^/ /' 5 | } 6 | 7 | BUILD_DIR=$1 8 | CACHE_DIR=$2 9 | 10 | PERL_VERSION="5.18.1" 11 | PERL_PACKAGE="perloku.s3.amazonaws.com/perl-$PERL_VERSION.tgz" 12 | 13 | VENDORED_PERL="$BUILD_DIR/vendor/perl" 14 | 15 | echo "-----> Vendoring Perl" 16 | 17 | mkdir -p $VENDORED_PERL && curl $PERL_PACKAGE -s -o - | tar xzf - -C $VENDORED_PERL 18 | 19 | # Set up so we can use Perl right away 20 | export PATH="$VENDORED_PERL/bin:$PATH" 21 | export PERL5LIB="$VENDORED_PERL/lib/$PERL_VERSION:$VENDORED_PERL/lib/site_perl/$PERL_VERSION" 22 | 23 | echo "Using Perl $PERL_VERSION" | indent 24 | 25 | if [ -f $BUILD_DIR/Makefile.PL ] || [ -f $BUILD_DIR/cpanfile ]; then 26 | echo "-----> Installing dependencies" 27 | VENDOR_DEPS="$BUILD_DIR/vendor/perl-deps" 28 | CACHE_DEPS="$CACHE_DIR/$PERL_VERSION/perl-deps" 29 | CPANM="perl -S $(which cpanm) -l $CACHE_DEPS" 30 | 31 | mkdir -p "$CACHE_DIR" 32 | $CPANM --notest --installdeps "$BUILD_DIR" 2>&1 | indent 33 | 34 | cp -R "$CACHE_DEPS" "$VENDOR_DEPS" 35 | 36 | echo "Dependencies installed" | indent 37 | fi 38 | 39 | -------------------------------------------------------------------------------- /bin/detect: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -x $1/Perloku ]; then 4 | echo "Perloku" 5 | exit 0 6 | else 7 | exit 1 8 | fi 9 | 10 | exit 0 11 | 12 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BUILD_DIR=$1 4 | 5 | cat << EOF 6 | --- 7 | config_vars: 8 | PATH: /app/vendor/perl/bin:/usr/bin:/bin 9 | PERL5OPT: -Mlocal::lib=/app/vendor/perl-deps 10 | default_process_types: 11 | web: ./Perloku $PORT 12 | EOF 13 | -------------------------------------------------------------------------------- /support/build_perl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PERL_VERSION="perl-5.18.1" 3 | PERLBREW_URL="http://install.perlbrew.pl" 4 | CPANM_URL="http://cpanmin.us" 5 | 6 | PERLBREW_ROOT="/tmp/perl" 7 | PERLBREW_INSTALL_OPTIONS="-Duserelocatableinc -n -v" 8 | 9 | PERL_ROOT="$PERLBREW_ROOT/perls/$PERL_VERSION" 10 | 11 | vulcan build -v -p "$PERL_ROOT" -c " 12 | echo ' 13 | export PERLBREW_ROOT=$PERLBREW_ROOT 14 | curl -kL $PERLBREW_URL | bash 15 | source $PERLBREW_ROOT/etc/bashrc 16 | perlbrew init 17 | perlbrew install $PERL_VERSION $PERLBREW_INSTALL_OPTIONS 18 | perlbrew use $PERL_VERSION 19 | curl -L $CPANM_URL | perl - --self-upgrade 20 | cpanm local::lib 21 | ' | bash" 22 | 23 | --------------------------------------------------------------------------------