# UCSC Genome Browser Website Dockerfile using Ubuntu 24 Noble
FROM phusion/baseimage:noble-1.0.2
LABEL org.opencontainers.image.authors="mhaeussl@ucsc.edu"
# The following is required as this is a "fat" docker image with an initd, running daemons like sshd and crond
# See phusion documentation
CMD ["/sbin/my_init"]

# Upgrade the base image using the Ubuntu repos and add wget,rsync
RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" && apt-get install -yq wget rsync

# Run mariadb and apache via initd, the Ubuntu startup system does not work in containers
ADD https://raw.githubusercontent.com/ucscGenomeBrowser/kent/master/src/product/installer/docker/apache.service /etc/service/apache/run
# actually mariadb, but the distros have mysqld symlinks, no need to rename
ADD https://raw.githubusercontent.com/ucscGenomeBrowser/kent/master/src/product/installer/docker/mariadb.service /etc/service/mariadb/run
#ADD mariadb.service /etc/service/mariadb/run
RUN chmod a+x /etc/service/mariadb/run /etc/service/apache/run 

# Install the genome browser
ADD http://raw.githubusercontent.com/ucscGenomeBrowser/kent/master/src/product/installer/browserSetup.sh /root/browserSetup.sh
RUN chmod a+x /root/browserSetup.sh && /root/browserSetup.sh -b install

# Use a persistent on-disk trackDb cache instead of the default /dev/shm
# (tmpfs in containers is small and not always shared with the apache user)
RUN echo "cacheTrackDbDir=/usr/local/apache/trash/trackDbCache" >> /usr/local/apache/cgi-bin/hg.conf

# Phusion documentation suggests this
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 80
