diff --git a/.env.sample b/.env.sample
index 9d4cb5a54b..eabe00bf6a 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,137 +1,7 @@
-# Default values are optimized for production to avoid having to configure
-# much in production.
-#
-# However it should be easy to get going in development too. If you see an
-# uncommented option that means it's either mandatory to set or it's being
-# overwritten in development to make your life easier.
+OP_API_KEY=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb
+OP_API_URL="https://data.bioontology.org"
+STARTER_ONTOLOGY=STY
-# Enable BuildKit by default:
-# https://docs.docker.com/develop/develop-images/build_enhancements
-export DOCKER_BUILDKIT=1
-
-# Rather than use the directory name, let's control the name of the project.
-export COMPOSE_PROJECT_NAME=ontoportal-docker
-
-# In development we want all services to start but in production you don't
-# need the asset watchers to run since assets get built into the image.
-#
-# You can even choose not to run postgres and redis in prod if you plan to use
-# managed cloud services. Everything "just works", even optional depends_on!
-#export COMPOSE_PROFILES=postgres,redis,web,worker,cable
-export COMPOSE_PROFILES=db,cache,assets,web
-
-# If you're running native Linux and your uid:gid isn't 1000:1000 you can set
-# these to match your values before you build your image. You can check what
-# your uid:gid is by running `id` from your terminal.
-#export UID=1000
-#export GID=1000
-
-# You can generate a more secure secret by running: ./run rails secret
-export SECRET_KEY_BASE=insecure_key_for_dev
-
-# Which environment is running? These should be "development" or "production".
-#export RAILS_ENV=production
-#export NODE_ENV=production
-export RAILS_ENV=development
-export NODE_ENV=development
-
-# The bind port for puma.
-#
-# Be warned that if you change this value you'll need to change 8000 in both
-# your Dockerfile and in a few spots in docker-compose.yml due to the nature of
-# how this value can be set (Docker Compose doesn't support nested ENV vars).
-#export PORT=8000
-
-# How many workers and threads should your app use? WEB_CONCURRENCY defaults
-# to the server's CPU count * 2. That is a good starting point. In development
-# it's a good idea to use 1 to avoid race conditions when debugging.
-#export WEB_CONCURRENCY=
-#export RAILS_MAX_THREADS=5
-#export WEB_CONCURRENCY=1
-#export RAILS_MAX_THREADS=1
-
-# You'll always want to set POSTGRES_USER and POSTGRES_PASSWORD since the
-# postgres Docker image uses them for its default database user and password.
-export POSTGRES_USER=hello
-export POSTGRES_PASSWORD=password
-#export POSTGRES_DB=hello
-#export POSTGRES_HOST=postgres
-#export POSTGRES_PORT=5432
-
-# What's your full Redis connection URL? This will be used for caching, Sidekiq,
-# and Action Cable. You can always split them up later.
-#export REDIS_URL=redis://redis:6379/1
-
-# The bind port for puma but for Action Cable.
-#
-# Be warned that if you change this value you'll need to change 28080 in a few
-# spots in docker-compose.yml due to the nature of how this value can be set
-# (Docker Compose doesn't support nested ENV vars).
-#export CABLE_PORT=28080
-
-# The Action Cable address that will be accessible over HTTP. In production
-# you would typically have this reverse proxied to a sub-domain with nginx, in
-# which case you would set something like: ws://cable.example.com
-#
-# This is one case where it defaults to a development value because it's not
-# possible for me to know what domain name you'll be using.
-#export ACTION_CABLE_FRONTEND_URL=ws://localhost:28080
-
-# Comma separated list of RegExp origins to allow connections from for Action
-# Cable. The values will be converted into a proper RegExp, so omit the / /.
-#
-# Examples:
-# http:\/\/localhost*
-# http:\/\/example.*,https:\/\/example.*
-#export ACTION_CABLE_ALLOWED_REQUEST_ORIGINS=http:\/\/localhost*
-
-# If this is set then Rails will serve files from public/ in production. You
-# probably don't want this behavior unless you're testing prod mode locally,
-# because nginx would typically serve static files.
-#export RAILS_SERVE_STATIC_FILES=
-
-# Should Docker restart your containers if they go down in unexpected ways?
-#export DOCKER_RESTART_POLICY=unless-stopped
-export DOCKER_RESTART_POLICY=no
-
-# What health check test command do you want to run? In development, having it
-# curl your web server will result in a lot of log spam, so setting it to
-# /bin/true is an easy way to make the health check do basically nothing.
-#export DOCKER_WEB_HEALTHCHECK_TEST=curl localhost:8000/up
-export DOCKER_WEB_HEALTHCHECK_TEST=/bin/true
-
-# What ip:port should be published back to the Docker host for the app server?
-# If you're using Docker Toolbox or a custom VM you can't use 127.0.0.1. This
-# is being overwritten in dev to be compatible with more dev environments.
-#
-# If you have a port conflict because something else is using 8000 then you
-# can either stop that process or change 8000 to be something else.
-#
-# Use the default in production to avoid having puma directly accessible to
-# the internet since it'll very likely be behind nginx or a load balancer.
-#export DOCKER_WEB_PORT_FORWARD=127.0.0.1:8000
-export DOCKER_WEB_PORT_FORWARD=127.0.0.1:3000
-
-# This is the same as above except for Action Cable.
-#export DOCKER_CABLE_PORT_FORWARD=127.0.0.1:28080
-export DOCKER_CABLE_PORT_FORWARD=28080
-
-# What volume path should be used? In dev we want to volume mount everything
-# so that we can develop our code without rebuilding our Docker images.
-#export DOCKER_WEB_VOLUME=./public:/app/public
-
-
-export DOCKER_WEB_VOLUME=.:/app
-
-# What CPU and memory constraints will be added to your services? When left at
-# 0 they will happily use as much as needed.
-# export DOCKER_POSTGRES_CPUS=0
-# export DOCKER_POSTGRES_MEMORY=0
-# export DOCKER_REDIS_CPUS=0
-# export DOCKER_REDIS_MEMORY=0
-# export DOCKER_WEB_CPUS=0
-# export DOCKER_WEB_MEMORY=0
-# export DOCKER_WORKER_CPUS=0
-# export DOCKER_WORKER_MEMORY=0
-# export DOCKER_CABLE_CPUS=0
-# export DOCKER_CABLE_MEMORY=0
+API_IMAGE_REPOSITORY=agroportal
+API_IMAGE_TAG=stage
+API_URL=http://localhost:9393
\ No newline at end of file
diff --git a/.github/workflows/docker-dev-release.yml b/.github/workflows/docker-dev-release.yml
new file mode 100644
index 0000000000..04db2105d0
--- /dev/null
+++ b/.github/workflows/docker-dev-release.yml
@@ -0,0 +1,45 @@
+name: Docker branch Images build
+
+on:
+ push:
+ branches:
+ - development
+ - stage
+ - test
+
+jobs:
+ push_to_registry:
+ name: Push Docker branch image to Docker Hub
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out the repo
+ uses: actions/checkout@v3
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Log in to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Extract metadata (tags, labels) for Docker
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: agroportal/ontoportal_web_ui
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v4
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ build-args: |
+ RUBY_VERSION=2.7
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
diff --git a/.github/workflows/tests-real-data.yml b/.github/workflows/tests-real-data.yml
new file mode 100644
index 0000000000..d2b410d5bb
--- /dev/null
+++ b/.github/workflows/tests-real-data.yml
@@ -0,0 +1,52 @@
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
+# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
+name: "Run remote API tests CI"
+
+on:
+ push:
+ pull_request_target:
+ types: [ opened, reopened ]
+env:
+ API_URL: ${{ secrets.API_URL }}
+ API_KEY: ${{ secrets.API_KEY }}
+ BIOMIXER_URL: ${{ secrets.BIOMIXER_URL }}
+ FAIRNESS_URL: ${{ secrets.FAIRNESS_URL }}
+ ANNOTATOR_URL: ${{ secrets.ANNOTATOR_URL }}
+ DB_HOST: 127.0.0.1
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ services:
+ mysql:
+ image: mysql:8.0
+ ports:
+ - "3306:3306"
+ env:
+ MYSQL_ROOT_PASSWORD: root
+ memcached:
+ image: memcached:1.6
+ ports:
+ - 11211:11211
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ # Add or replace dependency steps here
+ - name: Install Ruby and gems
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: 2.7.8
+ bundler-cache: true
+ # Add or replace database setup steps here
+ - name: set up config file
+ run: cp config/database.yml.sample config/database.yml
+ - name: Set up database schema
+ run: RAILS_ENV=test bin/rails db:setup
+ - name: Set up yarn
+ run: yarn install
+ # Add or replace test runners here
+ - name: Run tests
+ run: RAILS_ENV=test bin/rails test test/controllers/* -v
\ No newline at end of file
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index ec6dde7e74..9a3d8c9669 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -4,28 +4,30 @@
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
-name: "Ruby on Rails CI"
+name: "Run local API tests CI"
on:
push:
pull_request_target:
types: [ opened, reopened ]
env:
- API_URL: ${{ secrets.API_URL }}
- API_KEY: ${{ secrets.API_KEY }}
+ API_URL: http://localhost:9393
+ REMOTE_API_KEY: 8b5b7825-538d-40e0-9e9e-5ab9274a9aeb
+ REMOTE_API_URL: https://data.bioontology.org
BIOMIXER_URL: ${{ secrets.BIOMIXER_URL }}
FAIRNESS_URL: ${{ secrets.FAIRNESS_URL }}
ANNOTATOR_URL: ${{ secrets.ANNOTATOR_URL }}
+ DB_HOST: 127.0.0.1
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
- image: mysql:latest
+ image: mysql:8.0
ports:
- "3306:3306"
env:
- MYSQL_ROOT_PASSWORD: 'bp_user'
+ MYSQL_ROOT_PASSWORD: root
memcached:
image: memcached:1.6
ports:
@@ -39,6 +41,10 @@ jobs:
with:
ruby-version: 2.7.8
bundler-cache: true
+
+ - name: Run OntoPortal API
+ run: bin/run_api -k ${{ env.REMOTE_API_KEY }} -r agroportal -t stage -s STY -u ${{ env.REMOTE_API_URL }}
+
# Add or replace database setup steps here
- name: set up config file
run: cp config/database.yml.sample config/database.yml
@@ -48,4 +54,4 @@ jobs:
run: yarn install
# Add or replace test runners here
- name: Run tests
- run: RAILS_ENV=test bin/rails test -v
\ No newline at end of file
+ run: RAILS_ENV=test bin/rails test -v
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 88f019fdb5..1f496852bc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,50 +1,55 @@
-FROM ruby:2.7.5-alpine AS app
-
+# Make sure it matches the Ruby version in .ruby-version and Gemfile
+ARG RUBY_VERSION=3.2.0
+FROM ruby:${RUBY_VERSION}-alpine
+
+# Install libvips for Active Storage preview support
+RUN apk add --no-cache build-base \
+ libxml2-dev \
+ libxslt-dev \
+ mariadb-dev \
+ git \
+ tzdata \
+ nodejs yarn \
+ less \
+ bash \
+ docker \
+ docker-compose \
+ && mkdir /node_modules
+
+# Rails app lives here
WORKDIR /app
-ARG UID=1000
-ARG GID=1000
-
-RUN apk add --no-cache \
- build-base \
- libxml2-dev \
- libxslt-dev \
- mariadb-dev \
- git \
- nodejs \
- tzdata \
- yarn \
- less \
- && addgroup --gid ${GID} ruby \
- && adduser -u ${UID} -G ruby -D ruby \
- && chown ruby:ruby -R /app \
- && mkdir /node_modules \
- && chown ruby:ruby -R /node_modules /app
-
-USER ruby
-
-COPY --chown=ruby:ruby bin/ ./bin
-RUN chmod 0755 bin/*
-
+# Set production environment
ARG RAILS_ENV="production"
+ARG BUNDLE_WITHOUT="development test"
-ENV RAILS_ENV="${RAILS_ENV}" \
- NODE_ENV="${NODE_ENV}" \
- PATH="${PATH}:/home/ruby/.local/bin:/node_modules/.bin" \
- USER="ruby" \
- BUNDLE_PATH=/usr/local/bundle
-
-COPY --chown=ruby:ruby Gemfile* ./
-RUN bundle install --jobs "$(nproc)"
-RUN gem install rails
+ENV RAILS_LOG_TO_STDOUT="1" \
+ RAILS_SERVE_STATIC_FILES="true" \
+ RAILS_ENV="${RAILS_ENV}" \
+ BUNDLE_PATH=/usr/local/bundle \
+ BUNDLE_WITHOUT="${BUNDLE_WITHOUT}"
+RUN gem update --system && \
+ gem install bundler
+COPY Gemfile* .
+RUN bundle install
RUN echo "--modules-folder /node_modules" > .yarnrc
-COPY --chown=ruby:ruby package.json *yarn* ./
+COPY package.json *yarn* ./
RUN yarn install
+COPY . .
+
+# Precompile bootsnap code for faster boot times
+RUN bundle exec bootsnap precompile --gemfile app/ lib/
+
+# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
+COPY ./config/database.yml.sample ./config/database.yml
+RUN SECRET_KEY_BASE_DUMMY=1 RAILS_ENV=test bundle exec rails assets:precompile
+
+ENV BINDING="0.0.0.0"
EXPOSE 3000
-CMD ["sh"]
\ No newline at end of file
+CMD ["bash"]
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index fd3d45f4bb..64968c1a5a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -57,7 +57,7 @@ gem 'i18n'
gem 'rails-i18n', '~> 7.0.0'
gem 'iconv'
gem 'multi_json'
-gem 'mysql2', '0.5.3'
+gem 'mysql2'
gem 'oj'
gem 'open_uri_redirections'
gem 'pry'
diff --git a/Gemfile.lock b/Gemfile.lock
index f7c16a9bc6..fa8c7a40a9 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -90,6 +90,7 @@ GEM
ast (2.4.2)
autoprefixer-rails (10.4.15.0)
execjs (~> 2)
+ base64 (0.2.0)
bcrypt_pbkdf (1.1.0)
better_html (2.0.2)
actionview (>= 6.0)
@@ -100,7 +101,7 @@ GEM
smart_properties
bindata (2.4.15)
bindex (0.8.1)
- bootsnap (1.16.0)
+ bootsnap (1.17.0)
msgpack (~> 1.2)
bootstrap (4.2.1)
autoprefixer-rails (>= 9.1.0)
@@ -143,7 +144,7 @@ GEM
cube-ruby (0.0.3)
daemons (1.4.1)
dalli (3.2.6)
- date (3.3.3)
+ date (3.3.4)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
@@ -174,7 +175,7 @@ GEM
flamegraph (0.9.5)
globalid (1.2.1)
activesupport (>= 6.1)
- graphql (2.1.3)
+ graphql (2.1.6)
racc (~> 1.4)
graphql-client (0.18.0)
activesupport (>= 3.0)
@@ -208,14 +209,15 @@ GEM
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
iconv (1.0.8)
- importmap-rails (1.2.1)
+ importmap-rails (1.2.3)
actionpack (>= 6.0.0)
+ activesupport (>= 6.0.0)
railties (>= 6.0.0)
inline_svg (1.9.0)
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.6.0)
- irb (1.8.3)
+ irb (1.9.0)
rdoc
reline (>= 0.3.8)
iso-639 (0.3.6)
@@ -273,18 +275,18 @@ GEM
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.3.0)
- mysql2 (0.5.3)
+ mysql2 (0.5.5)
net-ftp (0.2.0)
net-protocol
time
- net-http (0.3.2)
+ net-http (0.4.0)
uri
- net-imap (0.4.1)
+ net-imap (0.4.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
- net-protocol (0.2.1)
+ net-protocol (0.2.2)
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
@@ -292,7 +294,8 @@ GEM
net-protocol
net-ssh (7.2.0)
netrc (0.11.0)
- newrelic_rpm (9.5.0)
+ newrelic_rpm (9.6.0)
+ base64
nio4r (2.5.9)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
@@ -390,7 +393,7 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
- rake (13.0.6)
+ rake (13.1.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
@@ -489,9 +492,9 @@ GEM
rack (>= 1, < 3)
thor (1.2.2)
tilt (2.3.0)
- time (0.2.2)
+ time (0.3.0)
date
- timeout (0.4.0)
+ timeout (0.4.1)
turbo-rails (1.5.0)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
@@ -505,7 +508,7 @@ GEM
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
- unf_ext (0.0.8.2)
+ unf_ext (0.0.9)
unicode-display_width (2.5.0)
uri (0.12.2)
version_gem (1.1.3)
@@ -533,7 +536,6 @@ GEM
zeitwerk (2.6.11)
PLATFORMS
- x86_64-darwin-21
x86_64-darwin-23
x86_64-linux
x86_64-linux-musl
@@ -573,7 +575,7 @@ DEPENDENCIES
listen
lookbook (~> 1.5.5)
multi_json
- mysql2 (= 0.5.3)
+ mysql2
net-ftp (~> 0.2.0)
net-http
newrelic_rpm
diff --git a/README b/README
deleted file mode 100644
index 0d6affddcd..0000000000
--- a/README
+++ /dev/null
@@ -1,182 +0,0 @@
-== Welcome to Rails
-
-Rails is a web-application and persistence framework that includes everything
-needed to create database-backed web-applications according to the
-Model-View-Control pattern of separation. This pattern splits the view (also
-called the presentation) into "dumb" templates that are primarily responsible
-for inserting pre-built data in between HTML tags. The model contains the
-"smart" domain objects (such as Account, Product, Person, Post) that holds all
-the business logic and knows how to persist themselves to a database. The
-controller handles the incoming requests (such as Save New Account, Update
-Product, Show Post) by manipulating the model and directing data to the view.
-
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in
-link:files/vendor/rails/activerecord/README.html.
-
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in
-link:files/vendor/rails/actionpack/README.html.
-
-
-== Getting started
-
-1. At the command prompt, start a new rails application using the rails command
- and your application name. Ex: rails myapp
- (If you've downloaded rails in a complete tgz or zip, this step is already done)
-2. Change directory into myapp and start the web server: script/server (run with --help for options)
-3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
-4. Follow the guidelines to start developing your application
-
-
-== Web Servers
-
-By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
-Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server,
-Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
-that you can always get up and running quickly.
-
-Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is
-suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
-getting up and running with mongrel is as easy as: gem install mongrel.
-More info at: http://mongrel.rubyforge.org
-
-If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
-Mongrel and WEBrick and also suited for production use, but requires additional
-installation and currently only works well on OS X/Unix (Windows users are encouraged
-to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
-http://www.lighttpd.net.
-
-And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
-web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
-for production.
-
-But of course its also possible to run Rails on any platform that supports FCGI.
-Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
-please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
-
-
-== Debugging Rails
-
-Have "tail -f" commands running on the server.log and development.log. Rails will
-automatically display debugging and runtime information to these files. Debugging
-info will also be shown in the browser on requests from 127.0.0.1.
-
-
-== Breakpoints
-
-Breakpoint support is available through the script/breakpointer client. This
-means that you can break out of execution at any point in the code, investigate
-and change the model, AND then resume execution! Example:
-
- class WeblogController < ActionController::Base
- def index
- @posts = Post.find(:all)
- breakpoint "Breaking out from the list"
- end
- end
-
-So the controller will accept the action, run the first line, then present you
-with a IRB prompt in the breakpointer window. Here you can do things like:
-
-Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
-
- >> @posts.inspect
- => "[#nil, \"body\"=>nil, \"id\"=>\"1\"}>,
- #\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
- >> @posts.first.title = "hello from a breakpoint"
- => "hello from a breakpoint"
-
-...and even better is that you can examine how your runtime objects actually work:
-
- >> f = @posts.first
- => #nil, "body"=>nil, "id"=>"1"}>
- >> f.
- Display all 152 possibilities? (y or n)
-
-Finally, when you're ready to resume execution, you press CTRL-D
-
-
-== Console
-
-You can interact with the domain model by starting the console through script/console.
-Here you'll have all parts of the application configured, just like it is when the
-application is running. You can inspect domain models, change values, and save to the
-database. Starting the script without arguments will launch it in the development environment.
-Passing an argument will specify a different environment, like script/console production.
-
-To reload your controllers and models after launching the console run reload!
-
-To reload your controllers and models after launching the console run reload!
-
-
-
-== Description of contents
-
-app
- Holds all the code that's specific to this particular application.
-
-app/controllers
- Holds controllers that should be named like weblogs_controller.rb for
- automated URL mapping. All controllers should descend from ApplicationController
- which itself descends from ActionController::Base.
-
-app/models
- Holds models that should be named like post.rb.
- Most models will descend from ActiveRecord::Base.
-
-app/views
- Holds the template files for the view that should be named like
- weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby
- syntax.
-
-app/views/layouts
- Holds the template files for layouts to be used with views. This models the common
- header/footer method of wrapping views. In your views, define a layout using the
- layout :default and create a file named default.rhtml. Inside default.rhtml,
- call <% yield %> to render the view using this layout.
-
-app/helpers
- Holds view helpers that should be named like weblogs_helper.rb. These are generated
- for you automatically when using script/generate for controllers. Helpers can be used to
- wrap functionality for your views into methods.
-
-config
- Configuration files for the Rails environment, the routing map, the database, and other dependencies.
-
-components
- Self-contained mini-applications that can bundle together controllers, models, and views.
-
-db
- Contains the database schema in schema.rb. db/migrate contains all
- the sequence of Migrations for your schema.
-
-doc
- This directory is where your application documentation will be stored when generated
- using rake doc:app
-
-lib
- Application specific libraries. Basically, any kind of custom code that doesn't
- belong under controllers, models, or helpers. This directory is in the load path.
-
-public
- The directory available for the web server. Contains subdirectories for images, stylesheets,
- and javascripts. Also contains the dispatchers and the default HTML files. This should be
- set as the DOCUMENT_ROOT of your web server.
-
-script
- Helper scripts for automation and generation.
-
-test
- Unit and functional tests along with fixtures. When using the script/generate scripts, template
- test files will be generated for you and placed in this directory.
-
-vendor
- External libraries that the application depends on. Also includes the plugins subdirectory.
- This directory is in the load path.
diff --git a/README.md b/README.md
index 33bdfb9648..2c90688aa3 100644
--- a/README.md
+++ b/README.md
@@ -1,130 +1,24 @@
-bioportal_web_ui
-================
+### Run dev
-A rails application for biological ontologies, see http://bioportal.bioontology.org/
+The first time, run this
-## Todo
-
-### Finir les metadata (grosse prio)
-
-#### Grosses tâches
-
-* Faire en sorte de bien récupèrer quand on a des array de metadata (en ajoutant les champs)
- * Faire une method générique (genre une class) qui permet de facilement distinguer les types de metadata (pas besoin d'ajouter les champs en dur dans le code)
-
-* Passer à bootstrap pour faire le joli layout?
- * Dans un premier temps import bootstrap seulement dans le form?
- * On pourrait faire des col pour ranger les metadata par "dates", "description", "links" dans des panels bootstrap
-
-* Meilleur affichage des metadata :
- * Bouton pour les valeurs qui reviennent tout le temps
-
-#### Plein de petits todo
-
-* Permettre de filtrer les ontos en fct des metadata
-Voir col P : https://docs.google.com/spreadsheets/d/1r1twxJvXdQXrkX0Ocis6YY08nlO5cGneCAQ5F7U_CoA/edit#gid=0
-Surtout dans les pages browse et welcome (voir les trucs en orange). Page Landscape plus tard
-
-Le but c'est d'avoir des résultats visibles
-
-* 3 blocks dans edit submission metadata
- * Origin
- * Toutes les prop qui ont la valeur S (colonne Q de docs.google Review of metadata prop) pour Simple
- * Toutes les prop qui ont la valeur C (colonne Q de docs.google Review of metadata prop) pour Complete
-
-
-**SEPARER License, onto hasSyntax, etc. Des meatdata de base de NCBO**
-
-**Change tout**
-* Premier bloc avec les metadata pas du tout extraites (formats, contact, file upload...)
-* 2eme bloc avec les metadata que le portal utilise: description, documentation...
-* Expliquer que quand on ajoute un fichier les metadata sont updatés avec les metadata contenues dans le fichier (après le bloc des metadata non extraites)a
-
-X Add contact > même type de bouton que Add new Language
-
-Petit ? quand tu le survoles on dit qu'on extrait normalement cette metadata de l'onto à partir de: list des metadata mappings
-Et on note "omv:description + rdfs:comment" quand on prend les valeurs de chaque propriété
-Trouver comment montrer qu'on prend omv:naturalLanguage plusieurs fois si remplis plusieurs fois
-
-Rassembler toutes les dates ensembles (au lieu de simple et complete) dans un même table
-
-X Attention date picker par défaut marche pas sur firefox (utiliser date picker de jQuery, celui used par NCBO)
-
-Mettre des espaces : HASCONTRIBUTOR & cie
-
-Afficher dans l'interface graphique quelle metadata on remplis par défaut (on les met toutes au même endroit ?)
-
-TODO list : mettre un champ text plus gros ? (comme description)
-
-Le but est d'éviter d'avoir un gros listing indigeste de metadata
-
-Exemple :
-Sous description ajouter bouton "voulez-vous ajouter un abstract?"
-Sous release date "voulez-vous ajouter d'autre dates"
-Sous contact "voulez-vous ajouter d'autres peoples" ?
-Sous publisher "voulez-vous ajouter d'autre rôle d'institut etc"
-
-Depiction et logo à côté l'un de l'autre
-
-Generalizes, HASDISJUNCTIONSWITH, et toutes les metadata de relations entre onto: faire en sorte de pouvoir choisir des ontos dans BioPortal (pitit popip)
-
-Dans Default Properties sur le spreadsheet des metadata elles sont groupées
-
-
-* Dans browse: permettre de trier dans l'ordre alphabétique
-* Ajouter des petits drapeaux à côté des naturalLang (dans browse et dans la page de présentation des submissions)
-
-* IncludedInDataCatalog: faudrait avoir des boutons plutôt (voir avec logo, pour les catalogs connus comme ontobee)
-
-* Handling des metadata plus propre et
-
-
-### Fermer les issues
-
-
-
-### Page Welcome
-
-https://github.com/sifrproject/bioportal_web_ui/issues/12
-https://github.com/agroportal/agroportal_web_ui/issues/59
-
-
-Dans links par exemple on peut mettre "need an ontology mapper: yamplusplus.lirmm.fr"
-
-Feed twitter: https://support.twitter.com/articles/20170071
-https://twitter.com/agrohackathon
-
-
-## Resolve problems
-
-* Ca lag beaucoup sur des ontos avec beaucoup de submissions (comme TRANSMAT sur AgroPortal)
-
-* En particulier quand on ajoute une nouvelle submission
-
-* Add New submission bug parfois (avec uploadFile) : faire des tests, s'il faut ça fait un moment que ça plante sans qu'on s'en rende compte (on utilise beaucoup l'URL en ce moment)
-```ruby
-TypeError (no implicit conversion of Symbol into Integer):
- app/controllers/submissions_controller.rb:28:in `[]'
- app/controllers/submissions_controller.rb:28:in `create'
-
-
-# Following line bugs
-if @errors[:error][:uploadFilePath] && @errors[:error][:uploadFilePath].first[:options]
-end
+```bash
+dip provision
```
-## How to
-
-### Add a facet filter for a metadata in browse
-
-In 3 files :
-* app/views/ontologies/browse.html.erb
-* public/browse/app.js
-* app/controllers/ontologies_controller.rb
+```bash
+dip rails s
+```
-## Log to production.log
+### Run test with local API
+```bash
+dip API_URL=http://localhost:9393 test -v
+```
-```ruby
-Rails.logger.warn "Submission params: #{params[:submission]}"
+### Run test with remote API
+> Warning: make sure you run only read tests, and not remove or create data in your remote server
+```bash
+dip API_URL= test -v
```
+
diff --git a/bin/ontoportal b/bin/ontoportal
new file mode 100755
index 0000000000..12ea12914d
--- /dev/null
+++ b/bin/ontoportal
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+docker compose run --rm rails bash -c "bundle check || bundle install" > /dev/null 2>&1
+
+case "$1" in
+ "bundle")
+ echo "Run: $*"
+ docker compose run --rm -it rails bash -c "$*"
+ ;;
+ "dev")
+ echo "Starting development server..."
+ echo "Run: bundle exec rails s -b 0.0.0.0"
+ docker compose run --rm -it --service-ports rails bash -c "bin/rails db:prepare && bundle exec rails s -b 0.0.0.0"
+ ;;
+ "test")
+ echo "Running API..."
+ if ! curl -sSf http://localhost:9393 > /dev/null 2>&1; then
+ if ! bin/run_api; then
+ echo "Error: Failed to run a local API"
+ exit 1
+ fi
+ fi
+
+
+ echo "Running tests..."
+ echo "Run: API_URL=http://localhost:9393 bundle exec rails test -v $*"
+ docker compose run --rm -it test bash -c "RAILS_ENV=test bin/rails db:prepare && API_URL=http://localhost:9393 bundle exec rails test -v $*"
+
+ echo "Stopping API..."
+ bin/stop_api
+
+ ;;
+ *)
+ echo "Usage: $0 {dev|test|bundle}"
+ exit 1
+ ;;
+esac
\ No newline at end of file
diff --git a/bin/run_api b/bin/run_api
new file mode 100755
index 0000000000..e5dcde7474
--- /dev/null
+++ b/bin/run_api
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+if ARGV.include?('-f')
+ system("rm -fr tmp/ontoportal_docker")
+end
+
+unless Dir.exists?("tmp/ontoportal_docker")
+ system("git clone --depth=1 https://github.com/syphax-bouazzouni/ontoportal_docker.git tmp/ontoportal_docker")
+end
+
+env_file_path = File.expand_path('../.env', __dir__)
+
+# Read and parse the .env file
+if File.exist?(env_file_path)
+ File.readlines(env_file_path).each do |line|
+ next unless line.include?('=')
+ key, value = line.strip.split('=', 2)
+ ENV[key] = value
+ end
+end
+Dir.chdir("tmp/ontoportal_docker") do
+ ARGV.delete('-f')
+
+ require 'optparse'
+
+ # Default values
+ options = {
+ api_key: ENV["OP_API_KEY"],
+ image_repository: ENV["API_IMAGE_REPOSITORY"],
+ image_tag: ENV["API_IMAGE_TAG"],
+ starter_ontology: ENV["STARTER_ONTOLOGY"],
+ remote_api_url: ENV["OP_API_URL"]
+ }
+
+ OptionParser.new do |opts|
+ opts.banner = "Usage: run.rb [options]"
+
+ opts.on("-k", "--api-key API_KEY", "API key") do |api_key|
+ options[:api_key] = api_key
+ end
+
+ opts.on("-r", "--image-repository REPOSITORY", "Image repository") do |image_repository|
+ options[:image_repository] = image_repository
+ end
+
+ opts.on("-t", "--image-tag TAG", "Image tag") do |image_tag|
+ options[:image_tag] = image_tag
+ end
+
+ opts.on("-s", "--starter-ontology ONTOLOGY", "Starter ontology") do |starter_ontology|
+ options[:starter_ontology] = starter_ontology
+ end
+
+ opts.on("-u", "--remote-api-url URL", "Remote API URL") do |remote_api_url|
+ options[:remote_api_url] = remote_api_url
+ end
+ end.parse!
+
+
+ unless system("./run -k #{options[:api_key]} -r #{options[:image_repository]} -t #{options[:image_tag]} -s #{options[:starter_ontology]} -u #{options[:remote_api_url]}")
+ exit 1
+ end
+end
diff --git a/bin/stop_api b/bin/stop_api
new file mode 100755
index 0000000000..930fc24dd8
--- /dev/null
+++ b/bin/stop_api
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+# Check if the directory exists
+if [ -d "tmp/ontoportal_docker" ]; then
+ # Check if the container is running
+ if docker ps --filter "name=ontoportal_docker-api" --format "{{.Names}}" | grep -q "ontoportal_docker-api"; then
+ container_names=$(docker ps --filter "name=ontoportal_docker-api" --format "{{.Names}}")
+ docker stop "$container_names"
+ fi
+
+ cd "tmp/ontoportal_docker" && docker compose stop
+fi
+
diff --git a/config/database.yml.sample b/config/database.yml.sample
index 463e3ebea9..6edf6ed312 100644
--- a/config/database.yml.sample
+++ b/config/database.yml.sample
@@ -13,8 +13,8 @@ default: &default
adapter: mysql2
encoding: utf8mb4
username: root
- password: bp_user
- host: 127.0.0.1
+ password: root
+ host: <%= ENV["DB_HOST"] %>
development:
<<: *default
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index af53788f9c..c7c4027c3e 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -1,5 +1,5 @@
Rails.application.config.middleware.use OmniAuth::Builder do
- $OMNIAUTH_PROVIDERS.each do |provider, config|
+ Array($OMNIAUTH_PROVIDERS).each do |provider, config|
provider config[:strategy] || provider, config[:client_id], config[:client_secret], client_options: {}.merge(config[:client_options].to_h)
end
end
\ No newline at end of file
diff --git a/dip.yml b/dip.yml
new file mode 100644
index 0000000000..2dc833925f
--- /dev/null
+++ b/dip.yml
@@ -0,0 +1,47 @@
+version: '7.1'
+
+# Define default environment variables to pass
+# to Docker Compose
+environment:
+ API_URL: ${API_URL}
+
+compose:
+ files:
+ - .docker-compose.yml
+ project_name: ontoportal_web_ui
+
+interaction:
+ # This command spins up a ontologies_api container with the required dependencies (solr, 4store, etc),
+ # and opens a terminal within it.
+ rails:
+ description: Open a Bash shell within a ontologies_api container (with dependencies up)
+ service: rails
+ command: bundle exec rails
+ compose:
+ run_options: [ service-ports, use-aliases ]
+
+
+
+ # Run a Rails container without any dependent services (useful for non-Rails scripts)
+ bash:
+ description: Run an arbitrary script within a container (or open a shell without deps)
+ service: rails
+ command: bash
+ compose_run_options: [no-deps]
+
+ # A shortcut to run Bundler commands
+ bundle:
+ description: Run Bundler commands
+ service: rails
+ command: bundle
+ compose_run_options: [ no-deps ]
+
+ test:
+ description: Open a Bash shell within a ontologies_api container (with dependencies up)
+ service: test
+ command: bundle exec rails test -v
+
+provision:
+ - dip compose down --volumes
+ - dip compose up -d db cache node
+ - dip bash -c bin/setup
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index 38be0278fb..17bc9a7657 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,52 +1,86 @@
x-app: &default-app
+ image: ontoportal_web_ui
build:
- context: "."
- target: "app"
+ context: .
args:
- - "UID=${UID:-1000}"
- - "GID=${GID:-1000}"
- - "RAILS_ENV=${RAILS_ENV:-production}"
- - "NODE_ENV=${NODE_ENV:-production}"
- depends_on:
- - "db"
- - "cache"
- links:
- - "db"
- - "cache"
+ RUBY_VERSION: '2.7.8'
+ RAILS_ENV: 'development'
env_file:
- ".env"
tty: true
volumes:
- - "${DOCKER_WEB_VOLUME}"
- - bundle:/usr/local/bundle
+ - .:/app
+ - bundle:/usr/local/bundle
- node:/node_modules
+ - rails_cache:/app/tmp/cache
+ - assets:/app/public/assets
+ - /var/run/docker.sock:/var/run/docker.sock
+ tmpfs:
+ - /tmp
+ - /app/tmp/pids
services:
db:
- environment:
- MYSQL_ROOT_PASSWORD: 'bp_user'
- image: "mysql:latest"
- profiles: ["db"]
+ image: "mysql:8.0"
+ networks:
+ - default
+ volumes:
+ - mysql-data:/var/lib/mysql
ports:
- "3306:3306"
- volumes:
- - db-v:/var/lib/mysql
+ environment:
+ MYSQL_ROOT_PASSWORD: root
+
cache:
- deploy:
- resources:
- limits:
- cpus: "${DOCKER_REDIS_CPUS:-0}"
- memory: "${DOCKER_REDIS_MEMORY:-0}"
- image: "memcached:1.6.17-bullseye"
- profiles: ["cache"]
+ image: memcached:latest
+ restart: unless-stopped
+ command: [ "-m", "1024" ]
+ networks:
+ - default
+ ports:
+ - "11211:11211"
+ node:
+ <<: *default-app
+ command: "yarn build --watch"
+ tty: true
+ volumes:
+ - .:/app
+ - bundle:/usr/local/bundle
+ - node:/node_modules
+ - rails_cache:/app/tmp/cache
+ - assets:/app/public/assets
+ - /var/run/docker.sock:/var/run/docker.sock
- web:
+ rails:
<<: *default-app
+ depends_on:
+ - db
+ - cache
+ - node
+ links:
+ - db
+ - cache
+ environment:
+ BUNDLE_WITHOUT: ''
+ DB_HOST: db
+ CACHE_HOST: cache
ports:
- - "${DOCKER_WEB_PORT_FORWARD:-127.0.0.1:3000}:${PORT:-3000}"
- profiles: ["web"]
- command: "yarn build --watch"
+ - "3000:3000"
+ test:
+ <<: *default-app
+ depends_on:
+ - db
+ - cache
+ network_mode: 'host'
+ environment:
+ BUNDLE_WITHOUT: ''
+ DB_HOST: 127.0.0.1
+ CACHE_HOST: 127.0.0.1
+
+
volumes:
- db-v:
+ mysql-data:
bundle:
+ rails_cache:
+ assets:
node:
diff --git a/test/controllers/ontologies_controller_test.rb b/test/controllers/ontologies_controller_test.rb
index ed96305cae..c7fcdb06c2 100644
--- a/test/controllers/ontologies_controller_test.rb
+++ b/test/controllers/ontologies_controller_test.rb
@@ -11,7 +11,7 @@ class OntologiesControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
- ONTOLOGIES.sample(5).flat_map { |ont| PAGES.map { |page| [ont, page] } }.each do |ont, page|
+ ONTOLOGIES.flat_map { |ont| PAGES.map { |page| [ont, page] } }.each do |ont, page|
test "should get page #{page} of #{ont.acronym} ontology" do
path = "#{ontologies_path}/#{ont.acronym}?p=#{page}"
get path