From a1e46ae494408a49d5d4f5eba24b7b316af6f12e Mon Sep 17 00:00:00 2001 From: Ben Pennell Date: Fri, 11 Oct 2024 16:25:29 -0400 Subject: [PATCH] Update docker compose and startup scripts so that web and sidekiq don't share gems anymore (symlinking didn't work across containers), get solr working again --- docker-compose.yml | 21 ++++++--------------- docker/start-app.sh | 19 +++++++++++++------ docker/start-sidekiq.sh | 31 +++++++++++++------------------ 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 445327a6a..c8bbf1142 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,7 +42,7 @@ services: - docker/.env volumes: - mount-code:/hyrax - - mount-gems:/hyc-gems + - mount-sidekiq-gems:/hyc-gems - fcrepo_data:/opt/fedora/ - hyrax_data:/opt/hyrax - ftp_data:/opt/data/ftp @@ -95,13 +95,14 @@ services: solr8: image: solr:8.11-slim volumes: - - solr8-data:/opt/solr/server/solr/configsets/hy-c + - ./solr/config:/opt/solr/server/solr/configsets/hy-c + - solr8-data:/var/solr/data ports: - "8983:8983" command: > bash -c " - precreate-core hydra-development /opt/solr/server/solr/configsets/hy-c; - precreate-core hydra-test /opt/solr/server/solr/configsets/hy-c; + precreate-core hydra-development /opt/solr/server/solr/configsets/hy-c && + precreate-core hydra-test /opt/solr/server/solr/configsets/hy-c && exec solr -f " networks: @@ -109,6 +110,7 @@ services: volumes: mount-code: mount-gems: + mount-sidekiq-gems: solr8-data: clam: pg_data: @@ -138,14 +140,3 @@ x-mutagen: permissions: defaultFileMode: 0644 defaultDirectoryMode: 0755 - #mount-gems: - #alpha: '../hyc-gems' - #beta: "volume://mount-gems" - # TODO: can we move these to simple volumes by auto-copying the configs over? - solr8-data: - alpha: './solr/config' - beta: 'volume://solr8-data' - configurationBeta: - permissions: - defaultOwner: 'id:8983' - defaultGroup: 'id:8983' diff --git a/docker/start-app.sh b/docker/start-app.sh index a79054784..45134b62a 100644 --- a/docker/start-app.sh +++ b/docker/start-app.sh @@ -5,16 +5,23 @@ source scl_source enable devtoolset-8 mkdir -p /opt/hyrax/log/ echo "#### Ensure rubygems system is up to date before bundle installing" -# gem install rubygems-update -# update_rubygems >> /dev/null - -echo "#### Bundle install" -bundle check || bundle install +gem install rubygems-update -v 3.4.20 +update_rubygems >> /dev/null echo "#### Performing config steps" # The bundle config and package are needed for the odd way we manage gems in production bundle config --local cache_path /hyc-gems -bundle package + +if ! bundle check; then + echo "#### Bundle install required" + bundle install + bundle package + echo "#### Creating symlink for libsass otherwise bundle cannot find it" + [ ! -L /opt/rh/rh-ruby30/root/usr/share/gems/gems/sassc-2.4.0/ext/libsass.so ] && ln -s /opt/rh/rh-ruby30/root/usr/lib64/gems/ruby/sassc-2.4.0/sassc/libsass.so /opt/rh/rh-ruby30/root/usr/share/gems/gems/sassc-2.4.0/ext/libsass.so +else + echo "#### Gems already installed, skipping bundle install" +fi + find . -name *.pid -delete bundle exec rake tmp:cache:clear bundle exec rake db:create && bundle exec rake db:migrate diff --git a/docker/start-sidekiq.sh b/docker/start-sidekiq.sh index b8bb5b2d9..3f3c41528 100644 --- a/docker/start-sidekiq.sh +++ b/docker/start-sidekiq.sh @@ -3,27 +3,22 @@ echo "#### Running start-sidekiq.sh" source scl_source enable rh-ruby30 source scl_source enable devtoolset-8 -# Wait for the web container, so that it can handle installation of bundle gems for both -echo "#### Waiting for web application to become available" -ATTEMPT_COUNTER=0 -MAX_ATTEMPTS=100 -SERVICE_URL=http://web:3000/ - -until $(curl --output /dev/null --silent --head --fail $SERVICE_URL); do - if [ ${ATTEMPT_COUNTER} -eq ${MAX_ATTEMPTS} ];then - echo "Max attempts to connect to web application reached, cannot start sidekiq" - exit 1 - fi - - printf '.' - ATTEMPT_COUNTER=$(($ATTEMPT_COUNTER+1)) - sleep 5 -done - echo "#### Ensure rubygems system is up to date before bundle installing" gem install rubygems-update -v 3.4.20 update_rubygems >> /dev/null +bundle config --local cache_path /hyc-gems + +if ! bundle check; then + echo "#### Bundle install required" + bundle install + bundle package + echo "#### Creating symlink for libsass otherwise bundle cannot find it" + [ ! -L /opt/rh/rh-ruby30/root/usr/share/gems/gems/sassc-2.4.0/ext/libsass.so ] && ln -s /opt/rh/rh-ruby30/root/usr/lib64/gems/ruby/sassc-2.4.0/sassc/libsass.so /opt/rh/rh-ruby30/root/usr/share/gems/gems/sassc-2.4.0/ext/libsass.so +else + echo "#### Gems already installed, skipping bundle install" +fi + echo "#### Starting sidekiq" -bundle && bundle exec sidekiq +bundle exec sidekiq echo "#### Shutdown sidekiq" \ No newline at end of file