├── .editorconfig ├── .gitignore ├── .travis.yml ├── Dockerfile ├── Makefile ├── README.md └── docker-compose.yml /.editorconfig: -------------------------------------------------------------------------------- 1 | # See https://editorconfig.org for format details and 2 | # https://editorconfig.org/#download for editor / IDE integration 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 4 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | end_of_line = lf 12 | charset = utf-8 13 | 14 | # Makefiles always use tabs for indentation 15 | [Makefile] 16 | indent_style = tab 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | sudo: true #required to use docker 3 | notifications: 4 | email: false 5 | services: 6 | - docker 7 | jobs: 8 | include: 9 | - name: Build container 10 | before_install: pip install --user awscli 11 | script: make dist 12 | - stage: publish image 13 | install: 14 | - pip install --user awscli 15 | script: skip 16 | before_deploy: make dist 17 | deploy: 18 | skip_cleanup: true 19 | provider: script 20 | script: make publish 21 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | 3 | ENV CANTALOUPE_VERSION=4.1.5 4 | 5 | EXPOSE 8182 6 | 7 | VOLUME /imageroot 8 | 9 | # Update packages and install tools 10 | RUN apt-get update -qy && apt-get dist-upgrade -qy && \ 11 | apt-get install -qy --no-install-recommends curl imagemagick \ 12 | libopenjp2-tools ffmpeg unzip default-jre-headless && \ 13 | apt-get -qqy autoremove && apt-get -qqy autoclean 14 | 15 | # Run non privileged 16 | RUN adduser --system cantaloupe 17 | 18 | # Get and unpack Cantaloupe release archive 19 | RUN curl --silent --fail -OL https://github.com/medusa-project/cantaloupe/releases/download/v$CANTALOUPE_VERSION/Cantaloupe-$CANTALOUPE_VERSION.zip \ 20 | && unzip Cantaloupe-$CANTALOUPE_VERSION.zip \ 21 | && ln -s cantaloupe-$CANTALOUPE_VERSION cantaloupe \ 22 | && rm Cantaloupe-$CANTALOUPE_VERSION.zip \ 23 | && mkdir -p /var/log/cantaloupe /var/cache/cantaloupe \ 24 | && chown -R cantaloupe /cantaloupe /var/log/cantaloupe /var/cache/cantaloupe \ 25 | && cp -rs /cantaloupe/deps/Linux-x86-64/* /usr/ 26 | 27 | USER cantaloupe 28 | CMD ["sh", "-c", "java -Dcantaloupe.config=/cantaloupe/cantaloupe.properties.sample -jar /cantaloupe/cantaloupe-$CANTALOUPE_VERSION.war"] 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: help dist publish promote 2 | SHELL=/bin/bash 3 | ECR_REGISTRY=672626379771.dkr.ecr.us-east-1.amazonaws.com 4 | DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ) 5 | 6 | help: ## Print this message 7 | @awk 'BEGIN { FS = ":.*##"; print "Usage: make \n\nTargets:" } \ 8 | /^[-_[:alpha:]]+:.?*##/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST) 9 | 10 | dist: ## Build docker image 11 | docker build -t $(ECR_REGISTRY)/cantaloupe-stage:latest \ 12 | -t $(ECR_REGISTRY)/cantaloupe-stage:`git describe --always` \ 13 | -t cantaloupe:latest . 14 | 15 | publish: dist ## Build, tag and push 16 | $$(aws ecr get-login --no-include-email --region us-east-1) 17 | docker push $(ECR_REGISTRY)/cantaloupe-stage:latest 18 | docker push $(ECR_REGISTRY)/cantaloupe-stage:`git describe --always` 19 | aws ecs update-service --cluster cantaloupe-stage-cluster --service cantaloupe-stage --region us-east-1 --force-new-deployment 20 | 21 | promote: ## Promote the current staging build to production 22 | $$(aws ecr get-login --no-include-email --region us-east-1) 23 | docker pull $(ECR_REGISTRY)/cantaloupe-stage:latest 24 | docker tag $(ECR_REGISTRY)/cantaloupe-stage:latest $(ECR_REGISTRY)/cantaloupe-prod:latest 25 | docker tag $(ECR_REGISTRY)/cantaloupe-stage:latest $(ECR_REGISTRY)/cantaloupe-prod:$(DATETIME) 26 | docker push $(ECR_REGISTRY)/cantaloupe-prod:latest 27 | docker push $(ECR_REGISTRY)/cantaloupe-prod:$(DATETIME) 28 | aws ecs update-service --cluster cantaloupe-prod-cluster --service cantaloupe-prod --region us-east-1 --force-new-deployment 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MIT Libraries Cantaloupe Docker Container 2 | 3 | This is our [Cantaloupe](https://cantaloupe-project.github.io/) container used in production. While you are welcome to use this container, and we appreciate PRs, the primary purpose of this repo is managing our production image. 4 | 5 | The `cantaloupe.properties.sample` file is the distributed version without modifications. All setting changes are handled through environment variables. 6 | 7 | ## Local Development 8 | 9 | There is a docker-compose file that will spin up an instance of minio as well as the IIIF server. The cantaloupe instance is configured to mostly track the production configuration which uses S3 for both the source and derivative cache. To start just run: `docker-compose up`. 10 | 11 | The minio server can be accessed at http://localhost:9000. The default username and password are `minio` and `password`. If you want to change these you can set the `MINIO_USERNAME` and `MINIO_PASSWORD` environment variables in a `.env` file. You will need to create a bucket called `images` and upload an image file to it. You should then be able to access the image through cantaloupe. For example, if you upload a file called `test.jp2` then you can see a JPEG version of the image scaled to 300 width at http://localhost:8182/iiif/2/test.jp2/full/300,/0/default.jpg. 12 | 13 | If you make changes to the Dockerfile, you will need to run `docker-compose build`. 14 | 15 | ## Deployment to AWS 16 | 17 | To publish a new staging build run `make publish`. To promote the current staging build to production run `make promote`. 18 | 19 | ## ToDo/Explore 20 | 21 | Updating to ImageMagick 7. There is a commented out setup in the Dockerfile if we need to compile from source. Hopefully by the time ImageMagick 6 is no longer supported by Cantaloupe there will be an official Debian package we can use. 22 | 23 | [Source chunking](https://medusa-project.github.io/cantaloupe/manual/4.1/sources.html). This is a new feature in Cantaloupe 4.1 and is supported by the KakaduNativeProcessor. 24 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | services: 3 | cantaloupe: 4 | image: cantaloupe 5 | build: . 6 | ports: 7 | - 8182:8182 8 | depends_on: 9 | - minio 10 | environment: 11 | HTTP_HTTP2_ENABLED: "true" 12 | HTTPS_HTTP2_ENABLED: "true" 13 | ENDPOINT_IIIF_CONTENT_DISPOSITION: none 14 | SOURCE_STATIC: S3Source 15 | S3SOURCE_ENDPOINT: http://minio:9000 16 | S3SOURCE_ACCESS_KEY_ID: minio 17 | S3SOURCE_SECRET_KEY: password 18 | S3SOURCE_BASICLOOKUPSTRATEGY_BUCKET_NAME: images 19 | PROCESSOR_SELECTION_STRATEGY: ManualSelectionStrategy 20 | PROCESSOR_MANUAL_SELECTIONSTRATEGY_JP2: OpenJpegProcessor 21 | CACHE_SERVER_DERIVATIVE_ENABLED: "true" 22 | CACHE_SERVER_DERIVATIVE: S3Cache 23 | CACHE_SERVIER_DERIVATIVE_TTL_SECONDS: 0 24 | CACHE_SERVER_PURGE_MISSING: "true" 25 | CACHE_SERVER_WORKER_ENABLED: "true" 26 | S3CACHE_ENDPOINT: http://minio:9000 27 | S3CACHE_ACCESS_KEY_ID: minio 28 | S3CACHE_SECRET_KEY: password 29 | S3CACHE_BUCKET_NAME: images 30 | S3CACHE_OBJECT_KEY_PREFIX: cache 31 | LOG_APPLICATION_LEVEL: warn 32 | LOG_ACCESS_CONSOLEAPPENDER_ENABLED: "true" 33 | minio: 34 | image: minio/minio 35 | command: ["server", "/data"] 36 | ports: 37 | - 9000:9000 38 | environment: 39 | MINIO_ACCESS_KEY: ${MINIO_USERNAME:-minio} 40 | MINIO_SECRET_KEY: ${MINIO_PASSWORD:-password} 41 | --------------------------------------------------------------------------------