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

changes for improved kitodo docker compose #23

Merged
merged 46 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
64f599e
changes for improved kitodo docker compose
markusweigelt Jun 8, 2022
54195a1
Merge branch 'main' into changes_for_kitodo
markusweigelt Jun 13, 2022
ddbd0a9
split implicit stop rules
bertsky Jun 13, 2022
42cb02f
changes for improved kitodo docker compose
markusweigelt Jun 8, 2022
6f2721d
improvements of kitodo-app and -builder to use with make files
markusweigelt Jun 13, 2022
fc5ba37
Merge branch 'changes_for_kitodo' of github.com:markusweigelt/kitodo_…
markusweigelt Jun 13, 2022
1ac829b
improve makefile and fix path problems using BUILDER_BUILD_RESOURCES
markusweigelt Jun 14, 2022
62d9682
remove symlink and add file again
markusweigelt Jun 14, 2022
b12b1d8
add kitodo app file
markusweigelt Jun 14, 2022
d3fe2ae
change builder path variable
markusweigelt Jun 14, 2022
1670698
use active mq config of submodule repository
markusweigelt Jun 14, 2022
c2c5a1d
simplify 'build' rules and COMPOSE_FILE def
bertsky Jun 14, 2022
a45f8be
example resources only contains diff to generate resources of kitodo …
markusweigelt Jun 16, 2022
fa47b14
revert . to PWD as relative basedir for volumes in .env
bertsky Jun 16, 2022
1050f8c
update submodule
markusweigelt Jun 16, 2022
b3872d3
Merge branch 'changes_for_kitodo' of github.com:markusweigelt/kitodo_…
markusweigelt Jun 16, 2022
9c9a227
submodule to head of kitodo-production-docker
markusweigelt Jun 17, 2022
97792fa
updata resources and ignore unzipped data directory
markusweigelt Jun 17, 2022
5aa4672
update manager module
markusweigelt Jun 17, 2022
9458dd6
revert more . to PWD (finish fa47b14bd)
bertsky Jun 17, 2022
f2b8e2b
update submodule
markusweigelt Jun 17, 2022
7c1eb51
Merge branch 'changes_for_kitodo' of github.com:markusweigelt/kitodo_…
markusweigelt Jun 17, 2022
3d2ef95
update submodule
markusweigelt Jun 17, 2022
e4b15a6
changed scripts/script_ocr.sh
markusweigelt Jun 22, 2022
7e63457
change unzip data to /data/data
markusweigelt Jun 22, 2022
2692e9c
make build-kitodo: run in fg, avoid orphans
bertsky Jun 23, 2022
5ab9615
Kitodo builder: use absolute path for Docker context
bertsky Jun 23, 2022
13f48dc
Merge branch 'changes_for_kitodo' of https://github.com/markusweigelt…
bertsky Jun 23, 2022
711b134
add docker-compose down of kitodo builder
markusweigelt Jun 23, 2022
a25fb32
Merge branch 'changes_for_kitodo' of github.com:markusweigelt/kitodo_…
markusweigelt Jun 23, 2022
4087886
update submodule
markusweigelt Jun 23, 2022
9d320e4
update submodule
markusweigelt Jun 23, 2022
fd90bc8
update submodule
markusweigelt Jun 23, 2022
0613d8b
improve documentation
markusweigelt Jun 23, 2022
1ba466a
revert changes to .env in 0613d8b55
bertsky Jun 23, 2022
1b810b8
remove unused env variables
markusweigelt Jun 24, 2022
2e6fcdb
submodule update
markusweigelt Jun 24, 2022
5449356
consider .env.local if exist
markusweigelt Jun 24, 2022
183fe11
formatting -> remove tabs
markusweigelt Jun 24, 2022
5caf177
update submodule
markusweigelt Jun 24, 2022
90947f9
update submodule
markusweigelt Jun 24, 2022
8b19c98
add env file parameter to docker-compose of build target
markusweigelt Jun 24, 2022
f6aa987
add env variable and update submodule
markusweigelt Jun 24, 2022
9eab6fc
update resource data zip and submodule
markusweigelt Jun 24, 2022
8f90aff
remove handling of .env.local and --env-file parameter of docker-comp…
markusweigelt Jun 24, 2022
2bd8fcb
submodule update
markusweigelt Jun 24, 2022
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
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ MANAGER_PORT_SSH=9022
MANAGER_KEYS=${PWD}/ocrd/manager/.ssh/authorized_keys
MANAGER_KEY=${PWD}/ocrd/manager/.ssh/id_rsa
MANAGER_DATA=${PWD}/kitodo/data/metadata
MANAGER_CONTROLLER_PORT_SSH=22

