Skip to content
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

Auto import, figure, wheel, etc. #21

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REPO=test
PREFIX=test
TCP_PORT=
SSL_PORT=4064:
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM centos:centos7
ARG CREATED=unknown
ARG REVISION=unknown
LABEL maintainer="[email protected]"
LABEL org.opencontainers.image.created="unknown"
LABEL org.opencontainers.image.revision="unknown"
LABEL org.opencontainers.image.source="https://github.com/openmicroscopy/omero-server-docker"
LABEL org.opencontainers.image.created="${CREATED}"
LABEL org.opencontainers.image.revision="${REVISION}"
LABEL org.opencontainers.image.source="https://github.com/ome/omero-server-docker"

RUN mkdir /opt/setup
WORKDIR /opt/setup
Expand Down
54 changes: 54 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: "3.3"
#
# Compose for the development of this docker image
#
services:
database:
image: "postgres:9.6"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be moved to 10?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, definitely. I'd suggest handling that across all repositories once the upgrade docs are in place.

environment:
- POSTGRES_USER=omero
- POSTGRES_DB=omero
- POSTGRES_PASSWORD=omero
networks:
- omero
volumes:
- "database:/var/lib/postgresql/data"

minimal:
image: ${REPO}/omero-server-minimal:${PREFIX}
build:
context: .
args:
- OMEGO_ADDITIONAL_ARGS="--ci=https://merge-ci.openmicroscopy.org/jenkins/"
- OMERO_VERSION="OMERO-build"
entrypoint: "true"

omero:
image: ${REPO}/omero-server:${PREFIX}
build:
context: extended
args:
- PARENT_IMAGE=${REPO}/omero-server-minimal:${PREFIX}
environment:
- CONFIG_omero_db_host=database
- CONFIG_omero_db_user=omero
- CONFIG_omero_db_pass=omero
- CONFIG_omero_db_name=omero
- ROOTPASS=omero
networks:
- omero
ports:
- "${TCP_PORT}4063"
- "${SSL_PORT}4064"
volumes:
- "omero:/OMERO"
- "./:/src:ro"
depends_on:
- minimal

networks:
omero:

volumes:
database:
omero:
10 changes: 10 additions & 0 deletions extended/95-background.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does 95 mean in the name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the startup scripts are numbered to be run in order. "95" means "pretty close to the end but give the user a few slots (96-98) before the final script (99) runs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks
since I noticed the pg version, for a minute I thought it was a pg matching version but the file was nothing to do with pg


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
8 changes: 8 additions & 0 deletions extended/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG PARENT_IMAGE=openmicroscopy/omero-server-minimal:latest
FROM ${PARENT_IMAGE}

USER root
ADD wait-on-login import-all /tools/
ADD 95-background.sh /startup/
RUN mkdir /import && touch /import/test.fake
USER omero-server
33 changes: 33 additions & 0 deletions extended/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])
60 changes: 60 additions & 0 deletions extended/wait-on-login
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/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

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"))


def end():
print "travis_fold:end:wait-on-login"

atexit.register(end)

print "travis_fold:start:wait-on-login"


def port_is_open():
rc = socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((OMERO_HOST, OMERO_PORT))
return (rc == 0)


for x in range(1, 31):
if port_is_open():
break
else:
time.sleep(1.0)
print "waiting on port: #%s" % x


# HACK: This 'ready' detection is still not working. Adding a hard sleep to be safe.
print "Sleeping for", SLEEP_TIME
time.sleep(SLEEP_TIME)

# Second: try to login
for x in range(1, 6):
# https://trello.com/c/rPstbt4z/216-open-ssl-110
client = omero.client(OMERO_HOST, OMERO_PORT)
try:
client.createSession(OMERO_USER, OMERO_PASS)
break
except:
print "Login attempt %s failed. Trying again in %s seconds" % (x, x+1)
time.sleep(x+1)
finally:
client.__del__()
34 changes: 31 additions & 3 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,37 @@
vars:
ice_version: "3.6"
ice_install_devel: False
ice_python_wheel: https://github.com/ome/zeroc-ice-py-centos7/releases/download/0.1.0/zeroc_ice-3.6.4-cp27-cp27mu-linux_x86_64.whl
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:

# TODO: copied from https://github.com/openmicroscopy/prod-playbooks/blob/bd5b837c740ae79806d911893ace38701c204381/ome-dundeeomero.yml
# Should be part of a figure-server role
tasks:
- name: OMERO.figure server-side prerequisites, script prerequisites + web server for decoupled OMERO.web
become: yes
yum:
name: "{{ item }}"
state: present
with_items:
- python-reportlab
- python-markdown

- name: Create a figure scripts directory
become: yes
file:
path: /opt/omero/server/OMERO.server/lib/scripts/omero/figure_scripts
state: directory
mode: 0755
recurse: yes
owner: root

- name: Download the Figure_To_Pdf.py script
become: yes
get_url:
url: https://raw.githubusercontent.com/ome/omero-figure/{{ omero_figure_tag | default("master") }}/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py
dest: /opt/omero/server/OMERO.server/lib/scripts/omero/figure_scripts/Figure_To_Pdf.py
mode: 0644
owner: root
checksum: "{{ omero_figure_pdfscript_checksum | default(omit) }}"