Skip to content

Instantly share code, notes, and snippets.

@petski
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petski/d9a6e5805fd259567f44 to your computer and use it in GitHub Desktop.
Save petski/d9a6e5805fd259567f44 to your computer and use it in GitHub Desktop.
FROM phusion/baseimage:0.9.16
CMD ["/sbin/my_init"]
#
# Apt
#
RUN apt-get -y update
RUN apt-get -y install \
git \
build-essential \
libexpat1-dev \
libxml2-dev \
zlib1g-dev
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#
# Add user
#
RUN useradd -ms /bin/bash user
ENV HOME /home/user
USER user
#
# Set up plenv (and Carton and Starman)
#
# From https://github.com/tokuhirom/plenv:
RUN git clone git://github.com/tokuhirom/plenv.git ~/.plenv
RUN echo 'export PATH="$HOME/.plenv/bin:$PATH"' >> ~/.profile
RUN echo 'eval "$(plenv init -)"' >> ~/.profile
RUN git clone git://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/
RUN bash --login -c "plenv install 5.21.8 && plenv global 5.21.8 && plenv install-cpanm && plenv rehash && cpanm Carton Starman"
#
# Change workdir
#
RUN mkdir -p ~/app
WORKDIR /home/user/app
#
# Set up dancer
#
RUN echo 'requires "Dancer2";' > ~/app/cpanfile
RUN bash --login -c "cd ~/app && carton install && carton exec dancer2 gen --overwrite --application app --directory ."
#
# Expose and run
#
EXPOSE 8080
CMD bash --login -c "cd ~/app && carton exec starman --port 8080 bin/app.psgi"
# Tip: use scan-perl-prereqs to verify cpanfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment