-
Notifications
You must be signed in to change notification settings - Fork 27
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
Refactor startup scripts, envvars for all omero parameter #1
Changes from 9 commits
e9bbbcc
cd6d1c4
f05009c
dfb8eb2
0e9d08b
d7bbf5a
cc58d70
1cf0093
307ace2
4c59444
a0a0edd
6f3b08e
d7c74ef
24a577e
7c3c12b
15eb386
73b3a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need not be in loop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and probably should be caps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/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 | ||
omego=/opt/omero/omego/bin/omego | ||
cd /opt/omero/server | ||
|
||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to be outside the if block? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, |
||
fi | ||
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 | ||
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" | ||
$omego db upgrade --serverdir=OMERO.server | ||
} || { | ||
echo "Initialising database" | ||
$omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,15 @@ RUN yum -y install epel-release \ | |
ARG OMERO_VERSION=latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're using the main release version (i.e.
Note: this doesn't yet give us a strategy for breaking changes in the image itself There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming this has everyone's implicit 👍 but now with 5.4 replacing 5.3 |
||
RUN ansible-playbook playbook.yml -e omero_server_release=$OMERO_VERSION | ||
|
||
USER omero-server | ||
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 50-config.py 60-database.sh 99-run.sh /startup/ | ||
|
||
# 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 | ||
USER omero-server | ||
|
||
EXPOSE 4061 4063 4064 | ||
EXPOSE 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 ["/usr/local/bin/run-exec.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
OMERO.server Docker | ||
=================== | ||
|
||
A CentOS 7 based Docker image 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 \ | ||
-p 4063:4063 -p 4064:4064 \ | ||
-e ROOTPASS=omero openmicroscopy/omero-server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ROOTPASS twice? |
||
|
||
|
||
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=`. | ||
Since `.` is not allowed in a variable name `.` must be 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`. | ||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initializing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
|
||
|
||
Default volumes | ||
--------------- | ||
|
||
- `/opt/omero/server/OMERO.server/var`: The OMERO.server `var` directory, including logs | ||
- `/OMERO`: The OMERO data directory | ||
|
||
|
||
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 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example isn't working for me:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to repeat all the |
||
-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` |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/local/bin/dumb-init /bin/bash | ||
|
||
set -e | ||
|
||
for f in /startup/*; do | ||
if [ -f "$f" -a -x "$f" ]; then | ||
echo "Running $f $@" | ||
"$f" "$@" | ||
fi | ||
done |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not particularly worried but there's obviously some danger of a
__
conflict here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know. Do you have another suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how evil this is but:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortuntately it's also used in the bash script
60-database.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuing discussion under #3