Skip to content

Commit

Permalink
Use Hyrax docker base setup (#1670)
Browse files Browse the repository at this point in the history
* use Hyrax docker base setup

Hyrax now provides a minimal base docker image, intended to be reused and
extended by applications. this is a proposal to replace the existing Dockerfile
with one based on that image.

this would switch the application server to `puma`. our thinking is that real
containerized deployments (e.g. via the Helm chart) are likely to be behind a
load balancer and an `nginx` (an ingress controller).

the image is kept minimal with the idea that a smaller set of system
dependencies means a lower footprint for security risks, besides the bandwidth
and storage convenince. Hyrax's setup definitely has space to improve here, but
the idea is greater consolidation will help the community maintain something
really solid.

there's still a little work to do here:

  - remove dependency on `zk` (and therefore java runtime).
  - refine & use Hyrax's `hyrax-worker` image setup for `sidekiq` workers (using
    a separate lets us consider optimizations like `MALLOC_ARENA_MAX=2`).
  - systematically reconcile environment variables (the job here is a bit
    patchwork).

if this is looking like a good direction, I can work on getting this working
with the upstream helm chart as well.

* add a .dockerignore

ignore unneeded files for image builds.

* remove `zk` dependency and .ebextensions

* remove StandardFilterFactory

this filter factory has been a no-op since Solr 3.1. remove it.

* setup solr configuration in docker-compose environment

use the Hyrax utility scripts to manage solr collection and configset in the
docker-compose dev environment.
  • Loading branch information
tamsin johnson authored Apr 26, 2021
1 parent 5b97f1d commit 9fb97d6
Show file tree
Hide file tree
Showing 26 changed files with 138 additions and 445 deletions.
33 changes: 25 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,21 @@ jobs:
- image: ualbertalib/docker-fcrepo4:<< parameters.fcrepo_version>>
environment:
CATALINA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
- image: solr:7-alpine
command: bin/solr -cloud -noprompt -f -p <<parameters.solr_port>>
- image: bitnami/solr:8
environment:
SOLR_PORT_NUMBER: 8985
SOLR_CLOUD_BOOTSTRAP: "yes"
SOLR_ENABLE_CLOUD_MODE: "yes"
SOLR_ENABLE_AUTHENTICATION: "yes"
SOLR_COLLECTION: hydra-test
SOLR_ADMIN_USERNAME: admin
SOLR_ADMIN_PASSWORD: admin
SOLR_ZK_HOSTS: localhost
- image: bitnami/zookeeper
environment:
ALLOW_ANONYMOUS_LOGIN: "yes"
JVMFLAGS: -Dzookeeper.4lw.commands.whitelist=ruok -Dzookeeper.admin.enableServer=false
ZOO_SERVERS: zoo1:2888:3888
- image: circleci/redis:<<parameters.redis_version>>
- image: circleci/postgres:9.6.2-alpine
parallelism: 4
Expand All @@ -44,23 +57,27 @@ jobs:
COVERALLS_PARALLEL: true
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
SOLR_ADMIN_USER: admin
SOLR_ADMIN_PASSWORD: admin
SOLR_COLLECTION_NAME: hydra-test
SOLR_CONFIGSET_NAME: hyku
SOLR_HOST: localhost
SOLR_PORT: 8985
SOLR_URL: http://admin:admin@localhost:8985/solr/
SETTINGS__SOLR__URL: http://admin:admin@localhost:8985/solr/
RAILS_ENV: test
RACK_ENV: test
FCREPO_TEST_PORT: 8080/fcrepo
SPEC_OPTS: --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
# CFLAGS need to be set for zookeeper to compile native extensions
CFLAGS: -Wno-error=format-overflow
steps:
- samvera/cached_checkout

- samvera/bundle:
ruby_version: << parameters.ruby_version >>
bundler_version: << parameters.bundler_version >>

- samvera/install_solr_core:
solr_config_path: << parameters.solr_config_path >>
- samvera/rubocop
- run: bundle exec rake db:create db:schema:load zookeeper:upload
- run: bundle exec rake db:create db:schema:load
- run: bin/solrcloud-upload-configset.sh solr/config
- samvera/parallel_rspec
- store_artifacts:
path: coverage
Expand Down
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.git
./tmp
./log
.internal_test_app/*

*.rdb

tmp/*
artifacts/*
coverage/*
chart/*
9 changes: 0 additions & 9 deletions .ebextensions/fits.config

This file was deleted.

14 changes: 0 additions & 14 deletions .ebextensions/honeybadger.config

This file was deleted.

25 changes: 0 additions & 25 deletions .ebextensions/install.config

This file was deleted.

7 changes: 0 additions & 7 deletions .ebextensions/java8.config

This file was deleted.

14 changes: 0 additions & 14 deletions .ebextensions/libreoffice.config

This file was deleted.

133 changes: 0 additions & 133 deletions .ebextensions/logzio.config

This file was deleted.

18 changes: 0 additions & 18 deletions .ebextensions/nginx.config

This file was deleted.

9 changes: 0 additions & 9 deletions .ebextensions/packages.config

This file was deleted.

27 changes: 12 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
FROM hyku/base:latest

ADD https://time.is/just build-time
COPY ops/nginx.sh /etc/service/nginx/run
COPY ops/webapp.conf /etc/nginx/sites-enabled/webapp.conf
COPY ops/env.conf /etc/nginx/main.d/env.conf

COPY --chown=app . $APP_HOME

RUN /sbin/setuser app bash -l -c "set -x && \
(bundle check || bundle install) && \
bundle exec rake assets:precompile DB_ADAPTER=nulldb && \
mv ./public/assets ./public/assets-new"

CMD ["/sbin/my_init"]
ARG HYRAX_IMAGE_VERSION=3.0.1
FROM ghcr.io/samvera/hyrax/hyrax-base:$HYRAX_IMAGE_VERSION as hyku

USER root
RUN apk --no-cache upgrade && \
apk --no-cache add libxml2-dev \
openjdk11-jre
USER app

COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
RUN bundle install --jobs "$(nproc)"
RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile
49 changes: 0 additions & 49 deletions Dockerfile.base

This file was deleted.

2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ gem 'rolify'
gem 'flipflop', '~> 2.3'
gem 'lograge'

gem 'zk'

gem 'mods', '~> 2.4'

group :aws, :test do
Expand Down
Loading

0 comments on commit 9fb97d6

Please sign in to comment.