Commit d402b6ff authored by Luca Cinquini's avatar Luca Cinquini
Browse files

First check in of Docker code migrated from Luca's personal GitHub repository.

parent 3554d942
Loading
Loading
Loading
Loading
+5 −12
Original line number Diff line number Diff line
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
**/*.war
**/*.tar
**/*.tgz
**/*.swp
**/*.jar

cog/Dockerfile

0 → 100644
+83 −0
Original line number Diff line number Diff line
# ESGF node with CoG web application
# When running a container, must have $ESGF_HOSTNAME ebv set,

FROM esgfhub/esgf-node

MAINTAINER Luca Cinquini <luca.cinquini@jpl.nasa.gov>

# choose CoG version
ENV COG_TAG=v3.7.0

# setup CoG environment
ENV COG_DIR=/usr/local/cog
RUN mkdir -p $COG_DIR
ENV COG_CONFIG_DIR=$COG_DIR/cog_config
RUN mkdir -p $COG_CONFIG_DIR
ENV COG_INSTALL_DIR=$COG_DIR/cog_install
RUN mkdir -p $COG_INSTALL_DIR
ENV LD_LIBRARY_PATH=/usr/local/lib

# install CoG in virtual environment
RUN cd $COG_DIR && \
    virtualenv venv && \
    source $COG_DIR/venv/bin/activate && \
    git  clone https://github.com/EarthSystemCoG/COG cog_install

# checkout specific tag or branch
RUN cd $COG_INSTALL_DIR && \
    git checkout -b devel origin/devel
    #git checkout $COG_TAG

# install CoG dependencies
RUN cd $COG_INSTALL_DIR && \
    source $COG_DIR/venv/bin/activate && \
    python setup.py -q install

# manually install additional dependencies
RUN cd $COG_DIR && \
    source $COG_DIR/venv/bin/activate && \
    git clone https://github.com/EarthSystemCoG/django-openid-auth.git && \
    cd django-openid-auth && \
    python setup.py install

RUN cd $COG_DIR && \
    git clone https://github.com/globusonline/transfer-api-client-python.git && \
    cd transfer-api-client-python && \
    source $COG_DIR/venv/bin/activate && \
    python setup.py install && \
    git pull && \
    cd mkproxy && \
    make  && \
    cp mkproxy $COG_DIR/venv/lib/python2.7/site-packages/globusonline_transfer_api_client-0.10.18-py2.7.egg/globusonline/transfer/api_client/x509_proxy/.

# for some unknown reason, must reinstall captcha
RUN source $COG_DIR/venv/bin/activate && \
    pip uninstall -y django-simple-captcha && \
    pip install django-simple-captcha==0.5.1

# expose default django port
EXPOSE 8000

# create non-privileged user to run django
RUN groupadd -r cogadmin && \
    useradd -r -g cogadmin cogadmin && \
    mkdir -p ~cogadmin && \
    chown cogadmin:cogadmin ~cogadmin

# change user prompt
RUN echo 'export PS1="[\u@\h]\$ "' >> ~cogadmin/.bashrc

# change ownership of application directories
RUN chown -R cogadmin:cogadmin $COG_DIR

# expose software installation directories
# needed by apache httpd running cog through mod_wsgi
VOLUME $COG_DIR/venv
VOLUME $COG_INSTALL_DIR

# scripts
COPY scripts/ /usr/local/bin/
RUN chmod +x /usr/local/bin/*.sh

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["false", "true"]
+11 −0
Original line number Diff line number Diff line
#!/bin/bash
# script to change the password that CoG uses to access the Postgres database

if [ "${ESGF_PASSWORD}" = "" ] || [ "${COG_CONFIG_DIR}" = "" ];
then
   echo "All env variables: ESGF_PASSWORD, COG_CONFIG_DIR must be set  "
   exit -1
fi

sed -i 's/DATABASE_PASSWORD = .*/DATABASE_PASSWORD = '"${ESGF_PASSWORD}"'/g' $COG_CONFIG_DIR/cog_settings.cfg
sed -i 's/dbsuper:.*@esgf-postgres/dbsuper:'"${ESGF_PASSWORD}"'@esgf-postgres/g' $COG_CONFIG_DIR/cog_settings.cfg
+14 −0
Original line number Diff line number Diff line
#!/bin/bash
# script to change the password of the 'rootAdmin' web site administrator
# - for access to the postgres databases (CoG+ESGF)
# - for web authentication of the rootAdmin user

if [ "${ESGF_PASSWORD}" = "" ] || [ "${ESGF_HOSTNAME}" = "" ];
then
   echo "All env variables: ESGF_PASSWORD, ESGF_HOSTNAME must be set  "
   exit -1
fi

source /usr/local/cog/venv/bin/activate
cd /usr/local/cog/cog_install
python manage.py change_password "https://${ESGF_HOSTNAME}/esgf-idp/openid/rootAdmin" "${ESGF_PASSWORD}"
+37 −0
Original line number Diff line number Diff line
#!/bin/bash

# command line arguments

# ESGF_HOSTNAME=.....
export ESGF_HOSTNAME=$1
echo "ESGF_HOSTNAME=$ESGF_HOSTNAME"

# esgf_flag=false/true
export ESGF_FLAG=$2
echo "ESGF_FLAG=$ESGF_FLAG"

# runserver=true/false
export RUNSERVER=$3
echo "RUNSERVER=$RUNSERVER"

# use virtualenv
source $COG_DIR/venv/bin/activate

# upgrade CoG
cd $COG_INSTALL_DIR
python setup.py -q setup_cog --esgf=$ESGF_FLAG

# customize CoG settings
echo "Using ESGF_HOSTNAME=$ESGF_HOSTNAME"
sed -i 's/ALLOWED_HOSTS = .*/ALLOWED_HOSTS = '"${ESGF_HOSTNAME}"'/g' $COG_CONFIG_DIR/cog_settings.cfg

# FIXME:  PRODUCTION_SERVER = True would require use of SSL to transmit any cookie
sed -i 's/PRODUCTION_SERVER = True/PRODUCTION_SERVER = False/g' $COG_CONFIG_DIR/cog_settings.cfg

# start django server in virtual environment
# or keep the container running
if [ $RUNSERVER ]; then
   $RUNSERVER && python ./manage.py runserver 0.0.0.0:8000
else
   tail -f /dev/null
fi
Loading