Skip to content

Commit e061111

Browse files
committed
Import on startup all files in /import
1 parent 2267456 commit e061111

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

99-run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ set -eu
44

55
omero=/opt/omero/server/OMERO.server/bin/omero
66
cd /opt/omero/server
7+
echo "Running importer in the background"
8+
sh -c "/tools/wait-on-login && /tools/import-all" &
79
echo "Starting OMERO.server"
810
exec $omero admin start --foreground

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ RUN curl -L -o /usr/local/bin/dumb-init \
2222
chmod +x /usr/local/bin/dumb-init
2323
ADD entrypoint.sh /usr/local/bin/
2424
ADD 50-config.py 60-database.sh 99-run.sh /startup/
25+
ADD wait-on-login import-all /tools/
26+
RUN mkdir /import && touch /import/test.fake
2527

2628
USER omero-server
2729

import-all

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
3+
import atexit
4+
import os
5+
import socket
6+
import sys
7+
import time
8+
9+
10+
OMERO_DIST = os.environ.get("OMERO_DIST", "/opt/omero/server/OMERO.server")
11+
if not os.path.exists(OMERO_DIST):
12+
OMERO_DIST = "/opt/omero/web/OMERO.web"
13+
14+
sys.path.append("/".join([OMERO_DIST, "lib/python"]))
15+
import omero
16+
from omero.cli import cli_login
17+
from omero.util.import_candidates import as_dictionary
18+
19+
20+
OMERO_HOST = os.environ.get("OMERO_HOST", "localhost")
21+
OMERO_USER = os.environ.get("OMERO_USER", "root")
22+
OMERO_PASS = os.environ.get("OMERO_PASS", "omero")
23+
OMERO_PORT = int(os.environ.get("OMERO_PORT", "4064"))
24+
SLEEP_TIME = int(os.environ.get("SLEEP_TIME", "30"))
25+
26+
27+
with cli_login("-s", OMERO_HOST,
28+
"-u", OMERO_USER,
29+
"-p", str(OMERO_PORT),
30+
"-w", OMERO_PASS) as cli:
31+
32+
for k, v in as_dictionary(("/import",)).items():
33+
cli.onecmd(["import", k])

0 commit comments

Comments
 (0)