Skip to content

Commit

Permalink
OZ-448: Upgrade SENAITE to 2.3.0 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
enyachoke authored Mar 20, 2024
1 parent 272c0f5 commit 53d9694
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 252 deletions.
99 changes: 50 additions & 49 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,75 +1,76 @@
# Use an official Python runtime as a parent image
FROM python:2.7-stretch
FROM python:2.7-slim-buster

# Set one or more individual labels
LABEL maintainer="Mekom Solutions"
LABEL email="[email protected]"
LABEL senaite.core.version="2.0.0rc2"
LABEL senaite.core.version="v2.3.0"

# Set environment variables
ENV PLONE_MAJOR=5.2 \
PLONE_VERSION=5.2.2 \
PLONE_MD5=a603eddfd3abb0528f0861472ebac934 \
PLONE_UNIFIED_INSTALLER=Plone-5.2.2-UnifiedInstaller \
SENAITE_HOME=/home/senaite \
SENAITE_USER=senaite \
SENAITE_INSTANCE_HOME=/home/senaite/senaitelims \
SENAITE_DATA=/data \
SENAITE_FILESTORAGE=/data/filestorage \
SENAITE_BLOBSTORAGE=/data/blobstorage
PLONE_VERSION=5.2.9 \
PLONE_MD5=fe4bac71688e9704a21f7877680f1374 \
PLONE_UNIFIED_INSTALLER=Plone-5.2.9-UnifiedInstaller-1.0 \
SENAITE_HOME=/home/senaite \
SENAITE_USER=senaite \
SENAITE_INSTANCE_HOME=/home/senaite/senaitelims \
SENAITE_DATA=/data \
SENAITE_FILESTORAGE=/data/filestorage \
SENAITE_BLOBSTORAGE=/data/blobstorage

# Create the senaite user
RUN useradd --system -m -d $SENAITE_HOME -U -u 500 $SENAITE_USER

# Create direcotries
# Create directories
RUN mkdir -p $SENAITE_INSTANCE_HOME $SENAITE_FILESTORAGE $SENAITE_BLOBSTORAGE

# Copy the package config
COPY resources/packages.txt /

# Install package dependencies
RUN apt-get update && apt-get install -y --no-install-recommends $(grep -vE "^\s*#" /packages.txt | tr "\n" " ")
# Copy Buildout
COPY resources/requirements.txt resources/versions.cfg resources/buildout.cfg resources/develop.cfg $SENAITE_INSTANCE_HOME/

#RUN chown -R senaite:senaite $SENAITE_INSTANCE_HOME $SENAITE_FILESTORAGE $SENAITE_BLOBSTORAGE

# Copy the build dependencies and startup scripts
COPY resources/build_deps.txt resources/run_deps.txt resources/docker-initialize.py resources/docker-entrypoint.sh /

# Note: we concatenate all commands to avoid multiple layer generation and reduce the image size
RUN apt-get update \
# Install system pakages
&& apt-get install -y --no-install-recommends $(grep -vE "^\s*#" /build_deps.txt | tr "\n" " ") \
&& apt-get install -y --no-install-recommends $(grep -vE "^\s*#" /run_deps.txt | tr "\n" " ") \
# Fetch unified installer
&& wget -O Plone.tgz https://launchpad.net/plone/$PLONE_MAJOR/$PLONE_VERSION/+download/$PLONE_UNIFIED_INSTALLER.tgz \
&& echo "$PLONE_MD5 Plone.tgz" | md5sum -c - \
&& tar -xzf /Plone.tgz \
&& cp -rv $PLONE_UNIFIED_INSTALLER/base_skeleton/* $SENAITE_INSTANCE_HOME \
&& cp -v $PLONE_UNIFIED_INSTALLER/buildout_templates/buildout.cfg $SENAITE_INSTANCE_HOME/buildout-base.cfg \
&& rm -rf $PLONE_UNIFIED_INSTALLER Plone.tgz \
&& git clone https://github.com/mekomsolutions/plone.initializer.git $SENAITE_INSTANCE_HOME/src/plone.initializer \
&& cd $SENAITE_INSTANCE_HOME/src/plone.initializer && git checkout main \
&& git clone https://github.com/mekomsolutions/senaite.indexer.git $SENAITE_INSTANCE_HOME/src/senaite.indexer \
&& cd $SENAITE_INSTANCE_HOME/src/senaite.indexer && git checkout main \
&& git clone https://github.com/mekomsolutions/senaite.monkeypatches.git $SENAITE_INSTANCE_HOME/src/senaite.monkeypatches\
&& cd $SENAITE_INSTANCE_HOME/src/senaite.monkeypatches && git checkout main
# Buildout

# Fetch unified installer
RUN wget -O Plone.tgz https://launchpad.net/plone/$PLONE_MAJOR/$PLONE_VERSION/+download/$PLONE_UNIFIED_INSTALLER.tgz \
&& echo "$PLONE_MD5 Plone.tgz" | md5sum -c - \
&& tar -xzf Plone.tgz \
&& cp -rv /$PLONE_UNIFIED_INSTALLER/base_skeleton/* $SENAITE_INSTANCE_HOME \
&& cp -v /$PLONE_UNIFIED_INSTALLER/buildout_templates/buildout.cfg $SENAITE_INSTANCE_HOME/buildout-base.cfg \
&& cd $SENAITE_HOME \
&& rm -rf /$PLONE_UNIFIED_INSTALLER /Plone.tgz
RUN cd $SENAITE_INSTANCE_HOME \
&& pip install -r requirements.txt \
&& buildout -c develop.cfg \
&& ln -s $SENAITE_FILESTORAGE/ var/filestorage \
&& ln -s $SENAITE_BLOBSTORAGE/ var/blobstorage \
&& chown -R senaite:senaite $SENAITE_HOME $SENAITE_DATA \
# Cleanup
&& apt-get purge -y --auto-remove $(grep -vE "^\s*#" /build_deps.txt | tr "\n" " ") \
&& rm -rf /$SENAITE_HOME/buildout-cache \
&& rm -rf /var/lib/apt/lists/*

# Change working directory
WORKDIR $SENAITE_INSTANCE_HOME

# Copy Buildout
COPY resources/requirements.txt resources/versions.cfg resources/buildout.cfg resources/develop.cfg ./

RUN chown -R senaite:senaite $SENAITE_INSTANCE_HOME $SENAITE_FILESTORAGE $SENAITE_BLOBSTORAGE

RUN git clone https://github.com/mekomsolutions/plone.initializer.git $SENAITE_INSTANCE_HOME/src/plone.initializer && cd $SENAITE_INSTANCE_HOME/src/plone.initializer && git checkout main
RUN git clone https://github.com/mekomsolutions/senaite.indexer.git $SENAITE_INSTANCE_HOME/src/senaite.indexer && cd $SENAITE_INSTANCE_HOME/src/senaite.indexer && git checkout main
RUN git clone https://github.com/mekomsolutions/senaite.monkeypatches.git $SENAITE_INSTANCE_HOME/src/senaite.monkeypatches && cd $SENAITE_INSTANCE_HOME/src/senaite.monkeypatches && git checkout main

# Buildout
RUN pip install -r requirements.txt \
&& buildout -c develop.cfg\
&& ln -s $SENAITE_FILESTORAGE/ var/filestorage \
&& ln -s $SENAITE_BLOBSTORAGE/ var/blobstorage \
&& chown -R senaite:senaite $SENAITE_HOME $SENAITE_DATA

# Mount external volume
VOLUME /data

# Copy startup scripts
COPY resources/docker-initialize.py resources/docker-entrypoint.sh /

# Expose instance port
EXPOSE 8080

# Add instance healthcheck
HEALTHCHECK --interval=1m --timeout=5s --start-period=1m \
CMD nc -z -w5 127.0.0.1 8080 || exit 1

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["start"]
CMD ["start"]
14 changes: 14 additions & 0 deletions resources/build_deps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dpkg-dev
gcc
libbz2-dev
libc6-dev
libffi-dev
libjpeg62-turbo-dev
libopenjp2-7-dev
libpcre3-dev
libtiff5-dev
libxml2-dev
libxslt1-dev
wget
zlib1g-dev
git
Loading

0 comments on commit 53d9694

Please sign in to comment.