Sign inSign up

maartentwoa/resourcespace

By maartentwoa

•Updated about 3 years ago

Resourcespace with external filestore (nfs), mariadb and non-ingested (staticsync) files.

Image
0

3.3K

maartentwoa/resourcespace repository overview

After having run my ResourceSpace (RS) installation installed on my Synology NAS for a long time I decided it was time to move it into a Docker container. I have left the data structures on the Synology as nfsv3 shares and MariaDB database.

This image is for the specific use case of running ResourceSpace in Docker on a Synology with the MariaDB, filestore and actual pictures sitting on nfs volumes on the Synology diskstation.

⁠NOTE: this image assumes you have a resourcespace database and file structures (filestore and picture directory) in place.

⁠External data

This ResourceSpace docker image is using external data structures:

  • Filestore (mounted over nfsv3) containing the previews etc
  • Pictures/videos (mounted over nfsv3). These are not imported but left in place using staticsync.
  • Database ("resourcespace" running on MariaDB)

⁠Setting up the container:

  • Pull the image
  • Create and fill in the envlistrourcespace file with your own settings
  • Start the container (e.g. with "docker run -t --name resourcespace --privileged=true --env-file ./envlistresourcespace -p 100:80 resourcespace")

What will happen:

  • ResourceSpace's config.php will be populated with the mysql and other settings that depend on your installation
  • firstrun.sh is run and then deleted to prevent it being rerun.
  • startup.sh gets started to mount the remote file systems and start apache.

Now Resourcespace should be running on port 100: http://yourserver:100/resourcespace/pages/home.php⁠

⁠Creating the image

If you'd prefer to build your own image instead of using the one presented here, this is what you do:

  • Create the Dockerfile
  • Create the config.php.empty file
  • Create the firstrun.sh file
  • Create the startup.sh file
  • Compile the image: "docker build -t resourcespace ."

You will need the following files to create the image:

⁠firstrun.sh

#!/bin/bash
cat /firstrun.sh
echo -e \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# >>$RS_ROOTDIR/include/config.php
echo -e \#\#\# mysql settings >>$RS_ROOTDIR/include/config.php
echo -e \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# >>$RS_ROOTDIR/include/config.php
echo -e \# MySQL database settings >>$RS_ROOTDIR/include/config.php
echo -e \$mysql_server= $MYSQLSERVER \; >>$RS_ROOTDIR/include/config.php
echo -e \$mysql_username= $MYSQLUSER \; >>$RS_ROOTDIR/include/config.php
echo -e \$mysql_password= $MYSQLPASSWORD \; >>$RS_ROOTDIR/include/config.php
echo -e \$mysql_db= $MYSQLDBNAME \; >>$RS_ROOTDIR/include/config.php
echo -e \$email_from= $EMAILFROM \; >>$RS_ROOTDIR/include/config.php
echo -e \$email_notify= $EMAILNOTIFY \; >>$RS_ROOTDIR/include/config.php
echo -e \# Base URL of the installation (dockerhost) >>$RS_ROOTDIR/include/config.php
echo -e \$baseurl= $BASEURL \; >>$RS_ROOTDIR/include/config.php
rm -f /firstrun.sh

⁠Envllist to start the container

Envlist "envlistresourcespace". Note my remote picturedirectory is called "FotosME" and I create a similarly called mountpoint locally (fotostub/FotosME) so I can create multiple mountpoints if I'd decide later and mount them all under /fotostub. Fill in your own details:

RS_FILESTOREREMOTEDIR=youripadres:/nfs/mount/ofyour/filestore
RS_FILESTORELOCALDIR=/var/www/html/resourcespace/filestore
RS_ROOTDIR=/var/www/html/resourcespace
# staticsync local directroy with files
RS_STATICSYNCLOCALDIR1=/fotostub/FotosME
# staticsync files remote directory
RS_STATICSYNCREMOTEDIR1=yourserverip:/nf/mount/ofyour/FotosME
MYSQLSERVER='ipadresofmysqlserver'
MYSQLUSER='mysqluseridforresourcespaceDB'
MYSQLPASSWORD='passwordofmysqluserid'
MYSQLDBNAME='resourcespace'
EMAILFROM='[email protected]'
EMAILNOTIFY='[email protected]' 
BASEURL='yourdockerhost'

example of this envlist looks like this:

RS_FILESTOREREMOTEDIR=192.168.6.6:/volume1/web/resourcespace/filestore
RS_FILESTORELOCALDIR=/var/www/html/resourcespace/filestore
RS_ROOTDIR=/var/www/html/resourcespace
# staticsync local directroy with files
RS_STATICSYNCLOCALDIR1=/fotostub/FotosME
# staticsync files remote directory
RS_STATICSYNCREMOTEDIR1=192.168.6.6:/volume1/unique/FotosME
MYSQLSERVER='192.168.6.6'
MYSQLUSER='dockeruser'
MYSQLPASSWORD='YY7ejft65d'
MYSQLDBNAME='resourcespace'
EMAILFROM='[email protected]'
EMAILNOTIFY='[email protected]'
BASEURL='http://diskstation:100/resourcespace'

⁠Empty config.php

My empty config.php (without mysql details) called "config.php.empty"


⁠The Dockerfile

And the Dockerfile in case you want to build your own image using this info:

FROM centos:centos7
  
