From e9bbbccb582108aa5841fe9e8cec4420fcec9078 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Tue, 30 May 2017 12:16:55 +0100 Subject: [PATCH 01/17] Add /startup/ folder for executable startup scripts --- Dockerfile | 8 ++++++-- run-exec.sh | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 run-exec.sh diff --git a/Dockerfile b/Dockerfile index cf6a5310..2c06935b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,11 @@ RUN yum -y install epel-release \ ARG OMERO_VERSION=latest RUN ansible-playbook playbook.yml -e omero_server_release=$OMERO_VERSION +RUN mkdir /startup +ADD slave.cfg process_defaultxml.py /opt/omero/server/ +ADD run.sh /startup/ +ADD run-exec.sh / + USER omero-server # default.xml may be modified at runtime for a multinode configuration @@ -20,5 +25,4 @@ RUN cp /opt/omero/server/OMERO.server/etc/templates/grid/default.xml /opt/omero/ EXPOSE 4061 4063 4064 VOLUME ["/OMERO", "/opt/omero/server/OMERO.server/var"] -ADD slave.cfg run.sh process_defaultxml.py /opt/omero/server/ -ENTRYPOINT ["/opt/omero/server/run.sh"] +ENTRYPOINT ["/run-exec.sh"] diff --git a/run-exec.sh b/run-exec.sh new file mode 100755 index 00000000..9c96ccf5 --- /dev/null +++ b/run-exec.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +for f in /startup/*; do + if [ -f "$f" -a -x "$f" ]; then + "$f" "$@" + fi +done From cd6d1c4cbbe43eeed19fa91e22590a11d7c54409 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 13:58:48 +0100 Subject: [PATCH 02/17] Use dump-init --- Dockerfile | 8 +++++--- run-exec.sh | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2c06935b..23c5724e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,10 +12,12 @@ RUN yum -y install epel-release \ ARG OMERO_VERSION=latest RUN ansible-playbook playbook.yml -e omero_server_release=$OMERO_VERSION -RUN mkdir /startup +RUN curl -L -o /usr/local/bin/dumb-init \ + https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \ + chmod +x /usr/local/bin/dumb-init +ADD run-exec.sh /usr/local/bin/ ADD slave.cfg process_defaultxml.py /opt/omero/server/ ADD run.sh /startup/ -ADD run-exec.sh / USER omero-server @@ -25,4 +27,4 @@ RUN cp /opt/omero/server/OMERO.server/etc/templates/grid/default.xml /opt/omero/ EXPOSE 4061 4063 4064 VOLUME ["/OMERO", "/opt/omero/server/OMERO.server/var"] -ENTRYPOINT ["/run-exec.sh"] +ENTRYPOINT ["/usr/local/bin/run-exec.sh"] diff --git a/run-exec.sh b/run-exec.sh index 9c96ccf5..df34bc5d 100755 --- a/run-exec.sh +++ b/run-exec.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/local/bin/dumb-init /bin/bash set -e From f05009c55c66715476659df5a596bfb434ec2af5 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 14:08:35 +0100 Subject: [PATCH 03/17] Add 50-config.py, ensure 99-run.sh runs last --- 50-config.py | 19 +++++++++++++++++++ run.sh => 99-run.sh | 0 Dockerfile | 2 +- run-exec.sh | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 50-config.py rename run.sh => 99-run.sh (100%) diff --git a/50-config.py b/50-config.py new file mode 100755 index 00000000..723d03f2 --- /dev/null +++ b/50-config.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# Set omero config properties from CONFIG_ envvars +# Variable names should replace "." with "_" and "_" with "__" +# E.g. CONFIG_omero_web_public_enabled=false + +import os +from subprocess import call +from re import sub + + +for (k, v) in os.environ.iteritems(): + omero = '/opt/omero/server/OMERO.server/bin/omero' + if k.startswith('CONFIG_'): + prop = k[7:] + prop = sub('([^_])_([^_])', r'\1.\2', prop) + prop = sub('__', '_', prop) + value = v + rc = call([omero, 'config', 'set', '--', prop, value]) + assert rc == 0 diff --git a/run.sh b/99-run.sh similarity index 100% rename from run.sh rename to 99-run.sh diff --git a/Dockerfile b/Dockerfile index 23c5724e..6e339e09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN curl -L -o /usr/local/bin/dumb-init \ chmod +x /usr/local/bin/dumb-init ADD run-exec.sh /usr/local/bin/ ADD slave.cfg process_defaultxml.py /opt/omero/server/ -ADD run.sh /startup/ +ADD 50-config.py 99-run.sh /startup/ USER omero-server diff --git a/run-exec.sh b/run-exec.sh index df34bc5d..a1b37df2 100755 --- a/run-exec.sh +++ b/run-exec.sh @@ -4,6 +4,7 @@ set -e for f in /startup/*; do if [ -f "$f" -a -x "$f" ]; then + echo "Running $f $@" "$f" "$@" fi done From dfb8eb2e250de1e610552c29e41b58d3479a382b Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 15:08:48 +0100 Subject: [PATCH 04/17] Remove support for grid. Separate out db config script. --- 60-database.sh | 46 ++++++++++++++++++ 99-run.sh | 105 ++++-------------------------------------- Dockerfile | 8 +--- process_defaultxml.py | 73 ----------------------------- slave.cfg | 8 ---- 5 files changed, 56 insertions(+), 184 deletions(-) create mode 100755 60-database.sh delete mode 100755 process_defaultxml.py delete mode 100644 slave.cfg diff --git a/60-database.sh b/60-database.sh new file mode 100755 index 00000000..6a5d7f37 --- /dev/null +++ b/60-database.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -eu + +omero=/opt/omero/server/OMERO.server/bin/omero +cd /opt/omero/server + +DBHOST=${DBHOST:-} +if [ -z "$DBHOST" ]; then + DBHOST=db +fi +DBUSER=${DBUSER:-omero} +DBNAME=${DBNAME:-omero} +DBPASS=${DBPASS:-omero} +ROOTPASS=${ROOTPASS:-omero} + +export PGPASSWORD="$DBPASS" + +i=0 +while ! psql -h $DBHOST -U$DBUSER $DBNAME >/dev/null 2>&1 < /dev/null; do + i=$(($i+1)) + if [ $i -ge 50 ]; then + echo "$(date) - postgres:5432 still not reachable, giving up" + exit 1 + fi + echo "$(date) - waiting for postgres:5432..." + sleep 1 +done +echo "postgres connection established" + +psql -w -h $DBHOST -U$DBUSER $DBNAME -c \ + "select * from dbpatch" 2> /dev/null && { + echo "Upgrading database" + DBCMD=upgrade +} || { + echo "Initialising database" + DBCMD=init +} +/opt/omero/omego/bin/omego db $DBCMD \ + --dbhost "$DBHOST" --dbuser "$DBUSER" --dbname "$DBNAME" \ + --dbpass "$DBPASS" --rootpass "$ROOTPASS" --serverdir=OMERO.server + +$omero config set omero.db.host "$DBHOST" +$omero config set omero.db.user "$DBUSER" +$omero config set omero.db.name "$DBNAME" +$omero config set omero.db.pass "$DBPASS" diff --git a/99-run.sh b/99-run.sh index 365439d9..44667490 100755 --- a/99-run.sh +++ b/99-run.sh @@ -2,104 +2,15 @@ set -eu -TARGET=${1:-master} - -OMERO_SERVER=/opt/omero/server/OMERO.server -omero=$OMERO_SERVER/bin/omero +omero=/opt/omero/server/OMERO.server/bin/omero cd /opt/omero/server -if [ "$TARGET" = bash ]; then - echo "Entering a shell" - exec bash -l -elif [ "$TARGET" = master ]; then - # Remaining args are the servers to run, default (no args) is to run all - # on master - if [ $# -gt 1 ]; then - shift - ARGS="$@" - else - ARGS= - fi - ./process_defaultxml.py OMERO.server/etc/templates/grid/default.xml.orig \ - $ARGS > OMERO.server/etc/templates/grid/default.xml - - DBHOST=${DBHOST:-} - if [ -z "$DBHOST" ]; then - DBHOST=db - fi - DBUSER=${DBUSER:-omero} - DBNAME=${DBNAME:-omero} - DBPASS=${DBPASS:-omero} - ROOTPASS=${ROOTPASS:-omero} - MASTER_IP=$(hostname -i) - - export PGPASSWORD="$DBPASS" - - i=0 - while ! psql -h $DBHOST -U$DBUSER $DBNAME >/dev/null 2>&1 < /dev/null; do - i=$(($i+1)) - if [ $i -ge 50 ]; then - echo "$(date) - postgres:5432 still not reachable, giving up" - exit 1 - fi - echo "$(date) - waiting for postgres:5432..." - sleep 1 +if stat -t /config/* > /dev/null 2>&1; then + for f in /config/*; do + echo "Loading $f" + $omero load "$f" done - echo "postgres connection established" - - psql -w -h $DBHOST -U$DBUSER $DBNAME -c \ - "select * from dbpatch" 2> /dev/null && { - echo "Upgrading database" - DBCMD=upgrade - } || { - echo "Initialising database" - DBCMD=init - } - /opt/omero/omego/bin/omego db $DBCMD \ - --dbhost "$DBHOST" --dbuser "$DBUSER" --dbname "$DBNAME" \ - --dbpass "$DBPASS" --rootpass "$ROOTPASS" --serverdir=OMERO.server - - $omero config set omero.db.host "$DBHOST" - $omero config set omero.db.user "$DBUSER" - $omero config set omero.db.name "$DBNAME" - $omero config set omero.db.pass "$DBPASS" - - $omero config set omero.master.host "$MASTER_IP" - - if stat -t /config/* > /dev/null 2>&1; then - for f in /config/*; do - echo "Loading $f" - $omero load "$f" - done - fi - - echo "Starting $TARGET" - exec $omero admin start --foreground -else - MASTER_ADDR=${MASTER_ADDR:-} - if [ -z "$MASTER_ADDR" ]; then - MASTER_ADDR=master - fi - - SLAVE_ADDR=$(hostname -i) - - $omero config set omero.master.host "$MASTER_ADDR" - - if stat -t /config/* > /dev/null 2>&1; then - for f in /config/*; do - echo "Loading $f" - $omero load "$f" - done - fi - - echo "Master addr: $MASTER_ADDR Slave addr: $SLAVE_ADDR" - sed -e "s/@omero.slave.host@/$SLAVE_ADDR/" -e "s/@slave.name@/$TARGET/" \ - slave.cfg > OMERO.server/etc/$TARGET.cfg - grep '^Ice.Default.Router=' OMERO.server/etc/ice.config || \ - echo Ice.Default.Router= >> OMERO.server/etc/ice.config - sed -i -r "s|^(Ice.Default.Router=).*|\1OMERO.Glacier2/router:tcp -p 4063 -h $MASTER_ADDR|" \ - OMERO.server/etc/ice.config - - echo "Starting node $TARGET" - exec $omero node $TARGET start --foreground fi + +echo "Starting OMERO.server" +exec $omero admin start --foreground diff --git a/Dockerfile b/Dockerfile index 6e339e09..155101fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,15 +16,11 @@ RUN curl -L -o /usr/local/bin/dumb-init \ https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \ chmod +x /usr/local/bin/dumb-init ADD run-exec.sh /usr/local/bin/ -ADD slave.cfg process_defaultxml.py /opt/omero/server/ -ADD 50-config.py 99-run.sh /startup/ +ADD 50-config.py 60-database.sh 99-run.sh /startup/ USER omero-server -# default.xml may be modified at runtime for a multinode configuration -RUN cp /opt/omero/server/OMERO.server/etc/templates/grid/default.xml /opt/omero/server/OMERO.server/etc/templates/grid/default.xml.orig - -EXPOSE 4061 4063 4064 +EXPOSE 4063 4064 VOLUME ["/OMERO", "/opt/omero/server/OMERO.server/var"] ENTRYPOINT ["/usr/local/bin/run-exec.sh"] diff --git a/process_defaultxml.py b/process_defaultxml.py deleted file mode 100755 index 580370c9..00000000 --- a/process_defaultxml.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python - -""" -Convert the nodes and server-instances in default.xml to a multi-node -configuration - -The configuration string should be in the form node1:s1,s2,... node2:s3 ... - -Examples - -Everything on a single node (default, the same as passing no config): -master:Blitz-0,Indexer-0,DropBox,MonitorServer,FileServer,Storm,PixelData-0,Processor-0,Tables-0,TestDropBox - -Processor on a separate node: -master:Blitz-0,Indexer-0,DropBox,MonitorServer,FileServer,Storm,PixelData-0,Tables-0,TestDropBox slave:Processor-0 - -Two Processor and two PixelData on two separate nodes: -master:Blitz-0,Indexer-0,DropBox,MonitorServer,FileServer,Storm,Tables-0,TestDropBox slave-1:Processor-0,PixelData-0 slave-2:Processor-1,PixelData-1 -""" - - -import re -import sys - - -def getnodes(nodedescs): - nodes = {} - for nd in nodedescs: - s = '' - node, descs = nd.split(':') - descs = descs.split(',') - for d in descs: - try: - t, i = d.split('-') - except ValueError: - t = d - i = None - s += ' \s*\]*\>(.*?\)' -m = re.search(pattern, xml, re.DOTALL) -assert m - -nodedescs = sys.argv[2:] - -master = '\n \n' -slaves = '' -nodes = getnodes(nodedescs) -for nodename in sorted(nodes.keys()): - servers = nodes[nodename] - if nodename == 'master': - master = '%s%s' % (servers, master) - else: - slaves += ' \n%s \n' % (nodename, servers) - -if nodes: - xmlout = xml[:m.start(1)] + master + slaves + xml[m.end(1):] -else: - xmlout = xml -print xmlout diff --git a/slave.cfg b/slave.cfg deleted file mode 100644 index 3377eac0..00000000 --- a/slave.cfg +++ /dev/null @@ -1,8 +0,0 @@ -# OMERO slave configuration -IceGrid.Node.Endpoints=tcp -h @omero.slave.host@ -IceGrid.Node.Name=@slave.name@ -IceGrid.Node.Data=var/@slave.name@ -IceGrid.Node.Output=var/log - -Ice.StdOut=var/log/@slave.name@.out -Ice.StdErr=var/log/@slave.name@.err From 0e9d08b884dd48a815d4792c6d5f4f789166811b Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 15:09:38 +0100 Subject: [PATCH 05/17] Remove slave/grid from tests --- test.sh | 10 +++------- test_dropbox.sh | 4 ++-- test_login.sh | 2 +- test_processor.sh | 8 ++++---- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/test.sh b/test.sh index 1bc462b4..f2230112 100755 --- a/test.sh +++ b/test.sh @@ -9,7 +9,7 @@ IMAGE=omero-server:$PREFIX CLEAN=${CLEAN:-y} cleanup() { - docker rm -f -v $PREFIX-db $PREFIX-master $PREFIX-slave-1 + docker rm -f -v $PREFIX-db $PREFIX-server } if [ "$CLEAN" = y ]; then @@ -21,15 +21,11 @@ cleanup || true docker build -t $IMAGE . docker run -d --name $PREFIX-db -e POSTGRES_PASSWORD=postgres postgres -docker run -d --name $PREFIX-master --link $PREFIX-db:db \ +docker run -d --name $PREFIX-server --link $PREFIX-db:db \ -p 4063:4063 -p 4064:4064 \ -e DBUSER=postgres -e DBPASS=postgres -e DBNAME=postgres \ -e ROOTPASS=omero-root-password \ - $IMAGE master \ - master:Blitz-0,Indexer-0,DropBox,MonitorServer,FileServer,Storm,PixelData-0,Tables-0 \ - slave-1:Processor-0 - -docker run -d --name $PREFIX-slave-1 --link $PREFIX-master:master $IMAGE slave-1 + $IMAGE # Smoke tests diff --git a/test_dropbox.sh b/test_dropbox.sh index 60a36f47..41429044 100755 --- a/test_dropbox.sh +++ b/test_dropbox.sh @@ -9,7 +9,7 @@ set -x OMERO=/opt/omero/server/OMERO.server/bin/omero FILENAME=$(date +%Y%m%d-%H%M%S-%N).fake -docker exec $PREFIX-master sh -c \ +docker exec $PREFIX-server sh -c \ "mkdir -p /OMERO/DropBox/root && touch /OMERO/DropBox/root/$FILENAME" echo -n "Checking for imported DropBox image $FILENAME " @@ -18,7 +18,7 @@ i=0 result= while [ $i -lt 60 ]; do sleep 4 - result=$(docker exec $PREFIX-master $OMERO hql -q -s localhost -u $OMERO_USER -w $OMERO_PASS "SELECT COUNT (*) FROM Image WHERE name='$FILENAME'" --style plain) + result=$(docker exec $PREFIX-server $OMERO hql -q -s localhost -u $OMERO_USER -w $OMERO_PASS "SELECT COUNT (*) FROM Image WHERE name='$FILENAME'" --style plain) if [ "$result" = "0,1" ]; then echo echo "Found image: $result" diff --git a/test_login.sh b/test_login.sh index d3af1b46..4f086404 100755 --- a/test_login.sh +++ b/test_login.sh @@ -11,7 +11,7 @@ OMERO=/opt/omero/server/OMERO.server/bin/omero # Wait up to 2 mins i=0 -while ! docker exec test-master $OMERO login -C -s localhost -u "$OMERO_USER" -q -w "$OMERO_PASS"; do +while ! docker exec test-server $OMERO login -C -s localhost -u "$OMERO_USER" -q -w "$OMERO_PASS"; do i=$(($i+1)) if [ $i -ge 24 ]; then echo "$(date) - OMERO.server still not reachable, giving up" diff --git a/test_processor.sh b/test_processor.sh index 78e650e4..193af4f2 100755 --- a/test_processor.sh +++ b/test_processor.sh @@ -12,15 +12,15 @@ DSNAME=$(date +%Y%m%d-%H%M%S-%N) FILENAME=$(date +%Y%m%d-%H%M%S-%N).fake SCRIPT=/omero/util_scripts/Dataset_To_Plate.py -dataset_id=$(docker exec $PREFIX-master $OMERO obj -q -s localhost -u $OMERO_USER -w $OMERO_PASS new Dataset name=$DSNAME | cut -d: -f2) +dataset_id=$(docker exec $PREFIX-server $OMERO obj -q -s localhost -u $OMERO_USER -w $OMERO_PASS new Dataset name=$DSNAME | cut -d: -f2) -docker exec $PREFIX-master sh -c \ +docker exec $PREFIX-server sh -c \ "touch /tmp/$FILENAME && $OMERO import -d $dataset_id /tmp/$FILENAME" -docker exec $PREFIX-master $OMERO script launch $SCRIPT IDs=$dataset_id +docker exec $PREFIX-server $OMERO script launch $SCRIPT IDs=$dataset_id echo "Completed with code $?" -result=$(docker exec $PREFIX-master $OMERO hql -q -s localhost -u $OMERO_USER -w $OMERO_PASS "SELECT COUNT(w) FROM WellSample w WHERE w.well.plate.name='$DSNAME' AND w.image.name='$FILENAME'" --style plain) +result=$(docker exec $PREFIX-server $OMERO hql -q -s localhost -u $OMERO_USER -w $OMERO_PASS "SELECT COUNT(w) FROM WellSample w WHERE w.well.plate.name='$DSNAME' AND w.image.name='$FILENAME'" --style plain) if [ "$result" != "0,1" ]; then echo "Script failed: $result" exit 2 From d7bbf5af09ceae5b4681ada295b047e0be2eb73a Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 15:32:23 +0100 Subject: [PATCH 06/17] Set db params from CONFIG_omero_db_ --- 60-database.sh | 25 ++++++++++++------------- test.sh | 4 +++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/60-database.sh b/60-database.sh index 6a5d7f37..acdc4282 100755 --- a/60-database.sh +++ b/60-database.sh @@ -1,23 +1,27 @@ #!/bin/bash +# 50-config.py or equivalent must be run first to set omero.db.* set -eu omero=/opt/omero/server/OMERO.server/bin/omero cd /opt/omero/server -DBHOST=${DBHOST:-} -if [ -z "$DBHOST" ]; then +CONFIG_omero_db_host=${CONFIG_omero_db_host:-} +if [ -n "$CONFIG_omero_db_host" ]; then + DBHOST="$CONFIG_omero_db_host" +else DBHOST=db + $omero config set omero.db.host "$DBHOST" fi -DBUSER=${DBUSER:-omero} -DBNAME=${DBNAME:-omero} -DBPASS=${DBPASS:-omero} -ROOTPASS=${ROOTPASS:-omero} +DBUSER="${CONFIG_omero_db_user:-omero}" +DBNAME="${CONFIG_omero_db_name:-omero}" +DBPASS="${CONFIG_omero_db_pass:-omero}" +ROOTPASS="${ROOTPASS:-omero}" export PGPASSWORD="$DBPASS" i=0 -while ! psql -h $DBHOST -U$DBUSER $DBNAME >/dev/null 2>&1 < /dev/null; do +while ! psql -h "$DBHOST" -U "$DBUSER" "$DBNAME" >/dev/null 2>&1 < /dev/null; do i=$(($i+1)) if [ $i -ge 50 ]; then echo "$(date) - postgres:5432 still not reachable, giving up" @@ -28,7 +32,7 @@ while ! psql -h $DBHOST -U$DBUSER $DBNAME >/dev/null 2>&1 < /dev/null; do done echo "postgres connection established" -psql -w -h $DBHOST -U$DBUSER $DBNAME -c \ +psql -w -h "$DBHOST" -U "$DBUSER" "$DBNAME" -c \ "select * from dbpatch" 2> /dev/null && { echo "Upgrading database" DBCMD=upgrade @@ -39,8 +43,3 @@ psql -w -h $DBHOST -U$DBUSER $DBNAME -c \ /opt/omero/omego/bin/omego db $DBCMD \ --dbhost "$DBHOST" --dbuser "$DBUSER" --dbname "$DBNAME" \ --dbpass "$DBPASS" --rootpass "$ROOTPASS" --serverdir=OMERO.server - -$omero config set omero.db.host "$DBHOST" -$omero config set omero.db.user "$DBUSER" -$omero config set omero.db.name "$DBNAME" -$omero config set omero.db.pass "$DBPASS" diff --git a/test.sh b/test.sh index f2230112..052fe215 100755 --- a/test.sh +++ b/test.sh @@ -23,7 +23,9 @@ docker build -t $IMAGE . docker run -d --name $PREFIX-db -e POSTGRES_PASSWORD=postgres postgres docker run -d --name $PREFIX-server --link $PREFIX-db:db \ -p 4063:4063 -p 4064:4064 \ - -e DBUSER=postgres -e DBPASS=postgres -e DBNAME=postgres \ + -e CONFIG_omero_db_user=postgres \ + -e CONFIG_omero_db_pass=postgres \ + -e CONFIG_omero_db_name=postgres \ -e ROOTPASS=omero-root-password \ $IMAGE From cc58d70c1ac1541d7980dd48ec8818613051958a Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 15:54:07 +0100 Subject: [PATCH 07/17] Use db config from omero when runnign omego --- 60-database.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/60-database.sh b/60-database.sh index acdc4282..e2e10f0b 100755 --- a/60-database.sh +++ b/60-database.sh @@ -4,6 +4,7 @@ set -eu omero=/opt/omero/server/OMERO.server/bin/omero +omego=/opt/omero/omego/bin/omego cd /opt/omero/server CONFIG_omero_db_host=${CONFIG_omero_db_host:-} @@ -35,11 +36,8 @@ echo "postgres connection established" psql -w -h "$DBHOST" -U "$DBUSER" "$DBNAME" -c \ "select * from dbpatch" 2> /dev/null && { echo "Upgrading database" - DBCMD=upgrade + $omego db upgrade --serverdir=OMERO.server } || { echo "Initialising database" - DBCMD=init + $omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server } -/opt/omero/omego/bin/omego db $DBCMD \ - --dbhost "$DBHOST" --dbuser "$DBUSER" --dbname "$DBNAME" \ - --dbpass "$DBPASS" --rootpass "$ROOTPASS" --serverdir=OMERO.server From 1cf0093d5264a8f5e945f7477bb7bc8560a38a0f Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 15:55:07 +0100 Subject: [PATCH 08/17] Add README back again --- README.md | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..44d7135e --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +OMERO.server Docker +=================== + +A CentOS 7 based Docker iamge for OMERO.server. + + +Running the images +------------------ + +To run the Docker images start a postgres DB: + + docker run -d --name postgres -e POSTGRES_PASSWORD=postgres postgres + +Then run OMERO.server passing the the database configuration parameters if they differ from the defaults: + + docker run -d --name omero-server --link postgres:db + -e CONFIG_omero_db_user=postgres \ + -e CONFIG_omero_db_pass=postgres \ + -e CONFIG_omero_db_name=postgres \ + -e ROOTPASS=omero-root-password \ + -e DBUSER=postgres \ + -p 4063:4063 -p 4064:4064 \ + -e ROOTPASS=omero openmicroscopy/omero-server + + +Configuration variables +----------------------- + +All [OMERO configuration properties](www.openmicroscopy.org/site/support/omero/sysadmins/config.html) can be set be defining environment variables `CONFIG_omero_property_name=` where `.` is replaced by `_` and `_` by `__`, for example + + -e CONFIG_omero_web_public_enabled=false + + +Configuration files +------------------- + +Additional configuration files for OMERO can be provided by mounting a directory `/config` inside any of the containers. +Files will be loaded with `omero load`. +For example: + + docker run -d -v /config:/config:ro openmicroscopy/omero-server + +Parameters required for initialising the server such as database configuration *must* be set using environment variables. + + +Default volumes +--------------- + +- `/opt/omero/server/OMERO.server/var`: The OMERO.server `var` directory, including logs +- `/OMERO`: The OMERO data directory (`omero-grid` only) + + +Exposed ports +------------- + +- 4063 +- 4064 + + +Example with named volumes +-------------------------- + + docker volume create --name omero-db + docker volume create --name omero-data + + docker run -d --name postgres -e POSTGRES_PASSWORD=postgres \ + -v omero-db:/var/lib/postgresql/data postgres + docker run -d --name omero-server --link postgres:db + -e CONFIG_omero_db_pass=dbpassword -v omero-data:/OMERO \ + -p 4063:4063 -p 4064:4064 openmicroscopy/omero-server + + +Running without links +--------------------- + +As an alternative to running with `--link` the address of the database can be specified using the variable `CONFIG_omero_db_host` From 307ace275b96a4ea72fb22a895b3aff15209bdb2 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 5 Jun 2017 17:55:16 +0100 Subject: [PATCH 09/17] Fix errors in README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 44d7135e..4da46b38 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ OMERO.server Docker =================== -A CentOS 7 based Docker iamge for OMERO.server. +A CentOS 7 based Docker image for OMERO.server. Running the images @@ -18,7 +18,6 @@ Then run OMERO.server passing the the database configuration parameters if they -e CONFIG_omero_db_pass=postgres \ -e CONFIG_omero_db_name=postgres \ -e ROOTPASS=omero-root-password \ - -e DBUSER=postgres \ -p 4063:4063 -p 4064:4064 \ -e ROOTPASS=omero openmicroscopy/omero-server @@ -26,7 +25,8 @@ Then run OMERO.server passing the the database configuration parameters if they Configuration variables ----------------------- -All [OMERO configuration properties](www.openmicroscopy.org/site/support/omero/sysadmins/config.html) can be set be defining environment variables `CONFIG_omero_property_name=` where `.` is replaced by `_` and `_` by `__`, for example +All [OMERO configuration properties](www.openmicroscopy.org/site/support/omero/sysadmins/config.html) can be set be defining environment variables `CONFIG_omero_property_name=`. +Since `.` is not allowed in a variable name `.` must be replaced by `_`, and `_` by `__`, for example -e CONFIG_omero_web_public_enabled=false @@ -34,7 +34,7 @@ All [OMERO configuration properties](www.openmicroscopy.org/site/support/omero/s Configuration files ------------------- -Additional configuration files for OMERO can be provided by mounting a directory `/config` inside any of the containers. +Additional configuration files for OMERO can be provided by mounting a directory `/config`. Files will be loaded with `omero load`. For example: @@ -47,7 +47,7 @@ Default volumes --------------- - `/opt/omero/server/OMERO.server/var`: The OMERO.server `var` directory, including logs -- `/OMERO`: The OMERO data directory (`omero-grid` only) +- `/OMERO`: The OMERO data directory Exposed ports From 4c594444012d5f10eed32bad84336f96f158c5d9 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Tue, 6 Jun 2017 14:50:15 +0100 Subject: [PATCH 10/17] Rename run-exec.sh entrypoint.sh --- Dockerfile | 4 ++-- run-exec.sh => entrypoint.sh | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename run-exec.sh => entrypoint.sh (100%) diff --git a/Dockerfile b/Dockerfile index 155101fe..bdbad5b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN ansible-playbook playbook.yml -e omero_server_release=$OMERO_VERSION RUN curl -L -o /usr/local/bin/dumb-init \ https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && \ chmod +x /usr/local/bin/dumb-init -ADD run-exec.sh /usr/local/bin/ +ADD entrypoint.sh /usr/local/bin/ ADD 50-config.py 60-database.sh 99-run.sh /startup/ USER omero-server @@ -23,4 +23,4 @@ USER omero-server EXPOSE 4063 4064 VOLUME ["/OMERO", "/opt/omero/server/OMERO.server/var"] -ENTRYPOINT ["/usr/local/bin/run-exec.sh"] +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/run-exec.sh b/entrypoint.sh similarity index 100% rename from run-exec.sh rename to entrypoint.sh From a0a0edd1a62d6487660beeaf5eb272cf2e410fc7 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Tue, 6 Jun 2017 14:50:38 +0100 Subject: [PATCH 11/17] Move constant out of loop in 50-config.py --- 50-config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/50-config.py b/50-config.py index 723d03f2..0d4f86ff 100755 --- a/50-config.py +++ b/50-config.py @@ -8,12 +8,13 @@ from re import sub +OMERO = '/opt/omero/server/OMERO.server/bin/omero' + for (k, v) in os.environ.iteritems(): - omero = '/opt/omero/server/OMERO.server/bin/omero' if k.startswith('CONFIG_'): prop = k[7:] prop = sub('([^_])_([^_])', r'\1.\2', prop) prop = sub('__', '_', prop) value = v - rc = call([omero, 'config', 'set', '--', prop, value]) + rc = call([OMERO, 'config', 'set', '--', prop, value]) assert rc == 0 From 6f3b08eddc33eb835da690dcb65632510818930a Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 8 Jun 2017 11:10:11 +0100 Subject: [PATCH 12/17] Improve comments --- 60-database.sh | 4 +++- README.md | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/60-database.sh b/60-database.sh index e2e10f0b..076c153a 100755 --- a/60-database.sh +++ b/60-database.sh @@ -1,5 +1,7 @@ #!/bin/bash -# 50-config.py or equivalent must be run first to set omero.db.* +# 50-config.py or equivalent must be run first to set all omero.db.* +# omero.db.host may require special handling since the default is +# to use `--link postgres:db` set -eu diff --git a/README.md b/README.md index 4da46b38..eb0ed5c9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ To run the Docker images start a postgres DB: docker run -d --name postgres -e POSTGRES_PASSWORD=postgres postgres -Then run OMERO.server passing the the database configuration parameters if they differ from the defaults: +Then run OMERO.server passing the database configuration parameters if they differ from the defaults. +This example uses the default `postgres` system database for convenience, in practice you may want to create your own database. docker run -d --name omero-server --link postgres:db -e CONFIG_omero_db_user=postgres \ @@ -19,7 +20,7 @@ Then run OMERO.server passing the the database configuration parameters if they -e CONFIG_omero_db_name=postgres \ -e ROOTPASS=omero-root-password \ -p 4063:4063 -p 4064:4064 \ - -e ROOTPASS=omero openmicroscopy/omero-server + openmicroscopy/omero-server Configuration variables @@ -63,10 +64,11 @@ Example with named volumes docker volume create --name omero-db docker volume create --name omero-data - docker run -d --name postgres -e POSTGRES_PASSWORD=postgres \ + docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -v omero-db:/var/lib/postgresql/data postgres docker run -d --name omero-server --link postgres:db - -e CONFIG_omero_db_pass=dbpassword -v omero-data:/OMERO \ + <-e CONFIG_omero_db_ ...> + -v omero-data:/OMERO -p 4063:4063 -p 4064:4064 openmicroscopy/omero-server From d7c74ef8a963112ff4b5b233e850aa04b9365837 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 8 Jun 2017 11:30:21 +0100 Subject: [PATCH 13/17] Use standard /opt/omero/server/config instead of /config --- 50-config.py | 12 +++++++++--- README.md | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/50-config.py b/50-config.py index 0d4f86ff..6a526777 100755 --- a/50-config.py +++ b/50-config.py @@ -1,15 +1,21 @@ #!/usr/bin/env python -# Set omero config properties from CONFIG_ envvars -# Variable names should replace "." with "_" and "_" with "__" -# E.g. CONFIG_omero_web_public_enabled=false +# 1. Run .omero files from /opt/omero/server/config/ +# 2. Set omero config properties from CONFIG_ envvars +# Variable names should replace "." with "_" and "_" with "__" +# E.g. CONFIG_omero_web_public_enabled=false import os from subprocess import call from re import sub +CONFIG_OMERO = '/opt/omero/server/config/omero-server-config-update.sh' OMERO = '/opt/omero/server/OMERO.server/bin/omero' +if os.access(CONFIG_OMERO, os.X_OK): + rc = call([CONFIG_OMERO]) + assert rc == 0 + for (k, v) in os.environ.iteritems(): if k.startswith('CONFIG_'): prop = k[7:] diff --git a/README.md b/README.md index eb0ed5c9..ebeceef2 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,13 @@ Since `.` is not allowed in a variable name `.` must be replaced by `_`, and `_` Configuration files ------------------- -Additional configuration files for OMERO can be provided by mounting a directory `/config`. +Additional configuration files for OMERO can be provided by mounting files into `/opt/omero/server/config/`. Files will be loaded with `omero load`. For example: - docker run -d -v /config:/config:ro openmicroscopy/omero-server + docker run -d -v + /config/extra.omero:/opt/omero/server/config/extra.omero:ro + openmicroscopy/omero-server Parameters required for initialising the server such as database configuration *must* be set using environment variables. From 24a577eae0e18ff99e1ea475b9450970f38d2b04 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 8 Jun 2017 11:35:33 +0100 Subject: [PATCH 14/17] Remove processing of /config/*.omero --- 99-run.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/99-run.sh b/99-run.sh index 44667490..ec83b891 100755 --- a/99-run.sh +++ b/99-run.sh @@ -4,13 +4,5 @@ set -eu omero=/opt/omero/server/OMERO.server/bin/omero cd /opt/omero/server - -if stat -t /config/* > /dev/null 2>&1; then - for f in /config/*; do - echo "Loading $f" - $omero load "$f" - done -fi - echo "Starting OMERO.server" exec $omero admin start --foreground From 7c3c12b200fbce745bd7f28181ebf030e321be67 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 3 Jul 2017 11:55:40 +0100 Subject: [PATCH 15/17] Update requirements --- playbook.yml | 4 ++++ requirements.yml | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/playbook.yml b/playbook.yml index 03188f0b..5155f9eb 100644 --- a/playbook.yml +++ b/playbook.yml @@ -3,5 +3,9 @@ - role: openmicroscopy.omero-server vars: ice_version: "3.6" + ice_install_devel: False omero_server_database_manage: False omero_server_systemd_setup: False + # You can reduce the size of the image by providing the URL to a + # precompiled Ice Python wheel + #ice_python_wheel: diff --git a/requirements.yml b/requirements.yml index 44390aa6..f3129664 100644 --- a/requirements.yml +++ b/requirements.yml @@ -4,10 +4,10 @@ version: 1.0.0 - src: openmicroscopy.ice - version: 2.0.0 + version: 2.1.0 - src: openmicroscopy.java - version: 2.0.0 + version: 2.0.1 - src: openmicroscopy.omego version: 0.1.0 @@ -18,9 +18,8 @@ - src: openmicroscopy.omero-python-deps version: 1.1.0 -- name: openmicroscopy.omero-server -# version: 2.0.0-m1 - src: https://github.com/manics/ansible-role-omero-server/archive/devel.tar.gz +- src: openmicroscopy.omero-server + version: 2.0.0-m2 - src: openmicroscopy.postgresql version: 2.0.0 From 15eb3864e537c02d1a0e48506705b6fe416918f8 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Tue, 4 Jul 2017 15:31:42 +0100 Subject: [PATCH 16/17] Use a fixed UID (1000) for omero-server --- playbook.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/playbook.yml b/playbook.yml index 5155f9eb..f4823e29 100644 --- a/playbook.yml +++ b/playbook.yml @@ -6,6 +6,7 @@ ice_install_devel: False omero_server_database_manage: False omero_server_systemd_setup: False + omero_server_system_uid: 1000 # You can reduce the size of the image by providing the URL to a # precompiled Ice Python wheel #ice_python_wheel: From 73b3a9caf082f66b300478194330d31d2d8e9595 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 13 Jul 2017 09:56:14 +0100 Subject: [PATCH 17/17] Use US spelling in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ebeceef2..9c44f0b5 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ For example: /config/extra.omero:/opt/omero/server/config/extra.omero:ro openmicroscopy/omero-server -Parameters required for initialising the server such as database configuration *must* be set using environment variables. +Parameters required for initializing the server such as database configuration *must* be set using environment variables. Default volumes