From fa32fc9229edcdc8266ace90423c917798765f91 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Sat, 11 Feb 2017 12:44:49 +0100 Subject: [PATCH] Dockerfile for production --- Dockerfile | 32 +++++++------------------------- docker-entrypoint.sh | 8 ++++++++ 2 files changed, 15 insertions(+), 25 deletions(-) create mode 100755 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index d5fd400c..0aed9bda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,22 @@ -# Based on ruby image, packed with a lot of development dependencies FROM ruby:2.3 -# Install all dependencies for development and testing RUN apt-get update && \ apt-get install --no-install-recommends -y \ - mysql-client \ + cron \ libv8-dev \ libmagic-dev \ - libmysqlclient-dev \ - xvfb \ - iceweasel && \ + libmysqlclient-dev && \ rm -rf /var/lib/apt/lists/* && \ apt-get clean -# Run app and all commands as user 'app'. This avoids changing permissions -# for files in mounted volume. -RUN adduser --gecos GECOS --disabled-password --shell /bin/bash app -USER app +ENV RAILS_ENV=production -# Create an directory to store the application code. -RUN mkdir /home/app/src -WORKDIR /home/app/src - -# Copy plugins before the rest to allow bundler loading gemspecs -# TODO: Move plugins to gems and add them to Gemfile instead -COPY plugins ./plugins - -# Add Gemfiles and run bundle. -COPY Gemfile Gemfile.lock ./ -ENV BUNDLE_JOBS=4 BUNDLE_PATH=/home/app/bundle \ - BUNDLE_APP_CONFIG=/home/app/bundle/config -RUN bundle install - -# Copy the application code. (Excluded files see .dockerignore) +WORKDIR /usr/src/app COPY . ./ +RUN bundle install --without development --without test && \ + whenever --update-crontab EXPOSE 3000 +ENTRYPOINT ["./docker-entrypoint.sh"] CMD ["rails", "server", "--binding", "0.0.0.0"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..2f02d475 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +if [ -f tmp/pids/server.pid ]; then + rm tmp/pids/server.pid +fi + +exec "$@"