Skip to content

Commit

Permalink
migrate from galaxy-central to "galaxy"
Browse files Browse the repository at this point in the history
  • Loading branch information
bgruening committed Nov 9, 2024
1 parent 11dc49f commit 3b9f9a0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.
6 changes: 3 additions & 3 deletions galaxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Galaxy - Stable
#
# VERSION Galaxy-central
# VERSION Galaxy in Docker

# TODO
#
Expand All @@ -11,7 +11,7 @@

FROM buildpack-deps:22.04 AS build_base

ENV GALAXY_ROOT_DIR=/galaxy-central \
ENV GALAXY_ROOT_DIR=/galaxy \
GALAXY_VIRTUAL_ENV=/galaxy_venv \
GALAXY_HOME=/home/galaxy \
GALAXY_CONDA_PREFIX=/tool_deps/_conda \
Expand Down Expand Up @@ -63,7 +63,7 @@ RUN mkdir $GALAXY_ROOT_DIR $GALAXY_VIRTUAL_ENV \

FROM ubuntu:22.04 AS galaxy_cluster_base

ENV GALAXY_ROOT_DIR=/galaxy-central \
ENV GALAXY_ROOT_DIR=/galaxy \
GALAXY_VIRTUAL_ENV=/galaxy_venv \
GALAXY_LOGS_DIR=/home/galaxy/logs \
GALAXY_CONFIG_DIR=/etc/galaxy \
Expand Down
58 changes: 30 additions & 28 deletions galaxy/ansible/templates/export_user_files.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ import os
import shutil
import subprocess

PG_VERSION = os.environ.get('PG_VERSION', '15')
GALAXY_UID = int(os.environ['GALAXY_UID'])
GALAXY_GID = int(os.environ['GALAXY_GID'])
GALAXY_ROOT_DIR = os.environ.get('GALAXY_ROOT_DIR', '/galaxy/')

if len( sys.argv ) == 2:
PG_DATA_DIR_DEFAULT = sys.argv[1]
else:
PG_DATA_DIR_DEFAULT = "/var/lib/postgresql/15/main"
PG_DATA_DIR_HOST = os.environ.get("PG_DATA_DIR_HOST", "/export/postgresql/15/main/")
PG_DATA_DIR_DEFAULT = f"/var/lib/postgresql/{PG_VERSION}/main"
PG_DATA_DIR_HOST = os.environ.get("PG_DATA_DIR_HOST", f"/export/postgresql/{PG_VERSION}/main/")

def change_path( src ):
"""
Expand All @@ -25,8 +30,8 @@ def change_path( src ):
os.makedirs(dest_dir)
shutil.move( src, dest )
os.symlink( dest, src.rstrip('/') )
os.chown( src, int(os.environ['GALAXY_UID']), int(os.environ['GALAXY_GID']) )
subprocess.call( 'chown -R %s:%s %s' % ( os.environ['GALAXY_UID'], os.environ['GALAXY_GID'], dest ), shell=True )
os.chown( src, GALAXY_UID, GALAXY_GID )
subprocess.call( f'chown -R {GALAXY_UID}:{GALAXY_GID} {dest}', shell=True )
# if destination exists (e.g. continuing a previous session), remove source and symlink
else:
if not os.path.realpath( src ) == os.path.realpath( dest ):
Expand All @@ -46,13 +51,13 @@ def copy_samples(src, dest):
distrib_file = os.path.join(src, filename)
export_file = os.path.join(dest, filename)
shutil.copy(distrib_file, export_file)
os.chown(export_file, int(os.environ['GALAXY_UID']), int(os.environ['GALAXY_GID']))
os.chown(export_file, GALAXY_UID, GALAXY_GID)


def _makedir(path):
if not os.path.exists( path ):
os.makedirs( path )
os.chown( path, int(os.environ['GALAXY_UID']), int(os.environ['GALAXY_GID']) )
os.chown(path, GALAXY_UID, GALAXY_GID)


def _ignore_static(dir, *patterns):
Expand All @@ -72,38 +77,35 @@ if __name__ == "__main__":
If the user re-starts (with docker start) the container the file /.galaxy_save is found and the linking
is aborted.
"""

galaxy_root_dir = os.environ.get('GALAXY_ROOT_DIR', '/galaxy-central/')

galaxy_distrib_paths = {'/galaxy-central/config/': '/export/.distribution_config',
'/galaxy-central/lib': '/export/galaxy-central/lib',
'/galaxy-central/tools': '/export/galaxy-central/tools'}
galaxy_distrib_paths = {os.path.join(GALAXY_ROOT_DIR, 'config'): '/export/.distribution_config',
os.path.join(GALAXY_ROOT_DIR, 'lib'): '/export/galaxy/lib',
os.path.join(GALAXY_ROOT_DIR, 'tools'): '/export/galaxy/tools'}
for image_path, export_path in galaxy_distrib_paths.items():
if os.path.exists(export_path):
shutil.rmtree(export_path)
# Ignore 2 dead symlinks in galaxy code: see https://github.com/galaxyproject/galaxy/issues/9847
shutil.copytree( image_path, export_path, ignore=_ignore_static('/galaxy-central/lib/galaxy/web/framework/static/style', 'question-octagon-frame.png', 'ok_small.png') )
shutil.copytree( image_path, export_path, ignore=_ignore_static(os.path.join(GALAXY_ROOT_DIR, '/lib/galaxy/web/framework/static/style'), 'question-octagon-frame.png', 'ok_small.png') )

