Skip to content

Commit

Permalink
Add Dockerfile and docker-compose for running tests, issues #256 #195
Browse files Browse the repository at this point in the history
  • Loading branch information
stkenny committed Sep 22, 2023
1 parent 7389610 commit 3965b73
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG RUBY_VERSION=3.2.2

FROM rubylang/ruby:$RUBY_VERSION-dev-jammy

RUN apt update && apt -y install \
imagemagick \
zip \
ghostscript \
libpng-dev \
graphicsmagick \
ffmpeg \
libreoffice \
git \
dcraw \
libyaml-dev

RUN mkdir -p /opt/kakadu/downloads
RUN wget http://kakadusoftware.com/wp-content/uploads/KDU805_Demo_Apps_for_Linux-x86-64_200602.zip -O /opt/kakadu/downloads/kakadu.zip \
&& unzip /opt/kakadu/downloads/kakadu.zip \
&& mv KDU805_Demo_Apps_for_Linux-x86-64_200602 kakadu \
&& cp kakadu/*.so /usr/lib \
&& cp kakadu/* /usr/bin

RUN sed -i 's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml
RUN sed -i 's/decode="dng:decode" command=".*"\/>$/decode="dng:decode" command="\&quot\;dcraw\&quot\; -c -q 3 -H 5 -w \&quot\;\%i\&quot\; \| \&quot\;convert\&quot\; - \&quot\;\%u\.png\&quot\;"\/>/' /etc/ImageMagick-6/delegates.xml

RUN addgroup --system --gid 1001 app && \
adduser --system --ingroup app --uid 1001 --shell /bin/sh --home /app app

RUN mkdir -p /app/samvera/hydra-derviatives
WORKDIR /app/samvera/hydra-derivatives
COPY ./ /app/samvera/hydra-derivatives
RUN gem install bundler && bundle install --jobs=3 --retry=3
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,32 @@ If you don't want to run the whole suite all at once like CI, do the following:
1. Run the test servers with `rake derivatives:test_server`
2. Run the tests.

## Running tests with Docker

First, make sure you have installed [Docker](https://www.docker.com/).

Within your cloned repository, tell Docker to get started installing your development environment:

```sh
docker compose build
docker compose up
```

This starts containers for:

- Fedora
- Solr

It also builds an image containing all dependencies needed for the tests.

To stop the containers, type <kbd>Ctrl</kbd>+<kbd>c</kbd>. To restart the containers you need only run `docker compose up`.

You can run the full test suite using the following command:

```sh
docker compose run -w /app/samvera/hydra-derivatives test sh -c "bundle exec rspec"
```

# Acknowledgments

This software has been developed by and is brought to you by the Samvera community. Learn more at the
Expand Down
15 changes: 15 additions & 0 deletions config/fedora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
development:
user: fedoraAdmin
password: fedoraAdmin
url: http://<%= ENV['FCREPO_HOST'] || 'localhost' %>:<%= ENV['FCREPO_DEVELOPMENT_PORT'] || ENV['FCREPO_PORT'] || 8984 %>/<%= ENV['FCREPO_REST_PATH'] || 'rest' %>
base_path: <%= ENV['FCREPO_DEV_BASE_PATH'] || ENV['FCREPO_BASE_PATH'] || '/dev' %>
test:
user: fedoraAdmin
password: fedoraAdmin
url: http://<%= ENV['FCREPO_HOST'] || 'localhost' %>:<%= ENV['FCREPO_DEVELOPMENT_PORT'] || ENV['FCREPO_PORT'] || 8986 %>/<%= ENV['FCREPO_REST_PATH'] || 'rest' %>
base_path: <%= ENV['FCREPO_TEST_BASE_PATH'] || ENV['FCREPO_BASE_PATH'] || '/test' %>
production:
user: fedoraAdmin
password: fedoraAdmin
url: http://<%= ENV['FCREPO_HOST'] || 'localhost' %>:<%= ENV['FCREPO_DEVELOPMENT_PORT'] || ENV['FCREPO_PORT'] || 8983 %>/<%= ENV['FCREPO_REST_PATH'] || 'rest' %>
base_path: <%= ENV['FCREPO_BASE_PATH'] || '/prod' %>
7 changes: 7 additions & 0 deletions config/solr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is a sample config file that points to a solr server for each environment
development:
url: <%= ENV['SOLR_DEVELOPMENT_URL'] || ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_DEVELOPMENT_PORT', 8983)}/solr/hydra-development" %>
test:
url: <%= ENV['SOLR_TEST_URL'] || ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_TEST_PORT', 8985)}/solr/hydra-test" %>
production:
url: <%= ENV['SOLR_URL'] || "http://your.production.server:8080/bl_solr/core0" %>
46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '2.2'

volumes:
solr:
fcrepo:

networks:
internal:

services:

solr:
image: solr:8
ports:
- 8985:8983
command:
- bash
- "-c"
- "precreate-core hydra-test /opt/solr/server/configsets/hydra-test; exec solr -f"
volumes:
- .:/app
- ./solr/config:/opt/solr/server/configsets/hydra-test
- solr:/opt/solr/server/solr
networks:
internal:

fcrepo:
image: ghcr.io/samvera/fcrepo4:4.7.5
volumes:
- fcrepo:/data:cached
ports:
- 8986:8080
networks:
internal:

test:
build: .
env_file:
- test.env
volumes:
- .:/app/samvera/hydra-derivatives # Volume mounted
networks:
internal:
depends_on:
- fcrepo
- solr
9 changes: 9 additions & 0 deletions test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FCREPO_HOST=fcrepo
FCREPO_PORT=8080
FCREPO_REST_PATH=rest
FCREPO_TEST_BASE_PATH=/test
SOLR_HOST=solr
SOLR_PORT=8983
SOLR_TEST_URL=http://solr:8983/solr/hydra-test
SOLR_URL=http://solr:8983/solr/
RAILS_ROOT=/app/samvera/hydra-derivatives/spec/support

0 comments on commit 3965b73

Please sign in to comment.