├── .dockerignore
├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── Makefile
├── README.md
├── cap-level0.toml
├── cap-max.toml
├── compose.build.yml
├── compose.override-example.yml
├── compose.yml
├── docker
├── Dockerfile
├── Dockerfile-alpine
├── README.md
├── demo-rais-entry.sh
├── demo-web-entry.sh
├── hub.md
├── images
│ ├── jp2tests
│ │ ├── 16-bit-gray.jp2
│ │ ├── 16-bit-rgb.jp2
│ │ └── sn00063609-19091231.jp2
│ └── testfile
│ │ ├── test-world-link.jp2
│ │ ├── test-world.jp2
│ │ └── test-world.jp2-info.json
├── nginx.conf
├── s3demo
│ ├── .gitignore
│ ├── Dockerfile
│ ├── README.md
│ ├── admin.go.html
│ ├── asset.go.html
│ ├── compose.yml
│ ├── env-example
│ ├── go.mod
│ ├── go.sum
│ ├── index.go.html
│ ├── layout.go.html
│ ├── main.go
│ ├── nginx.conf
│ └── server.go
└── static
│ ├── index.html
│ ├── osd
│ ├── images
│ │ ├── fullpage_grouphover.png
│ │ ├── fullpage_hover.png
│ │ ├── fullpage_pressed.png
│ │ ├── fullpage_rest.png
│ │ ├── home_grouphover.png
│ │ ├── home_hover.png
│ │ ├── home_pressed.png
│ │ ├── home_rest.png
│ │ ├── next_grouphover.png
│ │ ├── next_hover.png
│ │ ├── next_pressed.png
│ │ ├── next_rest.png
│ │ ├── previous_grouphover.png
│ │ ├── previous_hover.png
│ │ ├── previous_pressed.png
│ │ ├── previous_rest.png
│ │ ├── rotateleft_grouphover.png
│ │ ├── rotateleft_hover.png
│ │ ├── rotateleft_pressed.png
│ │ ├── rotateleft_rest.png
│ │ ├── rotateright_grouphover.png
│ │ ├── rotateright_hover.png
│ │ ├── rotateright_pressed.png
│ │ ├── rotateright_rest.png
│ │ ├── zoomin_grouphover.png
│ │ ├── zoomin_hover.png
│ │ ├── zoomin_pressed.png
│ │ ├── zoomin_rest.png
│ │ ├── zoomout_grouphover.png
│ │ ├── zoomout_hover.png
│ │ ├── zoomout_pressed.png
│ │ └── zoomout_rest.png
│ └── openseadragon.min.js
│ └── template.html
├── go.mod
├── go.sum
├── gocutus.png
├── rais-example.toml
├── revive.toml
├── rh_config
├── init.sh
└── rais.service
├── scripts
├── buildrun.sh
├── can_cgo.sh
├── deploy.sh
├── dev.sh
└── s3list.go
└── src
├── cmd
├── jp2info
│ └── main.go
└── rais-server
│ ├── admin_handlers.go
│ ├── cache.go
│ ├── config.go
│ ├── encode.go
│ ├── errors.go
│ ├── headers.go
│ ├── image_handler.go
│ ├── image_handler_test.go
│ ├── image_info.go
│ ├── internal
│ ├── servers
│ │ └── servers.go
│ └── statusrecorder
│ │ └── statusrecorder.go
│ ├── main.go
│ ├── main_test.go
│ ├── middleware.go
│ ├── plugins.go
│ ├── register.go
│ └── stats.go
├── fakehttp
├── response_writer.go
└── response_writer_test.go
├── iiif
├── feature_levels.go
├── feature_support.go
├── features.go
├── features_test.go
├── format.go
├── format_test.go
├── iiif.go
├── info.go
├── info_test.go
├── quality.go
├── region.go
├── region_test.go
├── rotation.go
├── rotation_test.go
├── size.go
├── size_test.go
├── url.go
└── url_test.go
├── img
├── cloud_stream.go
├── cloud_stream_test.go
├── constraint.go
├── decoder.go
├── errors.go
├── file_stream.go
├── resource.go
├── resource_test.go
└── streamer.go
├── jp2info
├── info.go
└── scanner.go
├── openjpeg
├── decode.go
├── handlers.c
├── handlers.h
├── image_stream.go
├── jp2_image.go
├── jp2_image_test.go
├── jp2_resources.go
├── logging.go
├── progression_level.go
├── progression_level_test.go
├── stream.c
└── stream.h
├── plugins
├── datadog
│ └── main.go
├── imagick-decoder
│ ├── convert.go
│ ├── image.go
│ ├── magick.c
│ ├── magick.h
│ ├── main.go
│ └── resources.go
├── json-tracer
│ ├── main.go
│ ├── sr.go
│ ├── tracer.go
│ └── write.go
└── plugins.go
├── transform
├── generator.go
├── rotation.go
└── template.txt
└── version
└── version.go
/.dockerignore:
--------------------------------------------------------------------------------
1 | .*.swp
2 | /Dockerfile
3 | /docker/images/
4 | /bin
5 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.go diff=golang
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bin
2 | /docker/images
3 | !/docker/images/testfile/test-world*
4 | /.env
5 | /docker-compose.override.yml
6 | /compose.override.yml
7 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile directory
2 | MakefileDir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
3 |
4 | .PHONY: all generate binaries test format lint clean distclean docker
5 |
6 | BUILD := $(shell git describe --tags)
7 |
8 | # Default target builds binaries
9 | all: cgo binaries
10 |
11 | # Security check
12 | .PHONY: audit
13 | audit:
14 | go tool govulncheck ./src/...
15 |
16 | .PHONY: cgo
17 | cgo:
18 | ./scripts/can_cgo.sh
19 |
20 | # Generated code
21 | generate: src/transform/rotation.go
22 |
23 | src/transform/rotation.go: src/transform/generator.go src/transform/template.txt
24 | go run src/transform/generator.go
25 | go fmt src/transform/rotation.go
26 |
27 | # Binary building rules
28 | binaries: src/transform/rotation.go rais-server jp2info bin/plugins/json-tracer.so
29 |
30 | rais-server:
31 | go build -ldflags="-s -w -X rais/src/version.Version=$(BUILD)" -o ./bin/rais-server rais/src/cmd/rais-server
32 |
33 | jp2info:
34 | go build -ldflags="-s -w -X rais/src/version.Version=$(BUILD)" -o ./bin/jp2info rais/src/cmd/jp2info
35 |
36 | # Testing
37 | test:
38 | go test rais/src/...
39 |
40 | bench:
41 | go test -bench=. -benchtime=5s -count=2 rais/src/openjpeg rais/src/cmd/rais-server
42 |
43 | format:
44 | find src/ -name "*.go" | xargs gofmt -l -w -s
45 |
46 | lint:
47 | go tool revive src/...
48 | go vet rais/src/...
49 |
50 | # Cleanup
51 | clean:
52 | rm -rf bin/
53 | rm -f src/transform/rotation.go
54 |
55 | distclean: clean
56 | go clean -modcache -testcache -cache
57 | docker rmi uolibraries/rais:build || true
58 | docker rmi uolibraries/rais:build-alpine || true
59 | docker rmi uolibraries/rais:dev || true
60 | docker rmi uolibraries/rais:dev-alpine || true
61 |
62 | # Generate the docker images
63 | docker: | generate
64 | docker pull golang:1
65 | docker pull golang:1-alpine
66 | docker build --rm --target build -f $(MakefileDir)/docker/Dockerfile -t rais:build $(MakefileDir)
67 | docker build --rm -f $(MakefileDir)/docker/Dockerfile -t uolibraries/rais:dev $(MakefileDir)
68 | make docker-alpine
69 |
70 | # Build just the alpine image for cases where we want to get this updated / cranked out fast
71 | docker-alpine: | generate
72 | docker build --rm --target build -f $(MakefileDir)/docker/Dockerfile-alpine -t rais:build-alpine $(MakefileDir)
73 | docker build --rm -f $(MakefileDir)/docker/Dockerfile-alpine -t uolibraries/rais:dev-alpine $(MakefileDir)
74 |
75 | # Build plugins on any change to their directory or their go files
76 | bin/plugins/%.so : src/plugins/% src/plugins/%/*.go
77 | go build -ldflags="-s -w" -buildmode=plugin -o $@ rais/$<
78 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://goreportcard.com/report/github.com/uoregon-libraries/rais-image-server)
2 |
3 | Rodent-Assimilated Image Server
4 | =======
5 |
6 | 
7 |
8 | RAIS was originally built by [eikeon](https://github.com/eikeon) as a 100% open
9 | source, no-commercial-products-required, proof-of-concept tile server for JP2
10 | images within [chronam](https://github.com/LibraryOfCongress/chronam).
11 |
12 | It has been updated to allow more command-line options, more source file
13 | formats, more features, and conformance to the [IIIF](http://iiif.io/) spec.
14 |
15 | RAIS is very efficient, completely free, and easy to set up and run. See our
16 | [wiki](https://github.com/uoregon-libraries/rais-image-server/wiki) pages for
17 | more details and documentation.
18 |
19 | Configuration
20 | -----
21 |
22 | ### Main Configuration Settings
23 |
24 | RAIS uses a configuration system that allows environment variables, a config
25 | file, and/or command-line flags. See [rais-example.toml](rais-example.toml)
26 | for an example of a configuration file. RAIS will use a configuration
27 | file if one exists at `/etc/rais.toml`.
28 |
29 | The configuration file's values can be overridden by environment variables,
30 | while command-line flags will override both configuration files and
31 | environmental variables. Configuration is best explained and understood by
32 | reading the example file above, which describes all the values in detail.
33 |
34 | ### Cloud Settings
35 |
36 | Because connecting to a cloud provider is optional, often means using a
37 | container-based setup, and differs from one provider to the next, all RAIS
38 | cloud configuration is environment-only. This means it can't be specified on
39 | the command line or in `rais.toml`.
40 |
41 | Currently RAIS can theoretically support S3, Azure, and Google Cloud backends,
42 | but only S3 has had much testing. To set up RAIS for S3, you would have to
43 | export the following environment variables (in addition to having an
44 | S3-compatible object store running):
45 |
46 | - `AWS_ACCESS_KEY_ID`: Required
47 | - `AWS_SECRET_ACCESS_KEY`: Required
48 | - `AWS_REGION`: Required
49 | - `RAIS_S3_ENDPOINT`: optionally set for custom S3 backends; e.g., "minio:9000"
50 | - `RAIS_S3_DISABLESSL`: optionally set this to "true" for custom S3 backends
51 | which don't need SSL (for instance if they're running on the same server as
52 | RAIS)
53 | - `RAIS_S3_FORCEPATHSTYLE`: optionally set this to "true" to force path-style
54 | S3 calls. This is typically necessary for custom S3 backends like minio, but
55 | not for AWS.
56 |
57 | Other backends have their own environment variables which have to be set in
58 | order to have RAIS connect to them.
59 |
60 | For a full demo of a working custom S3 backend powered by minio, see `docker/s3demo`.
61 |
62 | **Note** that external storage is going to be slower than serving images from
63 | local filesystems! Make sure you test carefully!
64 |
65 | IIIF Features
66 | -----
67 |
68 | RAIS supports level 2 of the IIIF Image API 2.1 as well as a handful of
69 | features beyond level 2. See
70 | [the IIIF Features wiki page](https://github.com/uoregon-libraries/rais-image-server/wiki/IIIF-Features)
71 | for an in-depth look at feature support.
72 |
73 | Caching
74 | -----
75 |
76 | RAIS can internally cache the IIIF `info.json` requests and individual tile
77 | requests. See the [RAIS Caching](https://github.com/uoregon-libraries/rais-image-server/wiki/Caching)
78 | wiki page for details.
79 |
80 | Generating tiled, multi-resolution JP2s
81 | ---
82 |
83 | RAIS performs best with JP2s which are generated as tiled, multi-resolution
84 | (think "zoom levels") images. Generating images like this is fairly easy with
85 | either the openjpeg tools or graphicsmagick. Other tools probably do this
86 | well, but we've only directly used those.
87 |
88 | You can find detailed instructions on the
89 | [How to encode jp2s](https://github.com/uoregon-libraries/rais-image-server/wiki/How-To-Encode-JP2s)
90 | wiki page.
91 |
92 | License
93 | -----
94 |
95 |
96 |
97 | RAIS Image Server is in the public domain under a
98 | [CC0](http://creativecommons.org/publicdomain/zero/1.0/) license.
99 |
100 | Contributors
101 | -----
102 |
103 | Special thanks to Jessica Dussault (@jduss4) for providing the hand-drawn
104 | "Gocutus" logo, and Greg Tunink (@techgique) for various digital refinements to
105 | said logo.
106 |
--------------------------------------------------------------------------------
/cap-level0.toml:
--------------------------------------------------------------------------------
1 | SizeByWhListed = true
2 | Default = true
3 | Jpg = true
4 |
--------------------------------------------------------------------------------
/cap-max.toml:
--------------------------------------------------------------------------------
1 | # This is an example capabilities file. Please note that RAIS will not check
2 | # custom capabilities for validity; as such, if you claim something is enabled
3 | # which RAIS doesn't support, such as WEBP output, IIIF image clients may make
4 | # invalid requests RAIS won't handle.
5 | #
6 | # All values below reflect the state of RAIS's capabilities as of August, 2018.
7 | # Note that Gif output is disabled by default, but may be enabled if desired.
8 | # It is generally too slow for a production server, however.
9 | RegionByPx = true
10 | RegionByPct = true
11 | RegionSquare = true
12 |
13 | SizeByWhListed = true
14 | SizeByW = true
15 | SizeByH = true
16 | SizeByPct = true
17 | SizeByWh = true
18 | SizeByForcedWh = true
19 | SizeAboveFull = true
20 | SizeByConfinedWh = true
21 | SizeByDistortedWh = true
22 |
23 | RotationBy90s = true
24 | Mirroring = true
25 |
26 | Default = true
27 | Color = true
28 | Gray = true
29 | Bitonal = true
30 |
31 | Jpg = true
32 | Png = true
33 | Gif = false
34 | Tif = true
35 |
36 | BaseURIRedirect = true
37 | Cors = true
38 | JsonldMediaType = true
39 |
--------------------------------------------------------------------------------
/compose.build.yml:
--------------------------------------------------------------------------------
1 | # This file is used to run builds on systems where installing the RAIS
2 | # dependencies is too cumbersome or simply undesirable. This is most easily
3 | # used via the `scripts/buildrun.sh` command.
4 | volumes:
5 | gopkg: {}
6 | gocache: {}
7 |
8 | services:
9 | rais-build:
10 | build:
11 | context: .
12 | dockerfile: ./docker/Dockerfile
13 | target: build
14 | volumes:
15 | - ./:/opt/rais-src:rw
16 | - ./docker/images:/var/local/images:ro
17 | - gocache:/root/.cache/go-build
18 | - gopkg:/usr/local/go/pkg
19 | command: make
20 |
--------------------------------------------------------------------------------
/compose.override-example.yml:
--------------------------------------------------------------------------------
1 | # Copy this to compose.override.yml and modify as needed. This file
2 | # adds some dev-friendly container magic to the mix:
3 | #
4 | # - All binaries are mounted into the container so you can test out local changes
5 | # - RAIS directly exposes its port to the host machine for quick debugging
6 | services:
7 | rais:
8 | # Uncomment one of these if you'd like to use an image built by `make
9 | # docker` rather than testing out the latest uploaded image
10 | #image: uolibraries/rais:dev
11 | #image: uolibraries/rais:dev-alpine
12 |
13 | environment:
14 | # These next lines would allow you to pass the various S3 configuration
15 | # options through from the host's environment (or the local .env file)
16 | - RAIS_S3_ENDPOINT
17 | - RAIS_S3_DISABLESSL
18 | - RAIS_S3_FORCEPATHSTYLE
19 | - AWS_ACCESS_KEY_ID
20 | - AWS_SECRET_ACCESS_KEY
21 | - AWS_REGION
22 | - AWS_SESSION_TOKEN
23 |
24 | # If you wanted to use a configured AWS credentials file for s3, do this
25 | # and then see the volume config below
26 | - AWS_SHARED_CREDENTIALS_FILE=/etc/aws.credentials
27 | ports:
28 | - 12415:12415
29 | - 12416:12416
30 |
--------------------------------------------------------------------------------
/compose.yml:
--------------------------------------------------------------------------------
1 | # This describes a self-contained demo of RAIS, using nginx to serve up the
2 | # static pages. This isn't a production configuration file!!
3 | #
4 | # If you don't set up an override file (compose.override-example.yml,
5 | # for instance), this will just use the stable version of RAIS from dockerhub.
6 | #
7 | # Put JP2s into docker/images and the apache entrypoint script will add them to
8 | # the images served by from RAIS.
9 | services:
10 | rais:
11 | image: uolibraries/rais
12 | environment:
13 | - URL
14 | - RAIS_ADDRESS
15 | - RAIS_LOGLEVEL
16 | - RAIS_TILEPATH=/var/local/images
17 | - RAIS_IIIFWEBPATH
18 | - RAIS_IIIFBASEURL
19 | - RAIS_INFOCACHELEN
20 | - RAIS_TILECACHELEN
21 | - RAIS_IMAGEMAXAREA
22 | - RAIS_IMAGEMAXWIDTH
23 | - RAIS_IMAGEMAXHEIGHT
24 | - RAIS_PLUGINS=*
25 | - RAIS_JPGQUALITY
26 | - RAIS_ALLOW_INSECURE_PLUGINS=0
27 | volumes:
28 | - ./docker/images:/var/local/images:ro
29 | - ./rais-example.toml:/etc/rais-template.toml:ro
30 | - ./cap-max.toml:/etc/rais-capabilities.toml:ro
31 | - ./docker/demo-rais-entry.sh:/entrypoint.sh:ro
32 | entrypoint: /entrypoint.sh
33 |
34 | web:
35 | image: nginx:1.15
36 | volumes:
37 | - ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
38 | - ./docker/images:/var/local/images:ro
39 | - ./docker/static:/static:ro
40 | - ./docker/demo-web-entry.sh:/entrypoint.sh:ro
41 | entrypoint: /entrypoint.sh
42 | depends_on:
43 | - rais
44 | ports:
45 | - 80:80
46 |
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | # This generates a production image for RAIS with the S3 plugin enabled
2 | #
3 | # Examples:
4 | #
5 | # # Simple case: just build the latest production image
6 | # docker build --rm -t uolibraries/rais:latest -f ./docker/Dockerfile .
7 | #
8 | # # Generate the build image to simplify local development
9 | # docker build --rm -t uolibraries/rais:build --target build -f ./docker/Dockerfile .
10 | FROM golang:1 AS build
11 | LABEL maintainer="Jeremy Echols "
12 |
13 | # Install all the build dependencies
14 | RUN apt-get update -y && apt-get upgrade -y && \
15 | apt-get install -y libopenjp2-7-dev libmagickcore-dev git gcc make tar findutils
16 |
17 | # Add the go mod stuff first so we aren't re-downloading dependencies except
18 | # when they actually change
19 | WORKDIR /opt/rais-src
20 | ADD ./go.mod /opt/rais-src/go.mod
21 | ADD ./go.sum /opt/rais-src/go.sum
22 | RUN go mod download
23 |
24 | # Make sure we don't just add every little thing, otherwise unimportant changes
25 | # trigger a rebuild
26 | ADD ./Makefile /opt/rais-src/Makefile
27 | ADD ./src /opt/rais-src/src
28 | ADD ./scripts /opt/rais-src/scripts
29 | ADD ./.git /opt/rais-src/.git
30 | RUN make
31 |
32 | # Manually build the ImageMagick and DataDog plugins to make this image as full
33 | # featured as possible, since debian's already pretty bloated.
34 | RUN make bin/plugins/imagick-decoder.so
35 | RUN make bin/plugins/datadog.so
36 |
37 |
38 |
39 | # Production image just installs runtime deps and copies in the binaries
40 | FROM debian:12 AS production
41 | LABEL maintainer="Jeremy Echols "
42 |
43 | # Stolen from mariadb dockerfile: add our user and group first to make sure
44 | # their IDs get assigned consistently
45 | RUN groupadd -r rais && useradd -r -g rais rais
46 |
47 | # Install the core dependencies needed for both build and production
48 | RUN apt-get update -y && apt-get upgrade -y && \
49 | apt-get install -y libopenjp2-7 imagemagick
50 |
51 | ENV RAIS_TILEPATH=/var/local/images
52 | ENV RAIS_PLUGINS="*.so"
53 | RUN touch /etc/rais.toml && chown rais:rais /etc/rais.toml
54 | COPY --from=build /opt/rais-src/bin /opt/rais/
55 |
56 | USER rais
57 | EXPOSE 12415
58 | ENTRYPOINT ["/opt/rais/rais-server"]
59 |
--------------------------------------------------------------------------------
/docker/Dockerfile-alpine:
--------------------------------------------------------------------------------
1 | # This generates a production alpine image for RAIS
2 | #
3 | # Example:
4 | #
5 | # docker build --rm -t uolibraries/rais:latest-alpine -f ./docker/Dockerfile-alpine .
6 | FROM golang:1-alpine AS build
7 | LABEL maintainer="Jeremy Echols "
8 |
9 | # Install all the build dependencies
10 | RUN apk add --no-cache openjpeg-dev git gcc make
11 |
12 | # This is necessary for our openjp2 C bindings
13 | RUN apk add --no-cache musl-dev
14 |
15 | # This is just getting absurd, but results in a dramatically smaller rais-server
16 | RUN apk add --no-cache upx
17 |
18 | # Add the go mod stuff first so we aren't re-downloading dependencies except
19 | # when they actually change
20 | WORKDIR /opt/rais-src
21 | ADD ./go.mod /opt/rais-src/go.mod
22 | ADD ./go.sum /opt/rais-src/go.sum
23 | RUN go mod download
24 |
25 | # Make sure we don't just add every little thing, otherwise unimportant changes
26 | # trigger a rebuild
27 | ADD ./Makefile /opt/rais-src/Makefile
28 | ADD ./src /opt/rais-src/src
29 | ADD ./scripts /opt/rais-src/scripts
30 | ADD ./.git /opt/rais-src/.git
31 | RUN make rais-server
32 |
33 | RUN upx ./bin/rais-server
34 |
35 | # Production image just installs runtime deps and copies in the binaries
36 | FROM alpine:3.10 AS production
37 | LABEL maintainer="Jeremy Echols "
38 |
39 | # Add our user and group first to make sure their IDs get assigned consistently
40 | RUN addgroup -S rais && adduser -S rais -G rais
41 |
42 | # Deps
43 | RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
44 | RUN apk add --no-cache openjpeg
45 |
46 | ENV RAIS_TILEPATH=/var/local/images
47 | ENV RAIS_PLUGINS="-"
48 | RUN touch /etc/rais.toml && chown rais:rais /etc/rais.toml
49 |
50 | # Though we compile everything, we want our default alpine image tiny, so we offer *no* plugins
51 | COPY --from=build /opt/rais-src/bin/rais-server /opt/rais/
52 |
53 | USER rais
54 | EXPOSE 12415
55 | ENTRYPOINT ["/opt/rais/rais-server"]
56 |
--------------------------------------------------------------------------------
/docker/README.md:
--------------------------------------------------------------------------------
1 | # Docker
2 |
3 | This directory contains everything necessary to run RAIS under Docker,
4 | including a test image for the compose-based demo.
5 |
6 | ## Building docker images
7 |
8 | The easiest way to use these is from the parent directory's `Makefile` via
9 | `make docker`.
10 |
11 | ## Running the demo
12 |
13 | From the project root:
14 |
15 | ```bash
16 | # Set up your local server's URL if "localhost" won't suffice for any reason
17 | export URL=http://192.168.0.5
18 |
19 | # Copy images into images/
20 | cp /some/jp2/sources/*.jp2 ./docker/images/
21 |
22 | # Run nginx and RAIS
23 | docker compose up
24 | ```
25 |
--------------------------------------------------------------------------------
/docker/demo-rais-entry.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | # demo-rais-entry.sh is the RAIS entrypoint script, which sets up the
4 | # configuration and runs the rais server
5 |
6 | # Copy the config and edit it in-place; this allows customizing most pieces of
7 | # configuration for demoing
8 | url=${URL:-}
9 | if test "$url" = ""; then
10 | echo "No URL provided; defaulting to 'http://localhost'"
11 | echo "If you can't see images, try an explicitly-set URL, e.g.:"
12 | echo
13 | echo " URL="http://192.168.0.5" docker compose up"
14 | url="http://localhost"
15 | fi
16 |
17 | exec /opt/rais/rais-server
18 |
--------------------------------------------------------------------------------
/docker/demo-web-entry.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # demo-apache-entry.sh is the Apache entrypoint script, which scans for images
4 | # and writes out HTML files to include all images in the RAIS / Open Seadragon
5 | # demo
6 |
7 | # Copy the templates
8 | cp -r /static/* /usr/share/nginx/html
9 |
10 | # Insert a tile source for every file found under /var/local/images
11 | sources=""
12 | for file in $(find /var/local/images -name "*.jp2" -o -name "*.tiff" -o -name "*.jpg" -o -name "*.png"); do
13 | relpath=${file##/var/local/images/}
14 | relpath=${relpath//\//%2F}
15 | if [[ $sources != "" ]]; then
16 | sources="$sources,"
17 | fi
18 |
19 | sources="$sources\"/iiif/$relpath/info.json\""
20 | done
21 | sed "s|%SRCS%|$sources|g" /usr/share/nginx/html/template.html > /usr/share/nginx/html/iiif.html
22 |
23 | exec nginx -g "daemon off;"
24 |
--------------------------------------------------------------------------------
/docker/hub.md:
--------------------------------------------------------------------------------
1 | # Supported tags and respective `Dockerfile` links
2 |
3 | - [`4`, `4.2`, `4.2.0`, `latest` (*docker/Dockerfile*)](https://github.com/uoregon-libraries/rais-image-server/blob/v4.2.0/docker/Dockerfile)
4 | - [`4-alpine`, `4.2-alpine`, `4.2.0-alpine`, `alpine` (*docker/Dockerfile-alpine*)](https://github.com/uoregon-libraries/rais-image-server/blob/v4.2.0/docker/Dockerfile-alpine)
5 | - [`3`, `3.3`, `3.3.2`, (*docker/Dockerfile*)](https://github.com/uoregon-libraries/rais-image-server/blob/v3.3.2/docker/Dockerfile)
6 | - [`3-alpine`, `3.3-alpine`, `3.3.2-alpine` (*docker/Dockerfile*)](https://github.com/uoregon-libraries/rais-image-server/blob/v3.3.2/docker/Dockerfile-alpine)
7 |
8 | # RAIS
9 |
10 | RAIS is a [IIIF](http://iiif.io/) image server, primarily built for speedy serving of tiled, multi-resolution JP2 files. RAIS is 100% open-source, and [the RAIS github repository](https://github.com/uoregon-libraries/rais-image-server) is available under a CC0 license.
11 |
12 | ## Usage
13 |
14 | See [the RAIS github wiki](https://github.com/uoregon-libraries/rais-image-server/wiki/Docker-Demo) for the easiest ways to use RAIS.
15 |
--------------------------------------------------------------------------------
/docker/images/jp2tests/16-bit-gray.jp2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uoregon-libraries/rais-image-server/23e0ccb12c68078716523d00885d90fbe97b6cac/docker/images/jp2tests/16-bit-gray.jp2
--------------------------------------------------------------------------------
/docker/images/jp2tests/16-bit-rgb.jp2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uoregon-libraries/rais-image-server/23e0ccb12c68078716523d00885d90fbe97b6cac/docker/images/jp2tests/16-bit-rgb.jp2
--------------------------------------------------------------------------------
/docker/images/jp2tests/sn00063609-19091231.jp2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uoregon-libraries/rais-image-server/23e0ccb12c68078716523d00885d90fbe97b6cac/docker/images/jp2tests/sn00063609-19091231.jp2
--------------------------------------------------------------------------------
/docker/images/testfile/test-world-link.jp2:
--------------------------------------------------------------------------------
1 | test-world.jp2
--------------------------------------------------------------------------------
/docker/images/testfile/test-world.jp2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uoregon-libraries/rais-image-server/23e0ccb12c68078716523d00885d90fbe97b6cac/docker/images/testfile/test-world.jp2
--------------------------------------------------------------------------------
/docker/images/testfile/test-world.jp2-info.json:
--------------------------------------------------------------------------------
1 | {"@context":"http://iiif.io/api/image/2/context.json","@id":"%ID%","protocol":"http://iiif.io/api/image","width":800,"height":400,"tiles":[{"width":512,"scaleFactors":[1,2]},{"width":1024,"scaleFactors":[1,2]}],"profile":["http://iiif.io/api/image/2/level2.json",{"formats":["gif","tif"],"supports":["mirroring","sizeAboveFull"], "maxArea": 262144, "maxWidth": 512}]}
2 |
--------------------------------------------------------------------------------
/docker/nginx.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | server_name localhost;
4 |
5 | location /iiif/ {
6 | proxy_set_header Host $host;
7 | proxy_set_header X-Real-IP $remote_addr;
8 | proxy_set_header X-Forwarded-For $remote_addr;
9 | proxy_set_header X-Forwarded-Host $host;
10 | proxy_set_header X-Forwarded-Proto $scheme;
11 | proxy_pass http://rais:12415;
12 | }
13 |
14 | location /admin {
15 | proxy_set_header Host $host;
16 | proxy_set_header X-Real-IP $remote_addr;
17 | proxy_set_header X-Forwarded-For $remote_addr;
18 | proxy_set_header X-Forwarded-Host $host;
19 | proxy_set_header X-Forwarded-Proto $scheme;
20 | proxy_pass http://rais:12416;
21 | }
22 |
23 | location / {
24 | root /usr/share/nginx/html;
25 | index index.html index.htm;
26 | }
27 |
28 | # redirect server error pages to the static page /50x.html
29 | #
30 | error_page 500 502 503 504 /50x.html;
31 | location = /50x.html {
32 | root /usr/share/nginx/html;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/docker/s3demo/.gitignore:
--------------------------------------------------------------------------------
1 | /.env
2 | /docker-compose.override.yml
3 |
--------------------------------------------------------------------------------
/docker/s3demo/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1 as build-env
2 | RUN apt-get update
3 | WORKDIR /s3demo
4 | ADD s3demo/go.mod /s3demo/go.mod
5 | ADD s3demo/go.sum /s3demo/go.sum
6 | RUN go mod download
7 | ADD ./s3demo/*.go /s3demo/
8 | RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o server
9 |
10 | FROM alpine
11 | RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
12 | WORKDIR /s3demo
13 | COPY --from=build-env /s3demo/server /s3demo/server
14 | ADD ./s3demo/*.go.html /s3demo/
15 | ADD ./static/osd /s3demo/osd
16 | EXPOSE 8080
17 | ENTRYPOINT ["/s3demo/server"]
18 |
--------------------------------------------------------------------------------
/docker/s3demo/README.md:
--------------------------------------------------------------------------------
1 | s3demo for RAIS
2 | ===
3 |
4 | This folder is dedicated to a mini-asset-manager-like application that presents
5 | a local file alongside any number of cloud files in an S3-compatible object
6 | store.
7 |
8 | Setup
9 | ---
10 |
11 | Run a simple, ugly "exhibit" of an entire S3 bucket!
12 |
13 | ### Get RAIS
14 |
15 | Grab the RAIS codebase and go to this directory:
16 |
17 | ```bash
18 | git clone https://github.com/uoregon-libraries/rais-image-server.git
19 | cd rais-image-server/docker/s3demo
20 | ```
21 |
22 | ### Optional: build a docker image
23 |
24 | You may want to build your own docker image rather than using the latest stable
25 | version from dockerhub, especially if testing out plugins or other code that
26 | requires a recompile. Building an image typically means running `make docker`
27 | and/or `make docker-alpine` *from the RAIS root directory*. Note that the
28 | alpine image is *much* faster to build, but doesn't contain any plugins.
29 |
30 | Once that's done, you will want to put an override for the s3 demo so it uses
31 | your local image. Something like this can be put into
32 | `compose.override.yml` in this (the s3demo) directory:
33 |
34 | ```
35 | version: "3.4"
36 |
37 | networks:
38 | internal:
39 | external:
40 |
41 | services:
42 | rais:
43 | image: uolibraries/rais:latest-alpine
44 | ```
45 |
46 | ### Set up an S3 environment
47 |
48 | We can do this the easy way or the hard way....
49 |
50 | #### The easy way: minio
51 |
52 | The demo is now set up to include "minio", an S3-compatible storage backend, by
53 | default. No actual S3 environment necessary!
54 |
55 | Run the minio container:
56 |
57 | `docker compose up minio`
58 |
59 | Create images:
60 |
61 | - Browse to `http://localhost:9000`
62 | - Log in with the acces key "key" and the secret key "secret"
63 | - Create a new bucket with the name "rais"
64 | - Upload JP2s into this bucket
65 |
66 | You can also use other s3 tools if the web interface for minio isn't to your
67 | liking - you'll just have to specify the S3 endpoint as
68 | `http://localhost:9000`.
69 |
70 | When you're done, you can stop the minio container - it'll restart in the next
71 | step anyway.
72 |
73 | #### The hard way
74 |
75 | You'll have to override the environment variables in `.env`. The easiest way
76 | is simply to copy `env-example` to `.env` and read what's there, customizing
77 | AWS-specific data as necessary.
78 |
79 | You'll also need to make sure you upload JP2 files into the bucket you
80 | designated in your `.env` file.
81 |
82 | A complete explanation of setting up and using AWS services is out of scope
83 | here, however, so if you are unfamiliar with AWS, go with the easy way above.
84 |
85 | ### Start the stack
86 |
87 | Run `docker compose up` and visit `http://localhost`. Gaze upon your glorious
88 | images, lovingly served up by RAIS.
89 |
90 | Caveats
91 | ---
92 |
93 | This is a pretty weak demo, so be advised it's really just for testing, not
94 | production use. Some caveats:
95 |
96 | - The images pulled from S3 live in ephemeral storage and will be deleted after
97 | you delete the RAIS container. This makes it simple to get at realistic
98 | first-hit costs
99 | - If you have non-images in your S3 bucket, behavior is undefined
100 | - If you're running anything else on your server at port 80, this demo won't
101 | work as-is. You may have to customize your setup (e.g., with a
102 | `compose.override.yml` file)
103 |
104 | Development
105 | ---
106 |
107 | Don't hack up the demo unless you want pain. The demo server is a mess, and
108 | the setup is a little hacky. It's here to provide a quick demo, not showcase
109 | elegant solutions to a problem.
110 |
111 | If you are a masochist, however, make sure you re-run "docker compose build"
112 | anytime you change the codebase or the go templates.
113 |
--------------------------------------------------------------------------------
/docker/s3demo/admin.go.html:
--------------------------------------------------------------------------------
1 |