shutil.copy('/galaxy-central/requirements.txt','/export/galaxy-central/requirements.txt')
shutil.copy(os.path.join(GALAXY_ROOT_DIR, 'requirements.txt'), '/export/galaxy/requirements.txt')

_makedir('/export/galaxy-central/')
_makedir('/export/galaxy/')
_makedir('/export/ftp/')

change_path( os.path.join(galaxy_root_dir, 'config') )
change_path( os.path.join(GALAXY_ROOT_DIR, 'config') )

# Copy all sample config files to config dir
# TODO find a way to update plugins/ without breaking user customizations
config_src = os.path.join(galaxy_root_dir, 'config')
config_dest = os.path.join('/export/', galaxy_root_dir, 'config')
config_src = os.path.join(GALAXY_ROOT_DIR, 'config')
config_dest = os.path.join('/export/', GALAXY_ROOT_DIR, 'config')
copy_samples(config_src, config_dest)

# Copy all sample files to tool-data dir
# TODO find a way to update shared/ without breaking user customizations
tool_data_src = os.path.join(galaxy_root_dir, 'tool-data')
tool_data_dest = os.path.join('/export/', galaxy_root_dir, 'tool-data')
tool_data_src = os.path.join(GALAXY_ROOT_DIR, 'tool-data')
tool_data_dest = os.path.join('/export/', GALAXY_ROOT_DIR, 'tool-data')
copy_samples(tool_data_src, tool_data_dest)

# TODO find a way to update /export/galaxy-central/display_applications/ without breaking user customizations
# TODO find a way to update /export/galaxy/display_applications/ without breaking user customizations

# Copy all files starting with "welcome"
# This enables a flexible start page design.
Expand All @@ -112,15 +114,15 @@ if __name__ == "__main__":
export_file = os.path.join( '/export/', filename)
image_file = os.path.join('/etc/galaxy/web/', filename)
shutil.copy(export_file, image_file)
os.chown( image_file, int(os.environ['GALAXY_UID']), int(os.environ['GALAXY_GID']) )
os.chown( image_file, GALAXY_UID, GALAXY_GID )

# copy image defaults to config/<file>.docker_sample to base derivatives on,
# and if there is a realized version of these files in the export directory
# replace Galaxy's copy with these. Use symbolic link instead of copying so
# deployer can update and reload Galaxy and changes will be reflected.
for config in [ 'galaxy.yml', 'gravity.yml' ,'job_conf.xml' ]:
image_config = os.path.join('/etc/galaxy/', config)
export_config = os.path.join( '/export/galaxy-central/config', config )
export_config = os.path.join( '/export/galaxy/config', config )
export_sample = export_config + ".docker_sample"
shutil.copy(image_config, export_sample)
if os.path.exists(export_config):
Expand All @@ -136,12 +138,12 @@ if __name__ == "__main__":
shutil.rmtree(os.path.join(dest_conda, subdir))
subprocess.call('cp -p --preserve -R %s %s' % (os.path.join(src_conda, subdir), os.path.join(dest_conda, subdir)), shell=True)

change_path( os.path.join(galaxy_root_dir, 'tools.yaml') )
change_path( os.path.join(galaxy_root_dir, 'integrated_tool_panel.xml') )
change_path( os.path.join(galaxy_root_dir, 'display_applications') )
change_path( os.path.join(GALAXY_ROOT_DIR, 'tools.yaml') )
change_path( os.path.join(GALAXY_ROOT_DIR, 'integrated_tool_panel.xml') )
change_path( os.path.join(GALAXY_ROOT_DIR, 'display_applications') )
change_path( os.path.join('/tool_deps') )
change_path( os.path.join(galaxy_root_dir, 'tool-data') )
change_path( os.path.join(galaxy_root_dir, 'database') )
change_path( os.path.join(GALAXY_ROOT_DIR, 'tool-data') )
change_path( os.path.join(GALAXY_ROOT_DIR, 'database') )

if os.path.exists('/export/common_htpasswd'):
shutil.copy('/export/common_htpasswd', '/etc/nginx/htpasswd')
Expand Down
8 changes: 0 additions & 8 deletions galaxy/startup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/usr/bin/env bash

# Migration path for old images that had the tool_deps under /export/galaxy-central/tool_deps/

if [ -d "/export/galaxy-central/tool_deps/" ] && [ ! -L "/export/galaxy-central/tool_deps/" ]; then
mkdir -p /export/tool_deps/
mv /export/galaxy-central/tool_deps /export/
ln -s /export/tool_deps/ $GALAXY_ROOT_DIR/
fi

# This is needed for Docker compose to have a unified alias for the main container.
# Modifying /etc/hosts can only happen during runtime not during build-time
echo "127.0.0.1 galaxy" >> /etc/hosts
Expand Down

0 comments on commit 3b9f9a0

Please sign in to comment.