Skip to content

Commit

Permalink
Update docker compose and startup scripts so that web and sidekiq don…
Browse files Browse the repository at this point in the history
…'t share gems anymore (symlinking didn't work across containers), get solr working again
  • Loading branch information
bbpennel committed Oct 11, 2024
1 parent 19da0d7 commit a1e46ae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 39 deletions.
21 changes: 6 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,20 +95,22 @@ 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:
- hycdev
volumes:
mount-code:
mount-gems:
mount-sidekiq-gems:
solr8-data:
clam:
pg_data:
Expand Down Expand Up @@ -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'
19 changes: 13 additions & 6 deletions docker/start-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 13 additions & 18 deletions docker/start-sidekiq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit a1e46ae

Please sign in to comment.