Skip to content

Commit

Permalink
Import on startup all files in /import
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmoore committed Jan 30, 2019
1 parent 2267456 commit e061111
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 99-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ set -eu

omero=/opt/omero/server/OMERO.server/bin/omero
cd /opt/omero/server
echo "Running importer in the background"
sh -c "/tools/wait-on-login && /tools/import-all" &
echo "Starting OMERO.server"
exec $omero admin start --foreground
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ RUN curl -L -o /usr/local/bin/dumb-init \
chmod +x /usr/local/bin/dumb-init
ADD entrypoint.sh /usr/local/bin/
ADD 50-config.py 60-database.sh 99-run.sh /startup/
ADD wait-on-login import-all /tools/
RUN mkdir /import && touch /import/test.fake

USER omero-server

Expand Down
33 changes: 33 additions & 0 deletions import-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python

import atexit
import os
import socket
import sys
import time


OMERO_DIST = os.environ.get("OMERO_DIST", "/opt/omero/server/OMERO.server")
if not os.path.exists(OMERO_DIST):
OMERO_DIST = "/opt/omero/web/OMERO.web"

sys.path.append("/".join([OMERO_DIST, "lib/python"]))
import omero
from omero.cli import cli_login
from omero.util.import_candidates import as_dictionary


OMERO_HOST = os.environ.get("OMERO_HOST", "localhost")
OMERO_USER = os.environ.get("OMERO_USER", "root")
OMERO_PASS = os.environ.get("OMERO_PASS", "omero")
OMERO_PORT = int(os.environ.get("OMERO_PORT", "4064"))
SLEEP_TIME = int(os.environ.get("SLEEP_TIME", "30"))


with cli_login("-s", OMERO_HOST,
"-u", OMERO_USER,
"-p", str(OMERO_PORT),
"-w", OMERO_PASS) as cli:

for k, v in as_dictionary(("/import",)).items():
cli.onecmd(["import", k])

0 comments on commit e061111

Please sign in to comment.