Dockerfile for production

This commit is contained in:
Patrick Gansterer 2017-02-11 12:44:49 +01:00
parent 03256d28dd
commit fa32fc9229
2 changed files with 15 additions and 25 deletions

View file

@ -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"]

8
docker-entrypoint.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
set -e
if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi
exec "$@"