# Builder Kitodo.Production
BUILDER_TYPE=GIT
BUILDER_GIT_COMMIT=ocrd-main
BUILDER_GIT_SOURCE_URL=https://github.com/markusweigelt/kitodo-production/
BUILDER_BUILD_RESOURCES=${PWD}/_modules/kitodo-production-docker/kitodo/build-resources

# Application Kitodo.Production
APP_BUILD_CONTEXT=${PWD}/_modules/kitodo-production-docker/kitodo
APP_BUILD_RESOURCES=${APP_BUILD_CONTEXT}/build-resources
APP_BUILD_CONTEXT=${PWD}/_modules/kitodo-production-docker/kitodo/
APP_BUILD_RESOURCES=./build-resources
APP_DATA=${PWD}/kitodo/data
APP_KEY=${PWD}/kitodo/.ssh/id_rsa
APP_PORT=8080
APP_DEBUG=false
APP_DEBUG_PORT=5005

# Database
DB_IMAGE=mysql:8.0.26
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/ocrd/*
/kitodo/*
*.iml
_resources/data/*
.env.local
190 changes: 93 additions & 97 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,97 +1,93 @@
TAGNAME ?= markusweigelt/ocrd_manager
SHELL = /bin/bash

CONTROLLER_ENV_UID ?= $(shell id -u)
CONTROLLER_ENV_GID ?= $(shell id -g)
MANAGER_ENV_UID ?= $(shell id -u)
MANAGER_ENV_GID ?= $(shell id -g)

MODE ?= managed
COMPOSE_FILES = docker-compose.yml
ifeq (managed,$(MODE))
COMPOSE_FILES += docker-compose.managed.yml
endif
COMPOSE_FILES += docker-compose.kitodo-app.yml
COMPOSE_FILES += docker-compose.kitodo-app.override.yml
bertsky marked this conversation as resolved.
Show resolved Hide resolved
NULL :=
WHITE := $(NULL) $(NULL)
COLON := :
COMPOSE_FILE = $(subst $(WHITE),$(COLON),$(COMPOSE_FILES))

.EXPORT_ALL_VARIABLES:

clean:
$(RM) -fr kitodo ocrd

build: ./kitodo
build: ./kitodo
build: ./kitodo/.ssh/id_rsa
build: ./ocrd/manager/.ssh/id_rsa
build: ./ocrd/controller/.ssh/authorized_keys
build: ./ocrd/manager/.ssh/authorized_keys
build:
$(MAKE) -C _modules/kitodo-production-docker build

./kitodo: ./_resources/config_modules.zip

./kitodo: ./_resources/config_modules.zip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still hesitant to completely skip telling make about ./_resources/config_modules.zip – but if its just a provisional state, ok.

unzip $< -d $@
touch -m $@

./kitodo/.ssh/: ./kitodo

./ocrd/controller/models/ ./ocrd/controller/config/ ./ocrd/manager/.ssh/ ./kitodo/.ssh/ ./ocrd/controller/.ssh/:
mkdir -p $@

./kitodo/.ssh/id_rsa: | ./kitodo/.ssh/
ssh-keygen -t rsa -q -f $@ -P '' -C 'Kitodo.Production key'

./ocrd/manager/.ssh/id_rsa: | ./ocrd/manager/.ssh/
ssh-keygen -t rsa -q -f $@ -P '' -C 'OCR-D manager key'

./ocrd/controller/.ssh/authorized_keys: ./ocrd/manager/.ssh/id_rsa | ./ocrd/controller/.ssh/
cp $<.pub $@

./ocrd/manager/.ssh/authorized_keys: ./kitodo/.ssh/id_rsa
cp $<.pub $@

start:
docker-compose up --build -d

down:
docker-compose down

stop:
docker-compose stop

config:
docker-compose config

status:
docker-compose ps

define HELP
cat <<"EOF"
Targets:
- build create directories and ssh key files
- start run docker-compose up
- down stop & rm docker-compose up
- stop stops docker-compose up
- config dump all the composed files
- status list running containers

Variables:
- CONTROLLER_ENV_UID user id to use on the OCR-D Controller (default: $(CONTROLLER_ENV_UID))
- CONTROLLER_ENV_GID group id to use on the OCR-D Controller (default: $(CONTROLLER_ENV_GID))
- MANAGER_ENV_UID user id to use on the OCR-D Manager (default: $(MANAGER_ENV_UID))
- MANAGER_ENV_GID group id to use on the OCR-D Manager (default: $(MANAGER_ENV_GID))
- MODE if 'managed', also starts/stops OCR-D Controller here (default: $(MODE))
EOF
endef
export HELP
help: ; @eval "$$HELP"

.PHONY: clean build start down config status help

# do not search for implicit rules here:
%.zip Makefile: ;
TAGNAME ?= markusweigelt/ocrd_manager
SHELL = /bin/bash

CONTROLLER_ENV_UID ?= $(shell id -u)
CONTROLLER_ENV_GID ?= $(shell id -g)
MANAGER_ENV_UID ?= $(shell id -u)
MANAGER_ENV_GID ?= $(shell id -g)

MODE ?= managed
ifeq (managed,$(MODE))
COMPOSE_FILE = docker-compose.yml:docker-compose.kitodo-app.yml:docker-compose.managed.yml
else
COMPOSE_FILE = docker-compose.yml:docker-compose.kitodo-app.yml
endif
COMPOSE_PATH_SEPARATOR = :

.EXPORT_ALL_VARIABLES:

clean:
$(RM) -fr kitodo ocrd _modules/kitodo-production-docker/kitodo/build-resources _resources/data

build-keys: ./kitodo/.ssh/id_rsa
build-keys: ./ocrd/manager/.ssh/id_rsa
build-keys: ./ocrd/controller/.ssh/authorized_keys
build-keys: ./ocrd/manager/.ssh/authorized_keys
build-kitodo: | ./_modules/kitodo-production-docker/kitodo/build-resources/
docker-compose -f ./docker-compose.kitodo-builder.yml up --abort-on-container-exit --build
build-examples: ./_resources/data

build: build-keys build-kitodo build-examples

./%/:
mkdir -p $@

./kitodo/.ssh/id_rsa: | ./kitodo/.ssh/
ssh-keygen -t rsa -q -f $@ -P '' -C 'Kitodo.Production key'

./ocrd/manager/.ssh/id_rsa: | ./ocrd/manager/.ssh/
ssh-keygen -t rsa -q -f $@ -P '' -C 'OCR-D manager key'

./ocrd/controller/.ssh/authorized_keys: ./ocrd/manager/.ssh/id_rsa | ./ocrd/controller/.ssh/
cp $<.pub $@

./ocrd/manager/.ssh/authorized_keys: ./kitodo/.ssh/id_rsa
cp $<.pub $@

./_resources/data: ./_resources/data.zip
unzip $< -d $@
touch -m $@

start:
docker-compose up -d --build

down:
docker-compose down
docker-compose -f ./docker-compose.kitodo-builder.yml down

stop:
docker-compose stop

config:
docker-compose config

status:
docker-compose ps

define HELP
cat <<"EOF"
Targets:
- build create directories and ssh key files
- start run docker-compose up
- down stop & rm docker-compose up
- stop stops docker-compose up
- config dump all the composed files
- status list running containers

Variables:
- CONTROLLER_ENV_UID user id to use on the OCR-D Controller (default: $(CONTROLLER_ENV_UID))
- CONTROLLER_ENV_GID group id to use on the OCR-D Controller (default: $(CONTROLLER_ENV_GID))
- MANAGER_ENV_UID user id to use on the OCR-D Manager (default: $(MANAGER_ENV_UID))
- MANAGER_ENV_GID group id to use on the OCR-D Manager (default: $(MANAGER_ENV_GID))
- MODE if 'managed', also starts/stops OCR-D Controller here (default: $(MODE))
- in addition, all variables defined in .env can be overridden via shell or make
EOF
endef
export HELP
help: ; @eval "$$HELP"

.PHONY: clean build build-keys build-kitodo build-examples start down config status help

# do not search for implicit rules here:
%.zip: ;
Makefile: ;
43 changes: 35 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ This could be done persistently via the filesystem, or dynamically:
Unless you want to use `make` below, export all config files into a variable,
so you won't have to type them each time:

export COMPOSE_FILE=docker_compose.yml:docker_compose.managed.yml:docker-compose.kitodo-app.yml:docker-compose.kitodo-app.override.yml
export COMPOSE_FILE=docker_compose.yml:docker_compose.managed.yml:docker-compose.kitodo-app.yml

Or, if you have started the [OCR-D Controller](https://github.com/bertsky/ocrd_controller) externally already:

export COMPOSE_FILE=docker_compose.yml:docker-compose.kitodo-app.yml:docker-compose.kitodo-app.override.yml
export COMPOSE_FILE=docker_compose.yml:docker-compose.kitodo-app.yml


Otherwise (when using the Makefile), just set your mode of operation:
Expand Down Expand Up @@ -143,24 +143,30 @@ Removes the stopped containers as well as any created networks.
#### Configuration

The following environment variables must be defined.
(This can also be done in a `.env` file, syntax is shell-like.)
(This can also be done in a `.env` file, syntax is shell-like.
The file configuration will still be dynamically overridden
by any variable settings via shell or make call.)

##### Controller

(only relevant in `managed` mode)

| Name | Default | Description
| --- | --- | --- |
| CONTROLLER_IMAGE | bertsky/ocrd_controller | name of image |
| CONTROLLER_IMAGE_TAG | latest | tag name of image |
| CONTROLLER_IMAGE | bertsky/ocrd_controller:latest | name and tag of image |
| CONTROLLER_HOST | ocrd-controller | name of host |
| CONTROLLER_ENV_UID | 1001 | user id of ssh user |
| CONTROLLER_ENV_GID | 1001 | group id of ssh user |
| CONTROLLER_ENV_UMASK | 0002 | "ssh user specific permission mask |
| CONTROLLER_PORT_SSH | 8022 | host-side port to exposed SSH server of container |
| CONTROLLER_DATA | ./kitodo/config_modules/metadata | data volume to mount |
| CONTROLLER_KEYS | ${PWD}/ocrd/controller/.ssh/authorized_keys | file with public ssh keys of users to login |
| CONTROLLER_DATA | ${PWD}/kitodo/data/metadata | data volume to mount |
| CONTROLLER_MODELS | ${PWD}/ocrd/controller/models | path to controller models |
| CONTROLLER_CONFIG | ${PWD}/ocrd/controller/config | path to controller config |
| CONTROLLER_WORKERS | 1 | count of workers for processing |

##### Manager

| Name | Default | Description
| --- | --- | --- |
| MANAGER_IMAGE | markusweigelt/ocrd_manager | name of image |
Expand All @@ -170,7 +176,9 @@ The following environment variables must be defined.
| MANAGER_ENV_GID | 1001 | group id of ssh user |
| MANAGER_ENV_UMASK | 0002 | ssh user specific permission mask |
| MANAGER_PORT_SSH | 9022 | host-side port to exposed SSH server of container |
| MANAGER_DATA | ./kitodo/config_modules/metadata | data volume to mount |
| MANAGER_KEYS | ${PWD}/ocrd/manager/.ssh/authorized_keys | file with public ssh keys of users to login |
| MANAGER_KEY | ${PWD}/ocrd/manager/.ssh/id_rsa | file with private ssh key of ocrd user to login to local (`managed`) or external Controller |
| MANAGER_DATA | ${PWD}/kitodo/data/metadata | data volume to mount |

(It is allowed and realistic if `MANAGER_DATA` is different than `CONTROLLER_DATA`.)

Expand All @@ -182,10 +190,29 @@ The following environment variables must be defined.
| MONITOR_HOST | ocrd-monitor | name of host |
| MONITOR_PORT_WEB | 5000 | host-side port to exposed Web server of container |
| MONITOR_PORT_GTK | 8085 | host-side port to exposed Broadwayd of container |
| MONITOR_DATA | ./kitodo/config_modules/metadata | data volume to mount |
| MONITOR_DATA | ${PWD}/kitodo/data/metadata | data volume to mount |

(Currently, `MONITOR_DATA` should be the same as `MANAGER_DATA`.)

##### Kitodo Resource Builder

| Name | Default | Description
| --- | --- | --- |
| BUILDER_TYPE | GIT | name of image |
| BUILDER_GIT_COMMIT | ocrd-main | branch "ocrd-main" of git repository |
| BUILDER_GIT_SOURCE_URL | https://github.com/markusweigelt/kitodo-production/ | repository of BUILDER_GIT_COMMIT |
| BUILDER_BUILD_RESOURCES | ${PWD}/_modules/kitodo-production-docker/kitodo/build-resources | directory path to resources for building Kitodo.Production image |

##### Kitodo Application

| Name | Default | Description
| --- | --- | --- |
| APP_BUILD_CONTEXT | ${PWD}/_modules/kitodo-production-docker/kitodo | directory of Dockerfile |
| APP_BUILD_RESOURCES | ${PWD}/_modules/kitodo-production-docker/kitodo | directory of build resources |
| APP_DATA | ${PWD}/kitodo/data | directory of application data e.g. config and modules |
| APP_KEY | ${PWD}/kitodo/.ssh/id_rsa | file with private ssh key of ocrd user to login to Manager |
| APP_PORT | 8080 | port of Kitodo.Production |

##### Use stable environment file

Docker Compose uses the `.env` file as default and thus the latest state of development.
Expand Down
2 changes: 1 addition & 1 deletion _modules/ocrd_controller
2 changes: 1 addition & 1 deletion _modules/ocrd_manager
Binary file not shown.
Loading