Created
March 19, 2015 22:16
-
-
Save bmorton/1aca93355e740f2a251f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
FROM yammer/ruby:2.2.0 | |
MAINTAINER Brian Morton "[email protected]" | |
# Install package dependencies for pg gem | |
RUN locale-gen en_US.UTF-8 | |
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | |
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list | |
RUN apt-get -y update | |
RUN apt-get -y install postgresql-client libpq-dev | |
# Install javascript runtime | |
RUN apt-get -y install nodejs | |
# Install etcd client | |
ENV ETCD_VERSION v2.0.0-rc.1 | |
ADD https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz /tmp/ | |
RUN tar -xvzf /tmp/etcd-${ETCD_VERSION}-linux-amd64.tar.gz -C /tmp | |
RUN mv /tmp/etcd-${ETCD_VERSION}-linux-amd64/etcdctl /bin/etcdctl | |
RUN rm -rf /tmp/* | |
# Add and install gem dependencies | |
ADD Gemfile /app/Gemfile | |
ADD Gemfile.lock /app/Gemfile.lock | |
RUN bash -l -c "cd /app && bundle install --deployment --without development test" | |
ADD . /app | |
# Use a fake DATABASE_URL for precompiling assets to trick Rails | |
# since it requires a string, but never connects during compilation | |
RUN bash -l -c "cd /app && RAILS_GROUPS=assets DATABASE_URL=postgresql://user:[email protected]/dbname bundle exec rake assets:precompile" | |
WORKDIR /app | |
EXPOSE 3000 | |
ENTRYPOINT ["/app/bin/env"] | |
CMD ["bundle exec puma -t ${PUMA_MIN_THREADS:-8}:${PUMA_MAX_THREADS:-12} -w ${PUMA_WORKERS:-1} -p 3000 -e ${RACK_ENV:-development} --preload"] |
This file contains hidden or 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
#!/bin/bash -l | |
export DOCKER_HOST_IP=`/sbin/ip route | awk '/default/ { print $3 }'` | |
export ETCDCTL_PEERS="http://${DOCKER_HOST_IP}:4001/" | |
if [ -z "$DATABASE_URL" ]; then | |
echo "Setting DATABASE_URL via etcd..." | |
export DATABASE_URL=`etcdctl get /carousel/database_url` | |
fi | |
if [ -z "$SECRET_KEY_BASE" ]; then | |
echo "Setting SECRET_KEY_BASE via etcd..." | |
export SECRET_KEY_BASE=`etcdctl get /carousel/secret_key_base` | |
fi | |
if [ -z "$RACK_ENV" ]; then | |
echo "Setting RACK_ENV via etcd..." | |
export RACK_ENV=`etcdctl get /carousel/rack_env` | |
fi | |
if [ -z "$PUMA_WORKERS" ]; then | |
echo "Setting PUMA_WORKERS via etcd..." | |
export PUMA_WORKERS=`etcdctl get /carousel/puma_workers` | |
fi | |
# Execute the commands passed to this script | |
$@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment