docbrown/Dockerfile
Hector Bustillos 27a7a199d7 #4129 Reduce Dockerfile size (#4251)
* The previous Dockerfile was using and outdated format and was causing
heavy load times.

The number of the lines in the Dockerfile are defined as layer, with more
layers more time and bigger is the final image.

There were many things that were able to be delegated to the official ruby
docker image.

*  - Use yarn community package
 - Don't create the workdir directory since is created by docker if doesn't exists
 - Remove config/application.yml from .dockerignore

* Update Dockerfile

Co-Authored-By: Abenet Tamiru <mail@abenet.me>

* Update Dockerfile

Co-Authored-By: Abenet Tamiru <mail@abenet.me>

* Add directory copy, and user correct folder in compose

* Update docker-compose and Dockerfile

* Fix typo

Co-Authored-By: Mac Siri <krairit.siri@gmail.com>

* Update wording

Co-Authored-By: Mac Siri <krairit.siri@gmail.com>
2019-10-10 18:01:04 -04:00

84 lines
2.6 KiB
Docker

FROM ruby:2.6.3-alpine3.10
#------------------------------------------------------------------------------
#
# Install Project dependencies
#
#------------------------------------------------------------------------------
RUN apk update -qq && apk add git nodejs postgresql-client ruby-dev build-base \
libxml2-dev libxslt-dev pcre-dev libffi-dev postgresql-dev tzdata
#------------------------------------------------------------------------------
#
# Install required bundler version
#
#------------------------------------------------------------------------------
RUN gem install bundler:2.0.2
#------------------------------------------------------------------------------
#
# Install Yarn
#
#------------------------------------------------------------------------------
ENV PATH=/root/.yarn/bin:$PATH
RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \
yarn
#------------------------------------------------------------------------------
#
# Define working directory
#
#------------------------------------------------------------------------------
WORKDIR /usr/src/app
#------------------------------------------------------------------------------
#
# Copy Gemfile and run bundle install
#
#------------------------------------------------------------------------------
COPY Gemfile /usr/src/app/Gemfile
COPY ./Gemfile ./Gemfile.lock ./
RUN bundle install --jobs 20 --retry 5
#------------------------------------------------------------------------------
#
# Copy Package.json and yarn.lock
#
#------------------------------------------------------------------------------
COPY ./package.json ./yarn.lock ./
#------------------------------------------------------------------------------
#
# Install packages
#
#------------------------------------------------------------------------------
RUN yarn install && yarn check --integrity
# timeout extension required to ensure
# system work properly on first time load
ENV RACK_TIMEOUT_WAIT_TIMEOUT=10000 \
RACK_TIMEOUT_SERVICE_TIMEOUT=10000 \
STATEMENT_TIMEOUT=10000
# Run mode configuration between dev / demo
# for entrypoint script behaviour
ENV RUN_MODE="demo"
# Database URL configuration - with user/pass
ENV DATABASE_URL="postgresql://devto:devto@db:5432/PracticalDeveloper_development"
# DB setup / migrate script triggers on boot
ENV DB_SETUP="false" \
DB_MIGRATE="false"
#
# Let's setup the public uploads folder volume
#
RUN mkdir -p /usr/src/app/public/uploads
VOLUME /usr/src/app/public/uploads
# Entrypoint and command to start the server
COPY docker-entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/docker-entrypoint.sh
COPY . /usr/src/app