Skip to content

Instantly share code, notes, and snippets.

@dpwrussell
Last active January 12, 2022 22:02
Show Gist options
  • Save dpwrussell/05d7016e6e03cd1503a3fae65c9cab62 to your computer and use it in GitHub Desktop.
Save dpwrussell/05d7016e6e03cd1503a3fae65c9cab62 to your computer and use it in GitHub Desktop.
*.sql
*.p12
*.key
*.pem
*.crt
*.jks
.env

RO OMERO ignored data.dir change

These instructions create an OMERO instance, then demonstrate how data.dir is ignored when starting up in RO data directory mode.

Note: Initially I was dumping the database before shutting down the stack, then loading it again in during database initialisation, but this proved to be irrelevant so I have simplified the example to remove these steps.

Initialise the OMERO instance and import an image for good measure

# New instance initalised 
docker-compose up -d

# Import an image
docker exec -it omero-docker_omeroserver_1 /omero-import-example.sh WwDgVUQ489LnPF

# Shutdown the stack
docker-compose down

Modify the compose

Modify the Docker compose file to replace all references to /OMERO.old with /OMERO.new.

Switch to OMERO RO data directory mode by commenting in these lines:

      CONFIG_omero_cluster_read__only.db: "false"
      CONFIG_omero_cluster_read__only.repo: "true"
      CONFIG_omero_pixeldata_memoizer_dir_local: "/tmp/BioFormatsCache"

Examine the result

# Start up the stack
docker-compose up -d

# Examine the repos
docker exec -it omero-docker_omeroserver_1 \
    /opt/omero/server/OMERO.server/bin/omero \
    -s localhost -u root -w WwDgVUQ489LnPF fs repos

The data.dir setting is not respected and remains /OMERO.old.

Created session for root@localhost:4064. Idle timeout: 10 min. Current group: system
 # | Id | UUID                                 | Type    | Path
---+----+--------------------------------------+---------+-------------------------------------------------------------
 0 | 58 | 46033d9c-bc2b-44d1-93a9-ab87b398bce2 | Public  | /OMERO.old
 1 | 59 | ScriptRepo                           | Script  | /opt/omero/server/OMERO.server-5.6.3-ice36-b228/lib/scripts
 2 | 60 | 335c6801-381e-4bc7-8c0d-177e55d23f7e | Managed | /OMERO.old/ManagedRepositor

This is in contrast to if the data.dir setting is changed, but RO mode is not set; in that scenario, the repo correctly updates.

version: "3.2"
services:
database:
image: "postgres:11"
environment:
POSTGRES_PASSWORD: FHfrByL5rXH7ZT
POSTGRES_OMERO_PASSWORD: tyg9woVsv75F9M
networks:
- omero
volumes:
- "database:/var/lib/postgresql/data"
- "./init-omero-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh:ro"
# It is necessart to intialise the var volume to be owned by 9798:9798 or
# else it is not writeable in the omeroserver container
omeroserver-init:
image: ubuntu
command: sh -c "chown 9798:9798 /omero_var && chown 9798:9798 /OMERO.old"
volumes:
- "omeroserver_var:/omero_var"
- "omero:/OMERO.old"
omeroserver:
# Use a build to align the omero-server user with the omero network user
build:
context: .
args:
OMERO_UID: 9798
OMERO_GID: 9798
environment:
ROOTPASS: WwDgVUQ489LnPF
CONFIG_omero_db_host: database
CONFIG_omero_db_name: omerodb
# Workaround problem with /omero/tmp not being write-lockable ?
# TODO Is this read-only OMERO specific?
OMERO_TMPDIR: /tmp
# RW Database
CONFIG_omero_db_user: omerouser
CONFIG_omero_db_pass: tyg9woVsv75F9M
# Repository management
CONFIG_omero_data_dir: "/OMERO.old"
# Read-only configuration
# CONFIG_omero_cluster_read__only.db: "false"
# CONFIG_omero_cluster_read__only.repo: "true"
# CONFIG_omero_pixeldata_memoizer_dir_local: "/tmp/BioFormatsCache"
networks:
- omero
ports:
- "4063:4063"
- "4064:4064"
volumes:
- "omero:/OMERO.old"
# OMERO var must be mounted as the original Dockerfile specified this as a volume
# when the USER was omero-server with the old uid/gid, which are then inherited
# by this var. If it isn't mounted, then there is no way to chown it as root
# using an init container.
- "omeroserver_var:/opt/omero/server/OMERO.server/var"
# Example image to import
- "./example.png:/example.png:ro"
- "./omero-import-example.sh:/omero-import-example.sh:ro"
depends_on:
omeroserver-init:
condition: service_completed_successfully
healthcheck:
test: ["CMD-SHELL", "/opt/omero/server/OMERO.server/bin/omero node status || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
omeroweb:
# This container uses the tag for the latest web release of OMERO 5
# To upgrade to the next major release, increment the major version number
image: "openmicroscopy/omero-web-standalone:5"
environment:
CONFIG_omero_web_server__list: '[["omeroserver", 4064, "omero"]]'
networks:
- omero
ports:
- "4080:4080"
depends_on:
omeroserver:
condition: service_healthy
networks:
omero:
volumes:
database:
omeroserver_var:
omero:
FROM openmicroscopy/omero-server:5
USER root
ARG OMERO_UID
ARG OMERO_GID
COPY fix-perms /usr/bin/fix-perms
RUN fix-perms
USER omero-server
#!/usr/bin/env bash
set -ex
OLD_UID=$(getent passwd omero-server | cut -f3 -d:)
OLD_GID=$(getent group omero-server | cut -f3 -d:)
usermod -u "${OMERO_UID}" omero-server
groupmod -g "${OMERO_GID}" omero-server
find / -xdev -user ${OLD_UID} -print -exec chown "${OMERO_UID}" -h {} \;
find / -xdev -group "${OLD_GID}" -print -exec chgrp "${OMERO_GID}" -h {} \;
#!/usr/bin/env bash
set -ex
# Create omerodb and omerouser
psql -v ON_ERROR_STOP=1 --username postgres <<-EOSQL
CREATE DATABASE omerodb;
CREATE USER omerouser WITH PASSWORD '${POSTGRES_OMERO_PASSWORD}';
GRANT ALL PRIVILEGES ON DATABASE omerodb TO omerouser;
EOSQL
#!/usr/bin/env bash
OMERO="/opt/omero/server/OMERO.server/bin/omero"
${OMERO} -s localhost -u root -w ${1} import /example.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment