Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provides docker-compose alternative workflow for Valkyrie development #891

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
docker-compose.yml
.bundle
.circleci
.ctags
.dockerignore
.lando.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.bash_history
/.bundle/
/.yardoc
/Gemfile.lock
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG ruby_version=2.6
FROM ruby:${ruby_version}

SHELL ["/bin/bash", "-c"]

WORKDIR /opt/valkyrie

COPY . .

RUN chmod -R 0777 .

USER 1001:0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines cause me to get a permission error when i try to run

docker-compose exec valkyrie bundle exec rake

and since this isn't a production image i don't think we need to set a non-default user. this change got tests running for me (although i got a number of failures which i haven't looked into yet):

 Dockerfile | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 24cb7f6..d4b44dd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,12 +5,8 @@ SHELL ["/bin/bash", "-c"]

 WORKDIR /opt/valkyrie

-COPY . .
-
-RUN chmod -R 0777 .
+RUN gem install bundler

-USER 1001:0
-
-ENV HOME=/opt/valkyrie
+COPY . .

-RUN gem install bundler && bundle install
+RUN bundle install --jobs "$(nproc)"


ENV HOME=/opt/valkyrie

RUN gem install bundler && bundle install
4 changes: 2 additions & 2 deletions db/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ default: &default
timeout: 5000
host: localhost
username: postgres
password:
password:

development:
<<: *default
database: Valkyrie_gem_development
port: 5433
url: <%= ENV['DATABASE_URL'] %>

test:
<<: *default
Expand Down
7 changes: 7 additions & 0 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

docker-compose up -d

docker-compose exec valkyrie /bin/bash

docker-compose down
83 changes: 83 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
version: '3.8'

services:
valkyrie:
image: valkyrie
build:
context: .
volumes:
- .:/opt/valkyrie
environment:
- SOLR_URL=http://solr:8983/solr/valkyrie-core-test
- DATABASE_URL=postgresql://postgres:valkyrie@db:5432/Valkyrie_gem_development
- DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
- RAILS_ENV=development
- RACK_ENV=development
- FEDORA_4_PORT=8080
- FEDORA_4_HOST=fcrepo4
- FEDORA_5_PORT=8080
- FEDORA_5_HOST=fcrepo5
- FEDORA_6_PORT=8080
- FEDORA_6_HOST=fcrepo6
command:
- sleep
- infinity

solr:
image: solr:7
ports:
- "8994:8983"
volumes:
- ./solr/config:/solr_config
- solr:/opt/solr/server/solr/mycores
entrypoint:
- docker-entrypoint.sh
- solr-precreate
- valkyrie-core-test
- /solr_config

db:
image: postgres:10
volumes:
- pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_DB=Valkyrie_gem_development
- POSTGRES_PASSWORD=valkyrie

fcrepo4:
image: samvera/fcrepo4:4.7.5
command:
- /fedora-entrypoint.sh
volumes:
- fcrepo4:/data
ports:
- "8988:8080"

fcrepo5:
image: samvera/fcrepo4:5.1.0
command:
- /fedora-entrypoint.sh
volumes:
- fcrepo5:/data
ports:
- "8998:8080"

fcrepo6:
image: fcrepo/fcrepo:6.0.0
command:
- "catalina.sh"
- "run"
volumes:
- fcrepo6:/data
ports:
- "8978:8080"
environment:
CATALINA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
JAVA_OPTS: "-Dfcrepo.dynamic.jms.port=61619 -Dfcrepo.dynamic.stomp.port=61615 -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"

volumes:
fcrepo4:
fcrepo5:
fcrepo6:
solr:
pgdata:
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
require 'webmock/rspec'
require 'timecop'

SOLR_TEST_URL = "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8994}/solr/valkyrie-core-test"
SOLR_TEST_URL = ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8994}/solr/valkyrie-core-test"

ROOT_PATH = Pathname.new(Dir.pwd)
Dir[Pathname.new("./").join("spec", "support", "**", "*.rb")].sort.each { |file| require_relative file.gsub(/^spec\//, "") }

WebMock.disable_net_connect!(allow_localhost: true)
# TODO - replace solr and fcrepo hosts with vars
# WebMock.disable_net_connect!(allow: ['localhost', 'solr:8983', 'fcrepo4:8080', 'fcrepo5:8080', 'fcrepo6:8080'])
WebMock.allow_net_connect!

RSpec.configure do |config|
config.order = :random
Expand Down
17 changes: 12 additions & 5 deletions spec/support/fedora_helper.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# frozen_string_literal: true
module FedoraHelper
def fedora_adapter_config(base_path:, schema: nil, fedora_version: 4)
port = 8988
if fedora_version == 5
port = 8998
elsif fedora_version == 6
host = 'localhost'

case fedora_version
when 4
port = ENV["FEDORA_4_PORT"] || 8988
host = ENV["FEDORA_4_HOST"] if ENV["FEDORA_4_HOST"].present?
when 5
port = ENV["FEDORA_5_PORT"] || 8998
host = ENV["FEDORA_5_HOST"] if ENV["FEDORA_5_HOST"].present?
when 6
port = ENV["FEDORA_6_PORT"] || 8978
host = ENV["FEDORA_6_HOST"] if ENV["FEDORA_6_HOST"].present?
end
connection_url = fedora_version == 6 ? "/fcrepo/rest" : "/rest"
opts = {
base_path: base_path,
connection: ::Ldp::Client.new(faraday_client("http://#{fedora_auth}localhost:#{port}#{connection_url}")),
connection: ::Ldp::Client.new(faraday_client("http://#{fedora_auth}#{host}:#{port}#{connection_url}")),
fedora_version: fedora_version
}
opts[:schema] = schema if schema
Expand Down
4 changes: 2 additions & 2 deletions spec/valkyrie/persistence/solr/persister_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ class MyLockingResource < Valkyrie::Resource

context "when solr does not return a response" do
before do
WebMock.disable_net_connect!
# WebMock.disable_net_connect!
stub_request(:post, "#{SOLR_TEST_URL}/update?softCommit=true&versions=true&wt=json").to_raise(RSolr::Error::Http.new(nil, nil))
end
after do
WebMock.disable_net_connect!(allow_localhost: true)
# WebMock.disable_net_connect!(allow_localhost: true)
end
it "passes the exception through" do
resource = MyLockingResource.new(title: ["My Locked Resource"])
Expand Down