ENV RS_FILESTOREREMOTEDIR   serverip:/nfs/mount/point
ENV RS_FILESTORELOCALDIR    /var/www/html/resourcespace/filestore
ENV RS_ROOTDIR /var/www/html/resourcespace
# staticsync local directroy with files
ENV RS_STATICSYNCLOCALDIR1 /fotostub/FotosME
# staticsync files remote directory to be inventoried
ENV RS_STATICSYNCREMOTEDIR1 serverip:/nfs/path/files
# location of external server, credentials, database
ENV MYSQLSERVER serverip
ENV MYSQLUSER userid
ENV MYSQLPASSWORD password
ENV MYSQLDBNAME database
ENV EMAILFROM adresfrom
ENV EMAILNOTIFY adresnotify
ENV BASEURL serverurl
 
RUN yum -y update; yum clean all;       \
        yum -y install                  \
        epel-release                    \
        bash-completion                 \
        net-tools                       \
        nfs-utils;                      \
    yum clean all
  
RUN yum -y install mysql     \
        httpd                \
        php                  \
        php-dev              \
        php-gd               \
        php-mysql            \
        php-mbstring         \
        perl-devel           \
        make                 \
        subversion           \
        vim                  \
        nano                 \
        wget                 \
        p7zip                \
        ghostscript;         \
    yum clean all
  
RUN yum -y install php-pear  \
        gcc                  \
        php-devel            \
        php-pear             \
        ImageMagick          \
        poppler;             \
    yum clean all
  
RUN wget https://forensics.cert.org/cert-forensics-tools-release-el7.rpm && \
    rpm -Uvh cert-forensics-tools-release*rpm    && \
    yum --enablerepo=forensics install -y antiword; \
    yum clean all
  
RUN wget http://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-10.56.tar.gz && \
    gzip -dc Image-ExifTool-10.56.tar.gz | tar -xf - && \
    cd Image-ExifTool-10.56        && \
    perl Makefile.PL               && \
    make install                   && \
    cd                             && \
    rm -rf ./Image-ExifTool-10.56  && \
    rm -f Image-ExifTool-10.56.tar.gz;
      
  
## install ffmpeg
RUN yum -y install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm && \
    yum -y install ffmpeg     \
        ufraw;                \
    yum clean all
  
## php.ini update for RS
RUN sed -i "s/memory_limit\ =.*/memory_limit\ =\ 999M/g" /etc/php.ini              && \
    sed -i "s/post_max_size\ =.*/post_max_size\ =\ 2000M/g" /etc/php.ini           && \
    sed -i "s/upload_max_filesize\ =.*/upload_max_filesize\ =\ 2000M/g" /etc/php.ini
  
##################################
# Note: we are not creating the RS database here
##################################
  
## Install ResourceSpace using subversion
RUN mkdir -p $RS_ROOTDIR
RUN svn co http://svn.resourcespace.org/svn/rs/trunk $RS_ROOTDIR
### add mountpoint for mounting external nfs share:
# -p creates it recursively
RUN mkdir -p $RS_FILESTORELOCALDIR
RUN chown -R apache:apache $RS_ROOTDIR/filestore
RUN chmod 755 $RS_ROOTDIR/filestore
RUN chown -R apache:apache $RS_ROOTDIR/include
RUN chown -R apache:apache $RS_ROOTDIR/plugins
RUN chown -R apache:apache $RS_ROOTDIR/gfx
# staticsync mount point original files
RUN mkdir -p $RS_STATICSYNCLOCALDIR1
RUN chown -R apache:apache $RS_STATICSYNCLOCALDIR1
  
  
### on my original NAS the files were owned by a user with gid 1023 and some by user http
RUN groupadd http
# permissions of filestore on my synology were set to group 1023
RUN groupadd synol -g 1023
RUN usermod apache -G apache,http,synol
  
### update httpd.conf with recommendations RS             
RUN sed -i "s/Options\ Indexes\ FollowSymLinks/Options\ FollowSymLinks/g"  /etc/httpd/conf/httpd.conf
  
### copy an update config file (config.php) for use with ResourceSpace
COPY ./config.php.empty $RS_ROOTDIR/include/config.php
RUN chown apache:apache $RS_ROOTDIR/include/config.php
 
### copy a firstrun script that adds the server specifics (ip addresses, credentials)
# to the config.php RS is using. This script only gets started once
COPY ./firstrun.sh /firstrun.sh
RUN chmod +x firstrun.sh
 
### Create a startup file that gets run when the container starts (/startup.sh)
### This file mounts the remote file systems using nfs3 and starts apache.
### the first time it starts it kicks off "firstrun.sh" to populate the config.php
RUN echo -e "#!/bin/bash\ncat ./startup.sh\nsleep 3\n" >/startup.sh
# script to run first time container starts. It gets deleted on first run and therefore ignored next runs
RUN echo -e 'if [ -e "./firstrun.sh" ]\nthen\n./firstrun.sh\nfi\n' >>/startup.sh
# mounting filestore externally as well as original file location
RUN echo -e 'mount -o nolock,nfsvers=3 $RS_FILESTOREREMOTEDIR $RS_FILESTORELOCALDIR\nmount -o nolock,nfsvers=3 $RS_STATICSYNCREMOTEDIR1 $RS_STATICSYNCLOCALDIR1\necho "done"\n/usr/sbin/httpd -DFOREGROUND' >>/startup.sh
RUN chmod +x /startup.sh
  
EXPOSE 80
  
### kick off the startup file
ENTRYPOINT ["/bin/bash", "/startup.sh"]

Tag summary

Content type

Image

Digest

sha256:0f5b36fef…

Size

724.3 MB

Last updated

about 3 years ago

docker pull maartentwoa/resourcespace