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

Add Docker Development Environment #129

Merged
merged 2 commits into from
Oct 23, 2017
Merged
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
53 changes: 53 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ------------------------------
# Path configuration
# ------------------------------


# ------------------------------
# Redis configuration
# ------------------------------

# Y/N
USE_REDIS=N

# Uncomment and set these if Redis is enabled
# S3_BUCKET=
# S3_BUCKET_FOLDER=
# S3_KEY=
# S3_SECRET=

# ------------------------------
# DB configuration
# ------------------------------

# Generally 'localhost', but use 'postgres' for docker-compose
DB_HOST=postgres

DATABASE_DEV=annotations_dev
DB_USERNAME_DEV=annotations_dev
DB_PASSWORD_DEV=rails

# DATABASE_TEST=
# DB_USERNAME_TEST=
# DB_PASSWORD_TEST=

# DATABASE_PROD=
# DB_USERNAME_PROD=
# DB_PASSWORD_PROD=

# ------------------------------
# IIIF configuration
# ------------------------------
IIIF_COLLECTIONS_HOST=
IIIF_HOST_URL=

# ------------------------------
# Docker-compose configuration
# ------------------------------

# Tells Docker what folder to mount as a volume for the codebase
# Should be the current working directory
# APPLICATION_PATH=

# Set this if using a Docker proxy container
# RAILS_SERVER_HOSTNAME=annotations.local
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ pickle-email-*.html
.rvmrc
.ruby-gemset
.ruby-version

local_env
.env
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ruby:2.2.4

RUN apt-get install gcc imagemagick -y

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install

CMD [""]
73 changes: 42 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
Mirador-Annotations
Purpose: provide a simple IIIF Annotations server which can be used stand-alone, but is designed with pairing with Mirador in mind. It assumes an outside manifest and canvas server, but can be pointed to by a Mirador endpoint and used to store and retrieve annotations.
One main thrust of Mirador-Annotations is to support the IIIF Layers=>Lists=>Annotations structure as an alternate way of organizing annotations. For example, a manuscript can be annotated with transcript, translation and commentary annotations and be organized by those functions along with the standard manifest=>canvas=>annotation_list structure.
# Mirador-Annotations
## Purpose
Provide a simple International Image Interoperability Framework (IIIF) Annotations server. Intended to be paired with Mirador, but can be used as a standalone deployment.

## About
It assumes an outside manifest and canvas server, but can be pointed to by a Mirador endpoint and used to store and retrieve annotations.

One main thrust of Mirador-Annotations is to support the IIIF `Layers=>Lists=>Annotations` structure as an alternate way of organizing annotations. For example, a manuscript can be annotated with transcript, translation, and commentary annotations and be organized by those functions along with the standard `manifest=>canvas=>annotation_list` structure.

See wiki home page for more background and information.

Getting Started:
Mirador-Annotations is basically a standard Ruby on Rails application with the usual deployment steps:
**Installation:**
- git clone
- bundle
- rake db:migrate
1. Clone the repository
2. Run bundle install
3. Rake db:migrate
4. Set env config variables:
- IIIF_HOST_URL
- USE_REDIS
if USE_REDIS is set to 'Y' then set these:
- REDIS_URL
- S3_Bucket
- S3_Bucket_Folder
- S3_Key
- S3_Secret

**Usage:**
- Mirador-Annotations receives new annotations in IIIF format and will save to whichever relational database
is configured. It will also return requested annotations in IIIF format.
- For use with Mirador, the central thought is to allow both standard annotations which are bound to a canvas,
and "targeting" annotations which are bound to another annotation.
- layers should be created manually, and when an canvas-bound annotation is entered it will automatically add to a list defined by layer and canvas
- Custom Method *getAnnotationsForCanvas* is an API call method which will return all annotations which are bound to a given canvas,
along with all annotations which target it either directly or indirectly
(i.e. Annotation 3 targets Annotation 2 which targets standard Annotation 1, which is bound to a canvas)
## Getting Started

### Basic Installation

Mirador-Annotations is a standard Ruby on Rails application with the usual deployment steps:

1. clone the repository
2. `bundle install`
3. `rake db:migrate`
4. Set `.env` config variables

### Developing Via Docker
If you prefer to develop via Docker, define the required variables in the `.env` file, then run the following:

1. `docker-compose up -d`
2. `docker-compose run rails rake db:migrate`

This will get the containers running in a private network. The rails container is exposed and bound to port 3000 on your local machine by default.

For troubleshooting tips on on developing with docker check the wiki.


## Usage Notes
Mirador-Annotations receives new annotations in IIIF format and will save to whichever relational database is configured. It will also return requested annotations in IIIF format.

Allows both standard annotations which are bound to a canvas, and "targeting" annotations which are bound to another annotation.

Layers should be created manually, and when a canvas-bound annotation is entered it will automatically add to a list defined by layer and canvas.

Custom method `#getAnnotationsForCanvas` is an API call method which will return all annotations which are bound to a given canvas, along with all annotations which target it either directly or indirectly. For example: Annotation 3 targets Annotation 2; Annotation 2 targets standard Annotation 1; Annotation 1 is bound to a canvas.

## External Links
* [Project Mirador](https://github.com/ProjectMirador/mirador)
* [International Image Interoperability Framework (IIIF)](http://iiif.io/)
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default: &default
adapter: postgresql
host: localhost
host: <%= ENV['DB_HOST'] %>
pool: 5
timeout: 5000
encodeing: utf8
Expand Down
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "2"

services:
rails:
container_name: annotation-server-rails
build: .
ports:
- 3000:3000
command: "bundle exec rails s -p 3000 -b '0.0.0.0'"
stdin_open: true
tty: true
links:
- postgres:postgres
- redis:redis
environment:
VIRTUAL_HOST: ${RAILS_SERVER_HOSTNAME}
DB_HOST: ${DB_HOST}
DATABASE_DEV: ${DATABASE_DEV}
DB_USERNAME_DEV: ${DB_USERNAME_DEV}
DB_PASSWORD_DEV: ${DB_PASSWORD_DEV}
volumes:
- ${APPLICATION_PATH}:/app
expose:
- "3000"

postgres:
container_name: annotation-server-postgres
image: postgres:latest
environment:
POSTGRES_USER: ${DB_USERNAME_DEV}
POSTGRES_PASSWORD: ${DB_PASSWORD_DEV}
volumes:
- postgres-data:/var/lib/postgresql/data

redis:
container_name: annotation-server-redis
image: redis:latest

volumes:
postgres-data: