Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr committed Feb 9, 2012
0 parents commit b972d52
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 0 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Perloku
=======

Deploy Perl applications in seconds.

## Step 1

Write an app:

```perl
#!/usr/bin/env perl
use Mojolicious::Lite;

get '/' => sub {
my $self = shift;
$self->render('index');
};

app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
Welcome to the Mojolicious real-time web framework!
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
```
## Step 2 (optional)
Create a Makefile.PL with your dependencies:
```perl
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'app.pl',
VERSION => '1.0',
AUTHOR => 'Magnus Holm <judofyr@gmail.com>',
EXE_FILES => ['app.pl'],
PREREQ_PM => {'Mojolicious' => '2.0'},
test => {TESTS => 't/*.t'}
);
```
## Step 3
Create an executable file called Perloku which runs a server on the port
given as an enviroment variable:
```sh
#!/bin/sh
./app.pl daemon --listen http://*:$PORT
```
Remember to `chmod +x Perloku`!
## Step 4
Deploy:
```sh
git init
git add .
git commit -m "Initial version"
heroku create -s cedar --buildpack http://github.com/judofyr/perloku.git
git push heroku master
```
38 changes: 38 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

indent() {
sed -u 's/^/ /'
}

BUILD_DIR=$1
CACHE_DIR=$2

PERL_VERSION="5.14.2"
PERL_PACKAGE="perloku.s3.amazonaws.com/perl-$PERL_VERSION.tgz"

VENDORED_PERL="$BUILD_DIR/vendor/perl"

echo "-----> Vendoring Perl"

mkdir -p $VENDORED_PERL && curl $PERL_PACKAGE -s -o - | tar xzf - -C $VENDORED_PERL

# Set up so we can use Perl right away
export PATH="$VENDORED_PERL/bin:$PATH"
export PERL5LIB="$VENDORED_PERL/lib/$PERL_VERSION:$VENDORED_PERL/lib/site_perl/$PERL_VERSION"

echo "Using Perl $PERL_VERSION" | indent

if [ -f $BUILD_DIR/Makefile.PL ]; then
echo "-----> Installing dependencies"
VENDOR_DEPS="$BUILD_DIR/vendor/perl-deps"
CACHE_DEPS="$CACHE_DIR/perl-deps"
CPANM="perl -S $(which cpanm) -l $VENDOR_DEPS"

mkdir -p "$CACHE_DIR"
$CPANM --notest --installdeps $BUILD_DIR

mv "$CACHE_DEPS" "$VENDOR_DEPS"

echo "Dependencies installed" | indent
fi

9 changes: 9 additions & 0 deletions bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ -x $1/Perloku ]; then
echo "Perloku"
exit 0
else
exit 1
fi

12 changes: 12 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

BUILD_DIR=$1

cat << EOF
---
config_vars:
PATH: /app/vendor/perl/bin:/usr/bin:/bin
PERL5OPT: -Mlocal::lib=/app/vendor/perl-deps
default_process_types:
web: ./Perloku $PORT
EOF
22 changes: 22 additions & 0 deletions support/build_perl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
PERL_VERSION="perl-5.14.2"
PERLBREW_URL="http://install.perlbrew.pl"
CPANM_URL="http://cpanmin.us"

PERLBREW_ROOT="/tmp/perl"
PERLBREW_INSTALL_OPTIONS="-Duserelocatableinc -n -v"

PERL_ROOT="$PERLBREW_ROOT/perls/$PERL_VERSION"

vulcan build -v -p "$PERL_ROOT" -c "
echo '
export PERLBREW_ROOT=$PERLBREW_ROOT
curl -kL $PERLBREW_URL | bash
source $PERLBREW_ROOT/etc/bashrc
perlbrew init
perlbrew install $PERL_VERSION $PERLBREW_INSTALL_OPTIONS
perlbrew use $PERL_VERSION
curl -L $CPANM_URL | perl - --self-upgrade
cpanm local::lib
' | bash"

0 comments on commit b972d52

Please sign in to comment.