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

Dockerization #46

Merged
merged 28 commits into from
Feb 5, 2024
Merged
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
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ jobs:
matrix:
ruby-version: ['2.7.5']
experimental: [false]
include:
- ruby-version: 3.0.3
experimental: true

steps:
- name: Pin chrome
uses: abhi1693/[email protected]
Expand All @@ -63,7 +59,7 @@ jobs:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Update rubygems
run: |
gem update --system
gem install rubygems-update -v 3.4.22
gem install bundler:2.3.15

- name: Set up JDK 1.8
Expand Down Expand Up @@ -102,7 +98,7 @@ jobs:
- name: Setup hyrax test environment
run: |
bundle exec rake hydra:test_server &
sleep 150
sleep 180
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the GHA container is a little slower so I bumped the sleep.

# - name: Rubbocop
# run: |
# bundle exec rubocop
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ config/java.yml
# Spring stuff
bin/rspec
bin/spring

# env files
.env
coverage/
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM ruby:2.7.5

ARG RAILS_ENV
ARG SECRET_KEY_BASE

# Necessary for bundler to operate properly
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# add nodejs and yarn dependencies for the frontend
# RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

# --allow-unauthenticated needed for yarn package
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y ca-certificates nodejs \
build-essential libpq-dev libreoffice unzip ghostscript vim \
ffmpeg \
clamav-freshclam clamav-daemon libclamav-dev \
libqt5webkit5-dev xvfb xauth default-jre-headless --fix-missing --allow-unauthenticated

RUN apt-get install chromium -y

# Increase stack size limit to help working with large works
ENV RUBY_THREAD_MACHINE_STACK_SIZE 8388608

RUN gem install rubygems-update -v 3.4.22

RUN mkdir /data
WORKDIR /data

# Pre-install gems so we aren't reinstalling all the gems when literally any
# filesystem change happens
ADD Gemfile /data
ADD Gemfile.lock /data
RUN mkdir /data/build
ADD ./build/install_gems.sh /data/build
RUN ./build/install_gems.sh
RUN mkdir /data/pdfs


# Add the application code
ADD . /data

# install node dependencies, after there are some included
#RUN yarn install
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ gem 'puma', '~> 4.3'
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby

# 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
Expand Down Expand Up @@ -71,6 +70,7 @@ group :test do
gem 'ffaker'
gem 'ladle'
gem 'capybara', '>= 2.15'
gem 'capybara-screenshot'
gem 'selenium-webdriver'
gem 'webdrivers', '~> 4.0', require: false
end
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
capybara-screenshot (1.0.26)
capybara (>= 1.0, < 4)
launchy
carrierwave (1.3.2)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
Expand Down Expand Up @@ -486,6 +489,8 @@ GEM
kaminari (~> 1.0)
ladle (1.0.1)
open4 (~> 1.0)
launchy (2.5.2)
addressable (~> 2.8)
ld-patch (3.1.2)
ebnf (~> 2.1)
rdf (~> 3.1)
Expand All @@ -508,7 +513,6 @@ GEM
rdf (~> 3.0)
legato (0.7.0)
multi_json
libv8 (3.16.14.19)
link_header (0.0.8)
linkeddata (3.1.1)
equivalent-xml (~> 0.6)
Expand Down Expand Up @@ -711,7 +715,6 @@ GEM
redis (>= 3.0.4)
redlock (1.2.1)
redis (>= 3.0.0, < 5.0)
ref (2.0.0)
regexp_parser (2.0.3)
representable (3.0.4)
declarative (< 0.1.0)
Expand Down Expand Up @@ -845,9 +848,6 @@ GEM
sxp (1.1.0)
rdf (~> 3.1)
temple (0.8.2)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.10)
Expand Down Expand Up @@ -894,6 +894,7 @@ DEPENDENCIES
bootstrap-sass (~> 3.0)
byebug
capybara (>= 2.15)
capybara-screenshot
coffee-rails (~> 4.2)
devise
devise-guests (~> 0.6)
Expand Down Expand Up @@ -924,7 +925,6 @@ DEPENDENCIES
simplecov-lcov (~> 0.8.0)
solr_wrapper (~> 2.1.0)
sqlite3 (~> 1.3.6)
therubyracer
tufts-curation!
turbolinks (~> 5)
twitter-typeahead-rails (= 0.11.1.pre.corejavascript)
Expand Down
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
# README
# Trove

This README would normally document whatever steps are necessary to get the
application up and running.
## About

Things you may want to cover:
Collections in Trove are available for use by Tufts University faculty and students, for teaching and research purposes. Collections will include images selected by faculty for teaching Art History courses. Faculty and students can create personal collections of images selected from those available in Trove.

* Ruby version

* System dependencies
## Running Test Locally

* Configuration
* MIRA test docker environment should be running already

* Database creation

* Database initialization
```
docker-compose up test
docker exec -it trove_test_1 /bin/bash
xvfb-run -a bundle exec rake spec SPEC_OPTS="--tag ~noci_local"

* How to run the test suite
```

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
There are two testing tags, noci and noci_local some tests aren't working in the dockerized environment we'll re-address when we move to Ruby 3
16 changes: 16 additions & 0 deletions build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

echo "Building ${RAILS_ENV}"

# Remove previous servers pid
rm -f tmp/puma.pid

