-
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 all 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,26 @@ | ||
#!/usr/bin/env python | ||
# 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:] | ||
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,45 @@ | ||
#!/bin/bash | ||
# 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 | ||
|
||
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" | ||
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,8 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
omero=/opt/omero/server/OMERO.server/bin/omero | ||
cd /opt/omero/server | ||
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 entrypoint.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/entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
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 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 \ | ||
-e CONFIG_omero_db_pass=postgres \ | ||
-e CONFIG_omero_db_name=postgres \ | ||
-e ROOTPASS=omero-root-password \ | ||
-p 4063:4063 -p 4064:4064 \ | ||
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=`. | ||
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 files into `/opt/omero/server/config/`. | ||
Files will be loaded with `omero load`. | ||
For example: | ||
|
||
docker run -d -v | ||
/config/extra.omero:/opt/omero/server/config/extra.omero:ro | ||
openmicroscopy/omero-server | ||
|
||
Parameters required for initializing 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 | ||
|
||
|
||
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_ ...> | ||
-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` |
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.
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.
Does this need to be outside the if block?
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.
No,
CONFIG_omero_db_host
will already be converted intoomero.db.host
by50-config.py
- I'll update the comment at the top of the file. The only reason for special handling here is that the default ofomero.db.host=localhost
will never work, instead it defaults todb
which should be set bydocker run --link ...
.