concord-consortium/rigse

View on GitHub
rails/Dockerfile-dev

Summary

Maintainability
Test Coverage
ARG NODE_VERSION=18.18.0
ARG RUBY_VERSION=2.7

FROM node:${NODE_VERSION}-alpine AS node
# Stick to Alpine <= 3.13 to avoid issues with ECS Docker
# See: https://github.com/docker-library/ruby/issues/351#issue-940462153
FROM docker.io/ruby:${RUBY_VERSION}-alpine3.12

COPY --from=node /usr/lib /usr/lib
COPY --from=node /usr/local/lib /usr/local/lib
COPY --from=node /usr/local/include /usr/local/include
COPY --from=node /usr/local/bin /usr/local/bin

RUN node -v

RUN true

RUN apk add \
  # The Ruby Gem "delayed-web" has a transitive depdency for "racc" which builds
  # native extensions and requires a C toolchain (it attempts to use gcc):
  # "Gem::Ext::BuildError: ERROR: Failed to build gem native extension."
  # "The compiler failed to generate an executable file. (RuntimeError)"
  # "You have to install development tools first."
  build-base \
  # The Ruby Gem "mimemagic" requires Freedesktop.org Shared MIME Info to be installed:
  # "Could not find MIME type database in the following locations:"
  # "Ensure you have either installed the shared-mime-info package for your distribution..."
  shared-mime-info \
  # The Ruby Gem "mysql2" requires a MySQL client library to link against
  # See: https://github.com/brianmario/mysql2#general-instructions
  mariadb-dev \
  # The "execjs" requires a supported JavaScript runtime to be installed
  # "/usr/local/bundle/gems/execjs-2.8.1/lib/execjs/runtimes.rb:58:in `autodetect':
  # Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
  # (ExecJS::RuntimeUnavailable)"
  # See: https://github.com/rails/execjs#execjs
  nodejs \
  # "/usr/local/bundle/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:159:in
  # `rescue in create_default_data_source': tzinfo-data is not present. Please add gem 'tzinfo-data'
  # to your Gemfile and run bundle install (TZInfo::DataSourceNotFound)"
  tzdata \
  # See: https://github.com/sstephenson/ruby-yui-compressor#label-Installing+and+loading+Ruby-YUI+Compressor
  openjdk8-jre \
  # Alpine Linux doesn't include bash by default
  bash

# This is currently commented out, as installing Chrome on Alpine Linux needs to be done in a different way,
# and this linux distribution is missing multiple dependencies required for installing Chrome.
# Install Google Chrome for Selenium
#
# RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
# && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
# && apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y google-chrome-stable

#
# Install wait-for-it to support docker-volume-sync
#
WORKDIR /usr/local/bin
RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/db049716e42767d39961e95dd9696103dca813f1/wait-for-it.sh && \
    chmod +x wait-for-it.sh

ENV APP_HOME /rigse
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

# use a mounted volume so the gems don't need to be rebundled each time
ENV BUNDLE_PATH /bundle

ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
  BUNDLE_JOBS=2 \
  BUNDLE_PATH=/bundle

ENV RAILS_ENV=development

EXPOSE 3000

CMD rails s -b 0.0.0.0