# Guarantee gems are installed in case docker image is outdated
./build/install_gems.sh

# Do not auto-migrate for production or staging environments
if [ "${RAILS_ENV}" != 'production' ] && [ "${RAILS_ENV}" != 'staging' ]; then
./build/validate_migrated.sh
fi

echo "Migration Validated"
8 changes: 8 additions & 0 deletions build/install_gems.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

if [ "${RAILS_ENV}" = 'production' ] || [ "${RAILS_ENV}" = 'staging' ]; then
echo "Bundle install without development or test gems."
bundle install --without development test
else
bundle install --without production
fi
14 changes: 14 additions & 0 deletions build/validate_migrated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

if [ "${RAILS_ENV}" = 'production' ] || [ "${RAILS_ENV}" = 'staging' ]; then
echo "Cannot auto-migrate ${RAILS_ENV} database, exiting"
exit 1
fi

echo "Checking ${RAILS_ENV} database migration status and auto-migrating if necessary."
# If the migration status can't be read or is not fully migrated
# then update the database with latest migrations
if bundle exec rails db:migrate:status &> /dev/null; then
bundle exec rails db:migrate
fi
echo "Done checking ${RAILS_ENV} database migration status"
3 changes: 0 additions & 3 deletions config/blacklight.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ development:
test: &test
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_TEST_PORT', 8985)}/solr/hydra-test" %>
production:
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
30 changes: 13 additions & 17 deletions config/database.yml.sample
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: mysql2
encoding: utf8
reconnect: false
pool: 20
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
database: <%= ENV['DB_NAME'] %>
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
host: <%= ENV['DB_HOST'] %>
port: <%= ENV['DB_PORT'] %>

development:
<<: *default
database: trove
database: <%= ENV.fetch('DB_NAME', 'tdl_on_hyrax') %>

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
database: trove_test
user: root
password: root
pool: 5
timeout: 5000
<<: *default
database: <%= ENV.fetch('DB_NAME', 'tdl_on_hyrax_test') %>
username: <%= ENV.fetch('DB_USERNAME', 'root') %>
password: <%= ENV.fetch('DB_PASSWORD', 'root') %>

production:
<<: *default
database: trove
encoding: unicode
pool: 50
10 changes: 10 additions & 0 deletions config/env.apple-silicon.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#COMMON SETTINGS

SERVER_PORTS="4000:4000"
SERVER_EXPOSE="4000"
TEST_PORTS="4101:4001"
TEST_EXPOSE="4111"

# APPLE SILICONE SETTINGS
SELENIUM_IMAGE="seleniarm/standalone-chromium"
SELENIUM_PLATFORM="linux/arm64"
10 changes: 10 additions & 0 deletions config/env.intel.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#COMMON SETTINGS

SERVER_PORTS="4000:4000"
SERVER_EXPOSE="4000"
TEST_PORTS="4101:4001"
TEST_EXPOSE="4111"

# INTEL SETTINGS
SELENIUM_IMAGE="selenium/standalone-chrome:3.141"
SELENIUM_PLATFORM="linux/amd64"
9 changes: 2 additions & 7 deletions config/fedora.yml.sample
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
development:
user: fedoraAdmin
password: fedoraAdmin
url: http://127.0.0.1:<%= ENV['FCREPO_DEVELOPMENT_PORT'] || 8984 %>/rest
url: <%= ENV['FEDORA_URL'] || "http://127.0.0.1:#{ENV.fetch('FCREPO_DEVELOPMENT_PORT', 8984)}/rest" %>
base_path: /dev
test:
user: fedoraAdmin
password: fedoraAdmin
url: http://127.0.0.1:<%= ENV['FCREPO_TEST_PORT'] || 8986 %>/rest
url: <%= ENV['FEDORA_URL'] || "http://127.0.0.1:#{ENV.fetch('FCREPO_TEST_PORT', 8986)}/rest" %>
base_path: /test
production:
user: fedoraAdmin
password: fedoraAdmin
url: http://127.0.0.1:8983/fedora/rest
base_path: /prod
21 changes: 9 additions & 12 deletions config/ldap.yml.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Authorizations
# Uncomment out the merging for each environment that you'd like to include.
# Uncomment out the merging for each enviornment that you'd like to include.
# You can also just copy and paste the tree (do not include the "authorizations") to each
# environment if you need something different per enviornment.
# enviornment if you need something different per enviornment.
authorizations: &AUTHORIZATIONS
group_base: ou=groups,dc=test,dc=com
## Requires config.ldap_check_group_membership in devise.rb be true
Expand All @@ -18,18 +17,17 @@ authorizations: &AUTHORIZATIONS
objectClass: inetOrgPerson
authorizationRole: postsAdmin

## Environment
## Enviornments

development:
host: localhost
host: ldap.tufts.edu
port: 636
attribute: cn
base: ou=people,dc=test,dc=com
admin_user: cn=admin,dc=test,dc=com
admin_password: admin_password
ssl: false
attribute: uid
base: dc=tufts, dc=edu
admin_user: some_user
admin_password: some_password
ssl: true
# <<: *AUTHORIZATIONS

test:
host: localhost
port: 3897
Expand All @@ -39,7 +37,6 @@ test:
admin_password: admin_password
ssl: false
# <<: *AUTHORIZATIONS

production:
host: localhost
port: 636
Expand Down
Loading
Loading