Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker redux #1

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CAPYBARA_SERVER=http://app:3010
CHROME_HEADLESS_MODE=false
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
DATABASE_TEST_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax_test?pool=5
DATABASE_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax?pool=5
DB_PORT=5432
DB_HOST=postgres
FCREPO_PORT=8080
FCREPO_HOST=fcrepo
FCREPO_REST_PATH=rest
FCREPO_TEST_BASE_PATH=/test
HUB_URL=http://chrome:4444/wd/hub
HYRAX_DERIVATIVES_PATH=/app/samvera/hyrax-webapp/derivatives/
HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine
HYRAX_UPLOAD_PATH=/app/samvera/hyrax-webapp/uploads/
IN_DOCKER=true
RACK_ENV=development
RAILS_ENV=development
RAILS_ROOT=.dassie
REDIS_HOST=redis
SOLR_PORT=8983
SOLR_HOST=solr
SOLR_TEST_URL=http://solr:8983/solr/hyrax_test
SOLR_URL=http://solr:8983/solr/hyrax

#### From .dassie/.env
MEMCACHED_HOST=memcached
HYRAX_ANALYTICS=1
REDIS_PROVIDER=SIDEKIQ_REDIS_URL
SIDEKIQ_REDIS_URL=redis://redis:6379/0

110 changes: 20 additions & 90 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,101 +1,31 @@
# Ripped off from Avalon
# Base stage for building gems
FROM ruby:2.7.2-buster as bundle
RUN echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list \
&& apt-get update \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
ARG HYRAX_IMAGE_VERSION=latest
FROM ghcr.io/samvera/dassie:$HYRAX_IMAGE_VERSION as hyrax-orcid-dev

COPY lib/hyrax/orcid/version.rb ./lib/hyrax/orcid/version.rb
COPY hyrax-orcid.gemspec ./hyrax-orcid.gemspec
COPY Gemfile ./Gemfile
COPY Gemfile.lock ./Gemfile.lock
COPY spec/internal_test_hyrax/Gemfile ./spec/internal_test_hyrax/Gemfile
COPY spec/internal_test_hyrax/Gemfile.lock ./spec/internal_test_hyrax/Gemfile.lock
#ARG APP_PATH=.dassie
ARG BUNDLE_WITHOUT=

RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)" \
&& bundle config build.nokogiri --use-system-libraries
ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine

#COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
COPY --chown=1001:101 ./Gemfile.dassie /app/samvera/hyrax-webapp/Gemfile
COPY --chown=1001:101 . /app/samvera/hyrax-engine

# Build development gems
FROM bundle as bundle-dev
RUN bundle config set without 'production'
RUN bundle config set with 'aws development test postgres'
ENV CFLAGS=-Wno-error=format-overflow
RUN bundle install --jobs=4 --retry=3
RUN cd /app/samvera/hyrax-engine && bundle install --jobs "$(nproc)"
RUN cd /app/samvera/hyrax-webapp && bundle install --jobs "$(nproc)"
#RUN cd /app/samvera/hyrax-webapp && RAILS_ENV=production SECRET_KEY_BASE='fakesecret1234' DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile


# Base stage for building final images
FROM ruby:2.7.1-slim-buster as base
FROM ghcr.io/samvera/dassie-worker:$HYRAX_IMAGE_VERSION as hyrax-orcid-dev-worker

RUN apt-get update && apt-get install -y --no-install-recommends curl gnupg2 \
&& curl -sL http://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && apt-get install -y --no-install-recommends --allow-unauthenticated \
nodejs \
sendmail \
git \
libxml2-dev \
libxslt-dev \
openssh-client \
zip \
dumb-init \
default-jre \
# Below copied from hyku's Dockerfile
build-essential \
ghostscript \
imagemagick \
libpq-dev \
libreoffice \
libsasl2-dev \
netcat \
postgresql-client \
rsync \
tzdata \
unzip \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#ARG APP_PATH=.dassie
ARG BUNDLE_WITHOUT=

# If changes are made to fits version or location,
# amend `LD_LIBRARY_PATH` in docker-compose.yml accordingly.
RUN mkdir -p /opt/fits && \
curl -fSL -o /opt/fits/fits-latest.zip https://projects.iq.harvard.edu/files/fits/files/fits-1.3.0.zip && \
cd /opt/fits && unzip fits-latest.zip && chmod +X /opt/fits/fits.sh
ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine

RUN useradd -m -U app \
&& su -s /bin/bash -c "mkdir -p /home/app" app
WORKDIR /home/app
#COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
COPY --chown=1001:101 ./Gemfile.dassie /app/samvera/hyrax-webapp/Gemfile
COPY --chown=1001:101 . /app/samvera/hyrax-engine

RUN cd /app/samvera/hyrax-webapp && bundle install --jobs "$(nproc)"
RUN cd /app/samvera/hyrax-engine && bundle install --jobs "$(nproc)"

# Build devevelopment image
FROM base as dev

COPY --from=bundle-dev /usr/local/bundle /usr/local/bundle

ARG RAILS_ENV=development
RUN dpkg -i /chrome.deb || apt-get install -yf


# Build production gems
FROM bundle as bundle-prod
RUN bundle install --jobs=4 --retry=3 --without development test --with aws production postgres


# Build production assets
FROM base as assets
COPY --from=bundle-prod --chown=app:app /usr/local/bundle /usr/local/bundle
COPY --chown=app:app . .

USER app
ENV RAILS_ENV=production

RUN SECRET_KEY_BASE=$(ruby -r 'securerandom' -e 'puts SecureRandom.hex(64)') bundle exec rake assets:precompile


# Build production image
FROM base as prod
COPY --from=assets --chown=app:app /home/app /home/app
COPY --from=bundle-prod --chown=app:app /usr/local/bundle /usr/local/bundle

USER app
ENV RAILS_ENV=production
29 changes: 11 additions & 18 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Declare your gem's dependencies in hyrax-orcid.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use a debugger
# gem 'byebug', group: [:development, :test]

eval_gemfile File.expand_path('spec/internal_test_hyrax/Gemfile', File.dirname(__FILE__))
source 'https://rubygems.org' do
# Please see hyrax-orcid.gemspec for dependency information.
gemspec name: 'hyrax-orcid'

group :development, :test do
gem 'pry' unless ENV['CI']
gem 'pry-byebug' unless ENV['CI']
gem 'ruby-prof', require: false
gem "simplecov", require: false
end
end
58 changes: 58 additions & 0 deletions Gemfile.dassie
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.4', '>= 5.2.4.4'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.3.8'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

gem 'dalli' # mem_cache_store support

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

begin # this is a hack to allow `eval_gemfile` to work correctly
gem 'hyrax'
gem 'hyrax-orcid', path: ENV.fetch('HYRAX_ENGINE_PATH', '..')
rescue; end

gem 'rsolr', '>= 1.0', '< 3'
gem 'bootstrap-sass', '~> 3.0'
gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript'
gem 'jquery-rails'
gem 'devise'
gem 'devise-guests', '~> 0.6'
gem 'riiif', '~> 2.1'
gem 'sidekiq', '~> 6.0'
Loading