├── bin ├── detect ├── release └── compile └── README.md /bin/detect: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # this pack is valid for apps with an app.psgi in the root 4 | if [ -f $1/app.psgi ]; then 5 | echo "Perl/PSGI" 6 | exit 0 7 | else 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cat << EOF 4 | --- 5 | addons: 6 | config_vars: 7 | PATH: local/bin:/usr/local/bin:/usr/bin:/bin 8 | default_process_types: 9 | web: perl -Mlib=\$PWD/local/lib/perl5 ./local/bin/starman --preload-app --port \$PORT 10 | EOF 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Heroku buildpack: Perl 2 | ====================== 3 | 4 | This is a Heroku buildpack that runs any PSGI based web applications using Starman. 5 | 6 | Usage 7 | ----- 8 | 9 | Example usage: 10 | 11 | $ ls 12 | cpanfile 13 | app.psgi 14 | lib/ 15 | 16 | $ cat cpanfile 17 | requires 'Plack', '1.0000'; 18 | requires 'DBI', '1.6'; 19 | 20 | $ heroku create --stack cedar --buildpack https://github.com/miyagawa/heroku-buildpack-perl.git 21 | 22 | $ git push heroku master 23 | ... 24 | -----> Heroku receiving push 25 | -----> Fetching custom buildpack 26 | -----> Perl/PSGI app detected 27 | -----> Installing dependencies 28 | 29 | The buildpack will detect that your app has an `app.psgi` in the root. 30 | 31 | Libraries 32 | --------- 33 | 34 | Dependencies can be declared using `cpanfile` (recommended) or more traditional `Makefile.PL`, `Build.PL` and `META.json` (whichever you can install with `cpanm --installdeps`), and the buildpack will install these dependencies using [cpanm](http://cpanmin.us) into `./local` directory. 35 | 36 | -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Usage: 3 | # 4 | # $ bin/compile 5 | 6 | # Fail fast and fail hard. 7 | set -eo pipefail 8 | 9 | indent() { 10 | sed -u 's/^/ /' 11 | } 12 | 13 | BUILD_DIR=$1 14 | CACHE_DIR=$2 15 | ENV_DIR=$3 16 | 17 | PATH="$BUILD_DIR/local/bin:$PATH" 18 | 19 | export PERL5LIB="$BUILD_DIR/local/lib/perl5" 20 | 21 | PERL_CPANM_OPT="--quiet --notest -l $BUILD_DIR/local" 22 | if [ -f $ENV_DIR/PERL_CPANM_OPT ]; then 23 | PERL_CPANM_OPT="$PERL_CPANM_OPT $(cat $ENV_DIR/PERL_CPANM_OPT)" 24 | fi 25 | export PERL_CPANM_OPT 26 | 27 | rm -rf $BUILD_DIR/local 28 | if [ -d $CACHE_DIR/local ]; then 29 | cp -a $CACHE_DIR/local $BUILD_DIR/local 30 | fi 31 | 32 | cd $BUILD_DIR 33 | 34 | if ! [ -e $BUILD_DIR/local/bin/cpanm ]; then 35 | echo "-----> Bootstrapping cpanm" 36 | curl -L --silent https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm | perl - App::cpanminus 2>&1 | indent 37 | fi 38 | 39 | echo "-----> Installing dependencies" 40 | echo "cpanm options: $PERL_CPANM_OPT" | indent 41 | cpanm --installdeps . 2>&1 | indent 42 | 43 | echo "-----> Installing Starman" 44 | cpanm Starman 2>&1 | indent 45 | 46 | if [ -d $BUILD_DIR/local ]; then 47 | rm -rf $CACHE_DIR/local 48 | mkdir -p $CACHE_DIR 49 | cp -a $BUILD_DIR/local $CACHE_DIR/local 50 | fi 51 | --------------------------------------------------------------------------------