forked from judofyr/perloku
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b972d52
Showing
5 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]>', | ||
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 | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|