From a3a60ea3ae355d6a39fda1f07f3d79644ddd2a41 Mon Sep 17 00:00:00 2001 From: Max Magorsch Date: Thu, 5 Sep 2019 16:12:58 +0200 Subject: Run the initialization scripts using docker-compose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docker-compose can be used to deploy the application. The index will be initialized and updated. Furthermore a cron job will be registered for production environments to update the index every 10 minutes. ° Signed-off-by: Max Magorsch --- bin/first-run | 22 ++++++++++++++++------ bin/update-all.sh | 6 +++++- bin/update-changelogs.sh | 2 ++ bin/update-md5.sh | 2 ++ bin/update-use.sh | 2 ++ docker-compose.override.yml | 5 +---- docker-compose.yml | 2 +- 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/bin/first-run b/bin/first-run index dd06ce2..63130ed 100755 --- a/bin/first-run +++ b/bin/first-run @@ -1,8 +1,18 @@ #!/bin/bash -bundle install --deployment -bundle exec rake tmp:create -bundle exec rake assets:precompile -bundle exec rake kkuleomi:index:init -bundle exec rake kkuleomi:seed:all -./update-all.sh +# Wait for Elasticsearch to start up +sleep 30 + +bundler install +bundle exec rake tmp:create RAILS_ENV=${1:-development} +bundle exec rake assets:precompile RAILS_ENV=${1:-development} +bundle exec rake kkuleomi:index:init RAILS_ENV=${1:-development} +./bin/update-all.sh ${1:-development} + +if [[ "${1:-development}" == "production" ]] +then + crontab -l | { cat; echo "*/10 * * * * /var/www/packages.gentoo.org/htdocs/bin/update-all.sh ${1:-development}"; } | crontab - +fi + +# Finally start the http server when the index is initialized +bundle exec thin start -p 5000 \ No newline at end of file diff --git a/bin/update-all.sh b/bin/update-all.sh index efa9955..82f8751 100755 --- a/bin/update-all.sh +++ b/bin/update-all.sh @@ -1,3 +1,7 @@ +#!/bin/bash + +emerge --sync + if [[ ! -d /mnt/packages-tree/gentoo/ ]]; then cd /mnt/packages-tree || exit 1 git clone https://anongit.gentoo.org/git/repo/gentoo.git @@ -10,4 +14,4 @@ fi /var/www/packages.gentoo.org/htdocs/bin/update-use.sh cd /var/www/packages.gentoo.org/htdocs || exit 1 -bundle exec rake kkuleomi:update:all RAILS_ENV=production &>/dev/null +bundle exec rake kkuleomi:update:all RAILS_ENV=${1:-development} &>/dev/null diff --git a/bin/update-changelogs.sh b/bin/update-changelogs.sh index ae64050..0b35989 100755 --- a/bin/update-changelogs.sh +++ b/bin/update-changelogs.sh @@ -1,5 +1,7 @@ #!/bin/bash +mkdir -p /var/cache/pgo-egencache + cd /mnt/packages-tree/gentoo/ || exit 1 egencache -j 6 --cache-dir /var/cache/pgo-egencache --repo gentoo --repositories-configuration '[gentoo] location = /mnt/packages-tree/gentoo' --update-changelogs diff --git a/bin/update-md5.sh b/bin/update-md5.sh index 05eca90..10c7d75 100755 --- a/bin/update-md5.sh +++ b/bin/update-md5.sh @@ -1,5 +1,7 @@ #!/bin/bash +mkdir -p /var/cache/pgo-egencache + cd /mnt/packages-tree/gentoo/ || exit 1 egencache -j 6 --cache-dir /var/cache/pgo-egencache --repo gentoo --repositories-configuration '[gentoo] location = /mnt/packages-tree/gentoo' --update diff --git a/bin/update-use.sh b/bin/update-use.sh index 7f32af2..33bacfb 100755 --- a/bin/update-use.sh +++ b/bin/update-use.sh @@ -1,5 +1,7 @@ #!/bin/bash +mkdir -p /var/cache/pgo-egencache + cd /mnt/packages-tree/gentoo/ || exit 1 egencache -j 6 --cache-dir /var/cache/pgo-egencache --repo gentoo --repositories-configuration '[gentoo] location = /mnt/packages-tree/gentoo' --update-use-local-desc diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 1c609af..3091f61 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -44,10 +44,7 @@ services: depends_on: - redis - elasticsearch - command: > - bash -c " bundler install - && bundle exec rake assets:precompile - && bundle exec thin start -p 5000" + command: bash -c "/var/www/packages.gentoo.org/htdocs/bin/first-run development" sidekiq: build: . volumes: diff --git a/docker-compose.yml b/docker-compose.yml index 719dc2e..59eb9d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,7 +40,7 @@ services: depends_on: - redis - elasticsearch - command: bundle exec thin start -p 5000 + command: bash -c "/var/www/packages.gentoo.org/htdocs/bin/first-run production" sidekiq: build: . volumes: -- cgit v1.2.3-65-gdbad