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 10 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
6 changes: 1 addition & 5 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 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/
71 changes: 71 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM ruby:2.7.7

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 imagemagick unzip ghostscript vim \
libqt5webkit5-dev xvfb xauth default-jre-headless --fix-missing --allow-unauthenticated

RUN apt-get update && apt-get install -y wget gnupg
RUN apt-get install -y wget apt-transport-https gnupg
RUN echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list

RUN wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public| apt-key add - \
&& apt-get update \
&& apt-get install -y temurin-8-jdk

RUN update-java-alternatives --set /usr/lib/jvm/temurin-8-jdk-amd64
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 suspect we may start needing this change in other places, worth noting: https://adoptium.net/blog/2023/07/adoptopenjdk-jfrog-io-has-been-deprecated/


RUN apt-get update && apt-get install -y wget unzip libatk1.0-0 libgtk-3-0 libgbm1

# Download and extract Google Chrome
RUN wget https://github.com/Alex313031/thorium/releases/download/M114.0.5735.134/thorium-browser_114.0.5735.134_amd64.zip && \
unzip chrome-linux.zip -d /usr/local/bin/ && \
rm chrome-linux.zip

# Create a symbolic link to the Chrome binary
RUN ln -s /usr/local/bin/thorium /usr/local/bin/google-chrome
RUN ln -s /usr/local/bin/thorium /usr/local/bin/chrome
RUN ln -s /usr/local/bin/thorium /usr/local/bin/chromium

# Cleanup unnecessary files
RUN apt-get remove -y wget unzip && apt-get clean

# Verify the installation
RUN google-chrome --version

Choose a reason for hiding this comment

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

We can get rid of this now.


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

RUN gem update --system

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
9 changes: 9 additions & 0 deletions build/configs/blacklight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
development:
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_DEVELOPMENT_PORT', 8983)}/solr/hydra-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/epigaea" %>
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"
64 changes: 64 additions & 0 deletions collection_types.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
-- MySQL dump 10.13 Distrib 5.6.50, for Linux (x86_64)
--
-- Host: localhost Database: trove
-- ------------------------------------------------------
-- Server version 5.6.50-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `hyrax_collection_types`
--

DROP TABLE IF EXISTS `hyrax_collection_types`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hyrax_collection_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`description` text COLLATE utf8_bin,
`machine_id` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nestable` tinyint(1) NOT NULL DEFAULT '1',
`discoverable` tinyint(1) NOT NULL DEFAULT '1',
`sharable` tinyint(1) NOT NULL DEFAULT '1',
`allow_multiple_membership` tinyint(1) NOT NULL DEFAULT '1',
`require_membership` tinyint(1) NOT NULL DEFAULT '0',
`assigns_workflow` tinyint(1) NOT NULL DEFAULT '0',
`assigns_visibility` tinyint(1) NOT NULL DEFAULT '0',
`share_applies_to_new_works` tinyint(1) NOT NULL DEFAULT '1',
`brandable` tinyint(1) NOT NULL DEFAULT '1',
`badge_color` varchar(255) COLLATE utf8_bin DEFAULT '#663333',
PRIMARY KEY (`id`),
UNIQUE KEY `index_hyrax_collection_types_on_machine_id` (`machine_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `hyrax_collection_types`
--

LOCK TABLES `hyrax_collection_types` WRITE;
/*!40000 ALTER TABLE `hyrax_collection_types` DISABLE KEYS */;
INSERT INTO `hyrax_collection_types` VALUES (1,'User Collection','A User Collection can be created by any user to organize their works.','user_collection',1,1,1,1,0,0,0,0,1,'#705070'),(2,'Admin Set','An aggregation of works that is intended to help with administrative control. Admin Sets provide a way of defining behaviors and policies around a set of works.','admin_set',0,0,1,0,1,1,1,1,0,'#405060'),(3,'Course Collection','For Trove','course_collection',1,1,1,1,0,0,0,1,1,'#663333'),(4,'Personal Collection','For Trove','personal_collection',1,1,1,1,0,0,0,1,1,'#663333');
/*!40000 ALTER TABLE `hyrax_collection_types` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2023-08-30 10:54:38
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="4001:4001"
TEST_EXPOSE="4001"

# 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="4001:4001"
TEST_EXPOSE="4001"

# 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
18 changes: 4 additions & 14 deletions config/secrets.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.

# Shared secrets are available across all environments.

# shared:
# api_key: a1B2c3D4e5F6

# Environmental secrets are only available for that specific environment.

development:
secret_key_base: 2587324607eaeace6e44616ed90077357916024c7504fd2196e511cfc29dff863696d68991f90251bb994e5fe7d682d220d3c0c8b83e666c50c36d9d84717ed4
secret_key_base: e1da67e2e2ce9800d7445cb839c27a9ac677bca7521f01cadb9716d75ceffcfce23d377aeea5a3e741a52c3b2349f24406d61784916a6b22c3a07a5589f6269c

test:
secret_key_base: fb0e5387401e0aef4cd1fcd1f622fc7f1be6c756ebc13dd81f699694aaa843428f481552749623b87fb9429f8ee362080a51cf79ed17d24562e1b4cc12e41531

# Do not keep production secrets in the unencrypted secrets file.
# Instead, either read values from the environment.
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
# and move the `production:` environment over there.
secret_key_base: 7f0c89448adf678e61e8e3368014925aed02975179a0be37b91a9cee0226f0fde6e19010163f8e47187726b560ef7bed2a6d7723b9509b135914fe0e51b9e79f

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
6 changes: 3 additions & 3 deletions config/solr.yml.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is a sample config file that points to a solr server for each environment
development:
url: http://127.0.0.1:<%= ENV['SOLR_TEST_PORT'] || 8983 %>/solr/hydra-development
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_DEVELOPMENT_PORT', 8983)}/solr/hydra-development" %>
test:
url: http://127.0.0.1:<%= ENV['SOLR_TEST_PORT'] || 8985 %>/solr/hydra-test
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_TEST_PORT', 8985)}/solr/hydra-test" %>
production:
url: http://your.production.server:8080/bl_solr/core0
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/nurax" %>
Loading
Loading