Skip to content

Commit

Permalink
Feature: Update docker compose to add ncbo cron (#80)
Browse files Browse the repository at this point in the history
* update config.rb sample with the new SOLR configuration values

* add ncbo_cron service to the API docker compose file and sync the volumes beetween the two
  • Loading branch information
syphax-bouazzouni committed Jun 8, 2024
1 parent 3cc0045 commit 15a90e6
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 36 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN bundle install

COPY . /srv/ontoportal/ontologies_api
RUN cp /srv/ontoportal/ontologies_api/config/environments/config.rb.sample /srv/ontoportal/ontologies_api/config/environments/development.rb
RUN cp /srv/ontoportal/ontologies_api/config/environments/config.rb.sample /srv/ontoportal/ontologies_api/config/environments/production.rb

EXPOSE 9393
CMD ["bundle", "exec", "rackup", "-p", "9393", "--host", "0.0.0.0"]
4 changes: 2 additions & 2 deletions config/environments/config.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ REDIS_PORT = ENV.include?("REDIS_PORT") ? ENV["REDIS_PORT"
REPORT_PATH = ENV.include?("REPORT_PATH") ? ENV["REPORT_PATH"] : "./test/ontologies_report.json"
REPOSITORY_FOLDER = ENV.include?("REPOSITORY_FOLDER") ? ENV["REPOSITORY_FOLDER"] : "./test/data/ontology_files/repo"
REST_URL_PREFIX = ENV.include?("REST_URL_PREFIX") ? ENV["REST_URL_PREFIX"] : ENV["API_URL"] || "http://localhost:9393"
SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8983/solr/prop_search_core1"
SOLR_TERM_SEARCH_URL = ENV.include?("SOLR_TERM_SEARCH_URL") ? ENV["SOLR_TERM_SEARCH_URL"] : "http://localhost:8983/solr/term_search_core1"
SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8983/solr"
SOLR_TERM_SEARCH_URL = ENV.include?("SOLR_TERM_SEARCH_URL") ? ENV["SOLR_TERM_SEARCH_URL"] : "http://localhost:8983/solr"

begin
# For prefLabel extract main_lang first, or anything if no main found.
Expand Down
32 changes: 27 additions & 5 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
application = 'ontologies_api'
app_path = "/srv/ontoportal/#{application}"
working_directory "#{app_path}/current/"
current_version_path = "#{app_path}/current"
pid_file_path = 'tmp/pids/unicorn.pid'

if Dir.exists?(current_version_path)
app_socket_path = app_path + '/shared/tmp/sockets/unicorn.sock'
app_gemfile_path = "#{current_version_path}/Gemfile"
user = 'ontoportal'
else
current_version_path = app_path
app_gemfile_path = "#{app_path}/Gemfile"
app_socket_path = app_path + '/tmp/sockets/unicorn.sock'
user = 'root'
end

working_directory current_version_path
worker_processes 8
timeout 300
preload_app true
user 'ontoportal', 'ontoportal'
user user, user

stderr_path 'log/unicorn.stderr.log'
stdout_path 'log/unicorn.stdout.log'
pid 'tmp/pids/unicorn.pid'


require 'fileutils'
[pid_file_path, app_socket_path].each do |file_path|
directory_path = File.dirname(file_path)
FileUtils.mkdir_p(directory_path) unless Dir.exist?(File.dirname(file_path))
end



pid pid_file_path
# Listen on both fast-failing unix data socket (for nginx) & a backloggable TCP connection
listen app_path + '/shared/tmp/sockets/unicorn.sock', :backlog => 1024
listen app_socket_path, :backlog => 1024
#listen 8087, :backlog => 256

# Make sure unicorn is using current gems after rolling restarts
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile"
ENV['BUNDLE_GEMFILE'] = app_gemfile_path
end

before_fork do |server, worker|
Expand Down
100 changes: 71 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
x-app: &app
image: agroportal/ontologies_api:development
image: agroportal/ontologies_api:master
environment: &env
# default bundle config resolves to /usr/local/bundle/config inside of the container
# we are setting it to local app directory if we need to use 'bundle config local'
BUNDLE_APP_CONFIG: /srv/ontoportal/ontologies_api/.bundle
BUNDLE_PATH: /srv/ontoportal/bundle
COVERAGE: 'true' # enable simplecov code coverage
REDIS_HOST: redis-ut
REDIS_PORT: 6379
SOLR_TERM_SEARCH_URL: http://solr-ut:8983/solr
SOLR_PROP_SEARCH_URL: http://solr-ut:8983/solr
GOO_BACKEND_NAME: 4store
GOO_PORT: 9000
GOO_HOST: 4store-ut
MGREP_HOST: mgrep-ut
MGREP_PORT: 55555
REPOSITORY_FOLDER: /srv/ontoportal/data/repository
REPORT_PATH: /srv/ontoportal/data/reports/ontologies_report.json
MGREP_DICTIONARY_FILE: /srv/ontoportal/data/mgrep
stdin_open: true
tty: true
command: /bin/bash
volumes:
# bundle volume for hosting gems installed by bundle; it speeds up gem install in local development
- bundle:/srv/ontoportal/bundle
- .:/srv/ontoportal/ontologies_api
# mount directory containing development version of the gems if you need to use 'bundle config local'
#- /Users/alexskr/ontoportal:/Users/alexskr/ontoportal
depends_on: &depends_on
solr-prop-ut:
condition: service_healthy
solr-term-ut:
condition: service_healthy
redis-ut:
condition: service_healthy



services:
api:
Expand All @@ -34,21 +30,55 @@ services:
.env
environment:
<<: *env
GOO_BACKEND_NAME: 4store
GOO_PORT: 9000
GOO_HOST: 4store-ut
GOO_PATH_QUERY: /sparql/
GOO_PATH_DATA: /data/
GOO_PATH_UPDATE: /update/
BUNDLE_APP_CONFIG: /srv/ontoportal/ontologies_api/.bundle
profiles:
- 4store
depends_on:
- solr-ut
- redis-ut
- mgrep-ut
- 4store-ut
solr-ut:
condition: service_healthy
redis-ut:
condition: service_healthy
mgrep-ut:
condition: service_started
4store-ut:
condition: service_started
ncbo_cron:
condition: service_started
ports:
- "9393:9393"
volumes:
# bundle volume for hosting gems installed by bundle; it speeds up gem install in local development
- app_api:/srv/ontoportal/ontologies_api
- repository:/srv/ontoportal/data/repository

ncbo_cron:
<<: *app
image: agroportal/ncbo_cron:master
env_file:
.env
environment:
<<: *env
BUNDLE_APP_CONFIG: /srv/ontoportal/ncbo_cron/.bundle
command: "bundle exec bin/ncbo_cron"
profiles:
- 4store
volumes:
- app_cron:/srv/ontoportal/ncbo_cron
- repository:/srv/ontoportal/data/repository
- history:/usr/local/hist
- reports:/srv/ontoportal/data/reports
- mgrep:/srv/ontoportal/data/mgrep
- logs:/srv/ontoportal/ncbo_cron/logs
depends_on:
solr-ut:
condition: service_healthy
redis-ut:
condition: service_healthy
mgrep-ut:
condition: service_started
4store-ut:
condition: service_started


mgrep-ut:
image: ontoportal/mgrep-ncbo:0.1
Expand Down Expand Up @@ -84,8 +114,14 @@ services:
ports:
- 8983:8983
command: bin/solr start -cloud -f
# volumes:
#- solr_data:/var/solr/data
volumes:
- solr_data:/var/solr/data
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8983/solr/admin/info/system?wt=json" ]
interval: 30s
timeout: 10s
retries: 3

agraph-ut:
image: franzinc/agraph:v8.1.0
platform: linux/amd64
Expand Down Expand Up @@ -152,7 +188,13 @@ services:
- gb

volumes:
bundle:
app_api:
app_cron:
agdata:
4store:
#solr_data:
repository:
solr_data:
reports:
mgrep:
logs:
history:

0 comments on commit 15a90e6

Please sign in to comment.