Skip to content

Commit b62d735

Browse files
authored
Merge pull request #129 from yale-web-technologies/chris-dockerize
Add Docker Development Environment
2 parents bb59381 + 3377070 commit b62d735

File tree

6 files changed

+151
-32
lines changed

6 files changed

+151
-32
lines changed

.env.template

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# ------------------------------
2+
# Path configuration
3+
# ------------------------------
4+
5+
6+
# ------------------------------
7+
# Redis configuration
8+
# ------------------------------
9+
10+
# Y/N
11+
USE_REDIS=N
12+
13+
# Uncomment and set these if Redis is enabled
14+
# S3_BUCKET=
15+
# S3_BUCKET_FOLDER=
16+
# S3_KEY=
17+
# S3_SECRET=
18+
19+
# ------------------------------
20+
# DB configuration
21+
# ------------------------------
22+
23+
# Generally 'localhost', but use 'postgres' for docker-compose
24+
DB_HOST=postgres
25+
26+
DATABASE_DEV=annotations_dev
27+
DB_USERNAME_DEV=annotations_dev
28+
DB_PASSWORD_DEV=rails
29+
30+
# DATABASE_TEST=
31+
# DB_USERNAME_TEST=
32+
# DB_PASSWORD_TEST=
33+
34+
# DATABASE_PROD=
35+
# DB_USERNAME_PROD=
36+
# DB_PASSWORD_PROD=
37+
38+
# ------------------------------
39+
# IIIF configuration
40+
# ------------------------------
41+
IIIF_COLLECTIONS_HOST=
42+
IIIF_HOST_URL=
43+
44+
# ------------------------------
45+
# Docker-compose configuration
46+
# ------------------------------
47+
48+
# Tells Docker what folder to mount as a volume for the codebase
49+
# Should be the current working directory
50+
# APPLICATION_PATH=
51+
52+
# Set this if using a Docker proxy container
53+
# RAILS_SERVER_HOSTNAME=annotations.local

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ pickle-email-*.html
4646
.rvmrc
4747
.ruby-gemset
4848
.ruby-version
49+
50+
local_env
51+
.env

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ruby:2.2.4
2+
3+
RUN apt-get install gcc imagemagick -y
4+
5+
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
6+
RUN mkdir /app
7+
WORKDIR /app
8+
ADD Gemfile /app/Gemfile
9+
ADD Gemfile.lock /app/Gemfile.lock
10+
RUN bundle install
11+
12+
CMD [""]

README.md

+42-31
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
1-
Mirador-Annotations
2-
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.
3-
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.
1+
# Mirador-Annotations
2+
## Purpose
3+
Provide a simple International Image Interoperability Framework (IIIF) Annotations server. Intended to be paired with Mirador, but can be used as a standalone deployment.
4+
5+
## About
6+
It assumes an outside manifest and canvas server, but can be pointed to by a Mirador endpoint and used to store and retrieve annotations.
7+
8+
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.
9+
410
See wiki home page for more background and information.
511

6-
Getting Started:
7-
Mirador-Annotations is basically a standard Ruby on Rails application with the usual deployment steps:
8-
**Installation:**
9-
- git clone
10-
- bundle
11-
- rake db:migrate
12-
1. Clone the repository
13-
2. Run bundle install
14-
3. Rake db:migrate
15-
4. Set env config variables:
16-
- IIIF_HOST_URL
17-
- USE_REDIS
18-
if USE_REDIS is set to 'Y' then set these:
19-
- REDIS_URL
20-
- S3_Bucket
21-
- S3_Bucket_Folder
22-
- S3_Key
23-
- S3_Secret
24-
25-
**Usage:**
26-
- Mirador-Annotations receives new annotations in IIIF format and will save to whichever relational database
27-
is configured. It will also return requested annotations in IIIF format.
28-
- For use with Mirador, the central thought is to allow both standard annotations which are bound to a canvas,
29-
and "targeting" annotations which are bound to another annotation.
30-
- 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
31-
- Custom Method *getAnnotationsForCanvas* is an API call method which will return all annotations which are bound to a given canvas,
32-
along with all annotations which target it either directly or indirectly
33-
(i.e. Annotation 3 targets Annotation 2 which targets standard Annotation 1, which is bound to a canvas)
12+
## Getting Started
13+
14+
### Basic Installation
15+
16+
Mirador-Annotations is a standard Ruby on Rails application with the usual deployment steps:
17+
18+
1. clone the repository
19+
2. `bundle install`
20+
3. `rake db:migrate`
21+
4. Set `.env` config variables
22+
23+
### Developing Via Docker
24+
If you prefer to develop via Docker, define the required variables in the `.env` file, then run the following:
25+
26+
1. `docker-compose up -d`
27+
2. `docker-compose run rails rake db:migrate`
28+
29+
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.
30+
31+
For troubleshooting tips on on developing with docker check the wiki.
32+
33+
34+
## Usage Notes
35+
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.
36+
37+
Allows both standard annotations which are bound to a canvas, and "targeting" annotations which are bound to another annotation.
38+
39+
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.
40+
41+
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.
3442

43+
## External Links
44+
* [Project Mirador](https://github.com/ProjectMirador/mirador)
45+
* [International Image Interoperability Framework (IIIF)](http://iiif.io/)

config/database.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
default: &default
22
adapter: postgresql
3-
host: localhost
3+
host: <%= ENV['DB_HOST'] %>
44
pool: 5
55
timeout: 5000
66
encodeing: utf8

docker-compose.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: "2"
2+
3+
services:
4+
rails:
5+
container_name: annotation-server-rails
6+
build: .
7+
ports:
8+
- 3000:3000
9+
command: "bundle exec rails s -p 3000 -b '0.0.0.0'"
10+
stdin_open: true
11+
tty: true
12+
links:
13+
- postgres:postgres
14+
- redis:redis
15+
environment:
16+
VIRTUAL_HOST: ${RAILS_SERVER_HOSTNAME}
17+
DB_HOST: ${DB_HOST}
18+
DATABASE_DEV: ${DATABASE_DEV}
19+
DB_USERNAME_DEV: ${DB_USERNAME_DEV}
20+
DB_PASSWORD_DEV: ${DB_PASSWORD_DEV}
21+
volumes:
22+
- ${APPLICATION_PATH}:/app
23+
expose:
24+
- "3000"
25+
26+
postgres:
27+
container_name: annotation-server-postgres
28+
image: postgres:latest
29+
environment:
30+
POSTGRES_USER: ${DB_USERNAME_DEV}
31+
POSTGRES_PASSWORD: ${DB_PASSWORD_DEV}
32+
volumes:
33+
- postgres-data:/var/lib/postgresql/data
34+
35+
redis:
36+
container_name: annotation-server-redis
37+
image: redis:latest
38+
39+
volumes:
40+
postgres-data:

0 commit comments

Comments
 (0)