Skip to content
Snippets Groups Projects
Commit 367d4657 authored by Helena Rasche's avatar Helena Rasche
Browse files

fix

parents bec486f9 f2a4358a
Branches
No related tags found
No related merge requests found
Showing
with 350 additions and 119 deletions
FROM php:apache
FROM php:7.2-apache
# Install packages and PHP-extensions
RUN apt-get -q update && \
mkdir -p /usr/share/man/man1 /usr/share/man/man7 && \
DEBIAN_FRONTEND=noninteractive apt-get -yq --no-install-recommends install \
file libfreetype6 libjpeg62 libpng16-16 libpq-dev libx11-6 libxpm4 \
postgresql-client wget patch cron logrotate git nano python python-requests python-setuptools \
memcached libmemcached11 libmemcachedutil2 gpg dirmngr ca-certificates && \
BUILD_DEPS="libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev libxpm-dev re2c zlib1g-dev libmemcached-dev python-pip python-dev libpq-dev"; \
DEBIAN_FRONTEND=noninteractive apt-get -yq --no-install-recommends install $BUILD_DEPS \
&& docker-php-ext-configure gd \
--with-jpeg-dir=/usr/lib/x86_64-linux-gnu --with-png-dir=/usr/lib/x86_64-linux-gnu \
--with-xpm-dir=/usr/lib/x86_64-linux-gnu --with-freetype-dir=/usr/lib/x86_64-linux-gnu \
&& docker-php-ext-install gd mbstring pdo_pgsql zip \
&& pip install chado==2.1.1 tripal==3.0 \
&& pecl install memcached \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/*
# && pecl install uploadprogress # not yet compatible with php7 on PECL
ENV TINI_VERSION v0.9.0
RUN set -x \
&& curl -fSL "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini" -o /usr/local/bin/tini \
&& curl -fSL "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini.asc" -o /usr/local/bin/tini.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
&& gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
|| gpg --keyserver pgp.mit.edu --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
&& gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
&& rm -r "$GNUPGHOME" /usr/local/bin/tini.asc \
&& rm -rf "$GNUPGHOME" /usr/local/bin/tini.asc \
&& chmod +x /usr/local/bin/tini
ENTRYPOINT ["/usr/local/bin/tini", "--"]
......@@ -17,28 +37,12 @@ RUN ln -s /var/www/html /app
# Update apache2 configuration for drupal
RUN a2enmod rewrite && a2enmod proxy && a2enmod proxy_http
# Install packages and PHP-extensions
RUN apt-get -q update && \
DEBIAN_FRONTEND=noninteractive apt-get -yq --no-install-recommends install \
file libfreetype6 libjpeg62 libpng12-0 libpq-dev libx11-6 libxpm4 \
postgresql-client wget patch cron logrotate git python python-requests && \
BUILD_DEPS="libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev libxpm-dev re2c zlib1g-dev python-pip python-dev libpq-dev"; \
DEBIAN_FRONTEND=noninteractive apt-get -yq --no-install-recommends install $BUILD_DEPS \
&& docker-php-ext-configure gd \
--with-jpeg-dir=/usr/lib/x86_64-linux-gnu --with-png-dir=/usr/lib/x86_64-linux-gnu \
--with-xpm-dir=/usr/lib/x86_64-linux-gnu --with-freetype-dir=/usr/lib/x86_64-linux-gnu \
&& docker-php-ext-install gd mbstring pdo_pgsql zip \
&& pip install chado tripal \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/*
# && pecl install uploadprogress # not yet compatible with php7 on PECL
# Compile a php7 compatible version of uploadprogress module
RUN cd /tmp && git clone https://github.com/php/pecl-php-uploadprogress.git && cd pecl-php-uploadprogress && phpize && ./configure && make && make install && cd /
# Download Drupal from ftp.drupal.org
ENV DRUPAL_VERSION=7.53
ENV DRUPAL_TARBALL_MD5=4230279ecca4f0cde652a219e10327e7
ENV DRUPAL_VERSION=7.59
ENV DRUPAL_TARBALL_MD5=7e09c6b177345a81439fe0aa9a2d15fc
WORKDIR /var/www
RUN rm -R html \
&& curl -OsS https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz \
......@@ -55,7 +59,56 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
&& drush cc drush \
&& mkdir /etc/drush && echo "<?php\n\$options['yes'] = TRUE;\n\$options['v'] = TRUE;\n" > /etc/drush/drushrc.php
RUN wget https://github.com/erasche/chado-schema-builder/releases/download/1.31-jenkins90/chado-1.31-tripal.sql.gz -O /chado-master-tripal.sql.gz
RUN wget https://github.com/erasche/chado-schema-builder/releases/download/1.31-jenkins110/chado-1.31-tripal.sql.gz -O /chado-master-tripal.sql.gz \
&& wget --no-check-certificate https://drupal.org/files/drupal.pgsql-bytea.27.patch -O /drupal.pgsql-bytea.27.patch
WORKDIR html
# Install elasticsearch php library (required by tripal_elasticsearch)
RUN cd /var/www/html/sites/all/libraries/\
&& mkdir elasticsearch-php \
&& cd elasticsearch-php \
&& composer require "elasticsearch/elasticsearch:~5.0" \
&& cd /var/www/html/
ENV BASE_URL_PATH="/tripal" \
GALAXY_SHARED_DIR="/tripal-data/" \
ENABLE_DRUPAL_CACHE=1 \
ENABLE_OP_CACHE=1 \
ENABLE_MEMCACHE=1 \
ENABLE_CRON_JOBS=0 \
TRIPAL_BASE_CODE_GIT="https://github.com/tripal/tripal.git[@01c1f154b3fb27fa822d24546d0c7ed76ccf4cc6]" \
TRIPAL_GIT_CLONE_MODULES="https://github.com/abretaud/tripal_rest_api.git[@cb1d52ffed0b8a5c1ac189b41c729c8ad93b1c21] https://github.com/tripal/tripal_elasticsearch.git[@bac9c5d35f4c38e906fe48f55064906af8ea029a] https://github.com/tripal/trpdownload_api.git" \
TRIPAL_DOWNLOAD_MODULES="queue_ui tripal_analysis_interpro-7.x-2.x-dev tripal_analysis_blast-7.x-2.x-dev tripal_analysis_go-7.x-2.x-dev" \
TRIPAL_ENABLE_MODULES="tripal_genetic tripal_natural_diversity tripal_phenotype tripal_project tripal_pub tripal_stock tripal_analysis_blast tripal_analysis_interpro tripal_analysis_go tripal_rest_api tripal_elasticsearch trpdownload_api"
RUN repo_url=`echo $TRIPAL_BASE_CODE_GIT | sed 's/\(.\+\)\[@\w\+\]/\1/'`; \
rev=`echo $TRIPAL_BASE_CODE_GIT | sed 's/.\+\[@\(\w\+\)\]/\1/'`; \
git clone $repo_url /var/www/html/sites/all/modules/tripal; \
if [ "$repo_url" != "$rev" ]; then \
cd /var/www/html/sites/all/modules/tripal; \
git reset --hard $rev; \
cd /var/www/html/; \
fi;
# Pre download all default modules
RUN drush pm-download ctools views libraries services ultimate_cron memcache ${TRIPAL_BASE_MODULE} \
$TRIPAL_DOWNLOAD_MODULES \
&& for repo in $TRIPAL_GIT_CLONE_MODULES; do \
repo_url=`echo $repo | sed 's/\(.\+\)\[@\w\+\]/\1/'`; \
rev=`echo $repo | sed 's/.\+\[@\(\w\+\)\]/\1/'`; \
module_name=`basename $repo_url .git`; \
git clone $repo_url /var/www/html/sites/all/modules/$module_name; \
if [ "$repo_url" != "$rev" ]; then \
cd /var/www/html/sites/all/modules/$module_name; \
git reset --hard $rev; \
cd /var/www/html/sites/all/modules/; \
fi; \
done
RUN cd /var/www/html/sites/all/modules/views \
&& patch -p1 < ../tripal/tripal_views/views-sql-compliant-three-tier-naming-1971160-30.patch \
&& cd /var/www/html/
# Add custom functions
ADD search.sql /search.sql
......@@ -67,7 +120,6 @@ ADD php-conf.d/ $PHP_INI_DIR/conf.d/
ADD logrotate.d/tripal /etc/logrotate.d/
# copy sites/default's defaults
WORKDIR html
ADD etc/tripal/settings.php /etc/tripal/settings.php
# Add README.md, entrypoint-script and scripts-folder
......@@ -76,11 +128,4 @@ ADD /scripts/ /scripts/
ADD tripal_apache.conf /etc/apache2/conf-enabled/tripal_apache.conf
ENV BASE_URL_PATH="/tripal" \
ENABLE_DRUPAL_CACHE=1 \
ENABLE_OP_CACHE=1\
TRIPAL_GIT_CLONE_MODULES="https://github.com/abretaud/tripal_rest_api.git https://github.com/tripal/tripal_elasticsearch.git" \
TRIPAL_DOWNLOAD_MODULES="tripal_analysis_interpro-7.x-2.x-dev tripal_analysis_blast-7.x-2.x-dev tripal_analysis_go-7.x-2.x-dev" \
TRIPAL_ENABLE_MODULES="tripal_genetic tripal_natural_diversity tripal_phenotype tripal_project tripal_pub tripal_stock tripal_analysis_blast tripal_analysis_interpro tripal_analysis_go tripal_rest_api tripal_elasticsearch"
CMD ["/entrypoint.sh"]
# Tripal Docker Image
[![Docker Automated build](https://img.shields.io/docker/automated/erasche/tripal.svg?style=flat-square)](https://hub.docker.com/r/erasche/tripal/)
[![DOI](https://zenodo.org/badge/10899/erasche/docker-tripal.svg)](https://zenodo.org/badge/latestdoi/10899/erasche/docker-tripal)
![Tripal Logo](http://tripal.info/sites/default/files/TripalLogo_dark.png)
This image contains a ready-to-go installation of Tripal v2.1.
This image contains a ready-to-go installation of Tripal v2.x.
## Using the Container
......@@ -40,7 +41,7 @@ services:
ports:
- "3000:80"
db:
image: erasche/chado:1.31-jenkins97-pg9.5
image: erasche/chado
environment:
- POSTGRES_PASSWORD=postgres
# The default chado image would try to install the schema on first run,
......@@ -88,8 +89,12 @@ By default some caching is done for better performances. You can disable it with
```
ENABLE_OP_CACHE: 0 # To disable the PHP opcache
ENABLE_DRUPAL_CACHE: 0 # To disable Drupal built-in cache
ENABLE_MEMCACHE: 0 # To disable caching using memcache (requires ENABLE_DRUPAL_CACHE=1)
```
If ENABLE_DRUPAL_CACHE is enabled but ENABLE_MEMCACHE is not, Drupal will cache data into database.
If both ENABLE_DRUPAL_CACHE and ENABLE_MEMCACHE are enabled, Drupal will cache data using memcache.
## Customizing the Image
To build a derivative image from this, it should be as simple as writing a Dockerfile which builds off of this image.
......@@ -111,10 +116,45 @@ If you need to install a module that is not hosted on http://www.drupal.org, you
ENV TRIPAL_GIT_CLONE_MODULES="https://github.com/abretaud/tripal_rest_api.git https://github.com/tripal/tripal_analysis_expression.git"
```
## Tripal usage
If you want to get a specific git revision, you can use this syntax:
```
ENV TRIPAL_GIT_CLONE_MODULES="https://github.com/abretaud/tripal_rest_api.git[@cb1d52ffed0b8a5c1ac189b41c729c8ad93b1c21]"
```
## Tripal jobs
When loading data into Tripal, jobs or indexing tasks will be created inside the container.
If you are using [Tripaille](https://github.com/abretaud/python-tripal) to load data, you have nothing specific to do, jobs will be launched automatically for you.
If you don't use Tripaille, you will need to manually launch Tripal jobs or indexing tasks, as described in the Tripal documentation:
```
# Launch all jobs in queue
docker-compose exec web "drush trp-run-jobs --username=admin"
# Launch indexing tasks in all queues
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_0"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_1"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_2"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_3"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_4"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_5"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_6"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_7"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_8"
docker-compose exec web "export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_9"
```
The container can also be configured to launch Tripal jobs automatically every 2 minutes using cron:
```
ENABLE_CRON_JOBS=1
```
The container is configured (with cron) to launch Tripal jobs in queue every 2 minutes.
The log of these jobs is available in the /var/log/tripal_jobs.log log file, which is emptied regularly.
The downside of this option is that cron will coninue to launch processes every 2 minutes, even when no jobs are scheduled, leading to a little more cpu usage every 2 minutes.
The log of these jobs will be available in the /var/log/tripal_jobs.log and /var/log/tripal_cron.log log files.
## Data backup
......@@ -131,7 +171,7 @@ services:
- ./your/backed/up/dir/tripal_private:/var/www/private
[...]
db:
image: erasche/chado:latest
image: erasche/chado
[...]
volumes:
- ./your/backed/up/dir/tripal_db:/var/lib/postgresql/data/
......
......@@ -16,7 +16,7 @@ services:
MEMORY_LIMIT: 128M
BASE_URL: "http://localhost:3000/tripal"
BASE_URL_PROTO: "http://"
DB_NAME: 'tripal'
DB_NAME: 'postgres'
ports:
- "3000:80"
......
......@@ -69,10 +69,24 @@ fi
### Initial setup if database doesn't exist
if [ "$(PGPASSWORD=$DB_PASS psql -U $DB_USER -h $DB_HOST -p $DB_PORT postgres -tAc "SELECT 1 FROM pg_database WHERE datname='$DB_NAME'" )" != '1' ]
then
echo "Database $DB_NAME does not exist, creating it"
echo "CREATE DATABASE $DB_NAME;" | psql -U $DB_USER -h $DB_HOST -p $DB_PORT postgres;
fi
# Add possibly missing files/dirs if sites dir is empty (files needed by drush pm-list)
if [ ! -e /var/www/html/sites/default ]; then
mkdir -p /var/www/html/sites/default/
fi
if [ ! -e /var/www/html/sites/default/settings.php ]; then
cp /etc/tripal/settings.php /var/www/html/sites/default/settings.php
fi
# Check if tables are there and that drush works
DB_LOADED=$(PGPASSWORD=$DB_PASS psql -U "$DB_USER" -h "$DB_HOST" -p "$DB_PORT" -tAc "SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'organism');")
DRUSH_OK=`drush pm-list > /dev/null 2>&1; echo "$?"`
DRUSH_OK=`export ENABLE_MEMCACHE=0 && drush pm-list > /dev/null 2>&1; echo "$?"`
if [[ $DRUSH_OK != "0" && $DB_LOADED != "t" ]]
then
run_scripts setup
......@@ -89,10 +103,10 @@ then
elif [[ $DRUSH_OK != "0" && $DB_LOADED == "t" ]]
then
echo "=> Error: 'drush pm-list' fails but the database is not empty. Something is wrong in the install. Exiting."
drush pm-list
export ENABLE_MEMCACHE=0 && drush pm-list
exit $?
else
echo "=> Skipped setup - database ${DB_NAME} already exists."
echo "=> Skipped setup - database ${DB_NAME} already ready."
fi
......
......@@ -21,7 +21,7 @@ $conf['mail_system'] = ['default-system' => 'TestingMailSystem'];
/**
* Default elasticsearch host
*/
$conf['elasticsearch_hosts'] = array('elasticsearch');
$conf['elasticsearch_host'] = 'elasticsearch';
/**
* Caching
......@@ -31,6 +31,18 @@ if (getenv('ENABLE_DRUPAL_CACHE') == "1") {
$conf['block_cache'] = TRUE;
}
if (getenv('ENABLE_MEMCACHE') == "1" && file_exists($_SERVER{'DOCUMENT_ROOT'} . '/sites/all/modules/memcache/memcache.inc')) {
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;
// Use memcache for locking mechanisms
$conf['ultimate_cron_class_lock'] = 'UltimateCronLockMemcache';
$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';
}
if (getenv('BASE_URL'))
// Use BASE_URL if defined by user
$base_url = getenv('BASE_URL');
......
......@@ -11,3 +11,11 @@ then
else
echo "PHP OPcache disabled"
fi
if [[ $ENABLE_MEMCACHE == "1" ]]
then
echo "Memcache enabled"
echo "extension=memcached.so" > $PHP_INI_DIR'/conf.d/memcached-status.ini'
else
echo "Memcache disabled"
fi
if [[ $ENABLE_MEMCACHE == "1" ]]
then
service memcached start
fi
# Launch tripal jobs regularly
chmod a+x /root/
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"/usr/local/bin/drush trp-run-jobs --username=${ADMIN_USER}\"') >> /var/log/tripal_jobs.log 2>&1" > tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_0\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_1\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_2\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_3\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_4\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_5\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_6\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_7\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_8\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elastic_queue_9\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
crontab tripal_cron && rm tripal_cron
if [[ $ENABLE_CRON_JOBS == "1" ]]
then
echo "Tripal job launching scheduled with cron"
service cron start
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"/usr/local/bin/drush trp-run-jobs --username=${ADMIN_USER}\"') >> /var/log/tripal_jobs.log 2>&1" > tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_0\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_1\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_2\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_3\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_4\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_5\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_6\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_7\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_8\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
echo "*/2 * * * * (bash -lc 'cd /var/www/html; su www-data -s /bin/bash -c \"export BASE_URL=http://localhost/ && /usr/local/bin/drush cron-run queue_elasticsearch_queue_9\"') >> /var/log/tripal_cron.log 2>&1" >> tripal_cron
crontab tripal_cron && rm tripal_cron
service cron start
fi
......@@ -10,6 +10,7 @@ if [ ! -e /var/www/html/sites/all ]; then
mkdir -p /var/www/html/sites/all/themes/
fi
# This is probably already done in entrypoint.sh, but just in case
if [ ! -e /var/www/html/sites/default/settings.php ]; then
cp /etc/tripal/settings.php /var/www/html/sites/default/settings.php
fi
# This script will ensure all required modules are installed and enabled
cd /var/www/html/
if [[ ! $(ls -A /var/www/html/sites/all/libraries/) ]]; then
# If no library is present in libraries dir, it (probably) means we are mounting an empty dir
# Make sure mandatory libraries are installed there
echo "Could not find required external libraries, reinstalling them in /var/www/html/sites/all/libraries/"
cd /var/www/html/sites/all/libraries/
mkdir elasticsearch-php
cd elasticsearch-php
composer require "elasticsearch/elasticsearch:~5.0"
cd /var/www/html/
fi
# This script will ensure all required modules are installed and enabled
cd /var/www/html/
if [[ ! $(ls -A /var/www/html/sites/all/modules/) ]]; then
# If no module is present in module dir, it (probably) means we are mounting an empty dir
# Make sure mandatory modules are installed there
# No real download from drupal.org will be done, tarballs are cached by drush when building the image
echo "Could not find required base modules, reinstalling them in /var/www/html/sites/all/modules/"
# Fetch the tripal code from github repo (drupal.org repo is often outdated)
cd /var/www/html/sites/all/modules/
repo_url=`echo $TRIPAL_BASE_CODE_GIT | sed 's/\(.\+\)\[@\w\+\]/\1/'`
rev=`echo $TRIPAL_BASE_CODE_GIT | sed 's/.\+\[@\(\w\+\)\]/\1/'`
git clone $repo_url tripal
cd tripal
if [ "$repo_url" != "$rev" ]; then
git reset --hard $rev
fi
cd /var/www/html/
# Fetch the other modules from drupal.org
drush pm-download ctools views libraries services ultimate_cron memcache
# Patch views module
cd /var/www/html/sites/all/modules/views
patch -p1 < ../tripal/tripal_views/views-sql-compliant-three-tier-naming-1971160-30.patch
cd /var/www/html/
fi
# Make sure all required modules are enabled
drush pm-enable ctools views views_ui libraries services
drush pm-enable rest_server ultimate_cron
drush pm-enable tripal_core
drush pm-enable tripal_views tripal_db tripal_cv tripal_organism tripal_analysis tripal_feature
if [[ $ENABLE_MEMCACHE == "1" ]]
then
# This always returns an error, just ignore it, it will work.
drush pm-enable memcache || true
fi
# Make sure permissions are ok
drush role-add-perm 'anonymous user' 'access chado_analysis content'
drush role-add-perm 'anonymous user' 'access chado_feature content'
drush role-add-perm 'anonymous user' 'access chado_organism content'
drush role-add-perm 'authenticated user' 'access chado_analysis content'
drush role-add-perm 'authenticated user' 'access chado_feature content'
drush role-add-perm 'authenticated user' 'access chado_organism content'
# Install additional modules
# We don't want to overwrite existing modules to avoid unexpected changes in module code
# Temporary disable default settings to allow usage of --no option
if [ -f /etc/drush/drushrc.php ]; then
mv /etc/drush/drushrc.php /etc/drush/drushrc.php_back
fi
if [ ! -z "$TRIPAL_DOWNLOAD_MODULES" ]; then
drush pm-download --no ${TRIPAL_DOWNLOAD_MODULES}
fi
if [ -f /etc/drush/drushrc.php_back ]; then
mv /etc/drush/drushrc.php_back /etc/drush/drushrc.php
fi
if [ ! -z "$TRIPAL_GIT_CLONE_MODULES" ]; then
cd /var/www/html/sites/all/modules/
for repo in $TRIPAL_GIT_CLONE_MODULES; do
repo_url=`echo $repo | sed 's/\(.\+\)\[@\w\+\]/\1/'`
rev=`echo $repo | sed 's/.\+\[@\(\w\+\)\]/\1/'`
module_name=`basename $repo_url .git`
if [ -d "$module_name" ]; then
echo "Skipping git clone of module $module_name from $repo_url, $module_name already exists in /var/www/html/sites/all/modules/$module_name"
else
git clone $repo_url
if [ "$repo_url" != "$rev" ]; then
cd "$module_name"
git reset --hard $rev
cd /var/www/html/sites/all/modules/
fi
fi
done
cd /var/www/html/
fi
drush pm-enable ${TRIPAL_ENABLE_MODULES}
# Launch any job automatically created while installing modules
drush trp-run-jobs --username=${ADMIN_USER}
# Make sure module permissions are ok too (if modules are installed)
drush role-add-perm 'anonymous user' 'access chado_analysis_go content' || true
drush role-add-perm 'anonymous user' 'access chado_analysis_blast content' || true
drush role-add-perm 'anonymous user' 'access chado_analysis_interpro content' || true
drush role-add-perm 'authenticated user' 'access chado_analysis_go content' || true
drush role-add-perm 'authenticated user' 'access chado_analysis_blast content' || true
drush role-add-perm 'authenticated user' 'access chado_analysis_interpro content' || true
# Install additional themes
if [ ! -z "$THEME_GIT_CLONE" ]; then
cd /var/www/html/sites/all/themes/
for repo in $THEME_GIT_CLONE; do
theme_name=`basename $repo .git`
if [ -d "$theme_name" ]; then
echo "Skipping git clone of theme $theme_name from $repo, $theme_name already exists in /var/www/html/sites/all/themes/$theme_name"
else
git clone $repo
fi
done
cd /var/www/html/
fi
if [ ! -z "$THEME" ]; then
# Activate the theme
drush pm-enable "$THEME"
drush vset theme_default "$THEME"
fi
# Clear cache
drush cc all
prev_dir=$(pwd)
cd /var/www
chown -R www-data.www-data .
find . -type d -exec chmod ug=rx,o= '{}' \;
find . -type f -exec chmod ug=r,o= '{}' \;
chown -Rf www-data.www-data . || echo
find . -type d -exec chmod -f ug=rx,o= '{}' \; || echo
find . -type f -exec chmod -f ug=r,o= '{}' \; || echo
mkdir -p private
chmod ug=rwx,o= private
find private -type d -exec chmod ug=rwx,o= '{}' \;
find private -type f -exec chmod ug=rw,o= '{}' \;
......
This folder contains scripts that will be executed before the launch of a Drupal-instance.
See /README.md for details.
......@@ -14,5 +14,5 @@ if [ ! -e /var/www/html/sites/default/settings.php ]; then
cp /etc/tripal/settings.php /var/www/html/sites/default/settings.php
fi
chown -R www-data.www-data /var/www/html/sites
chown -R www-data.www-data /var/www/private
chown -Rf www-data.www-data /var/www/html/sites || echo
chown -Rf www-data.www-data /var/www/private || echo
/usr/bin/env PHP_OPTIONS="-d sendmail_path=$(which true)" drush site-install --site-name=default --account-name="${ADMIN_USER}" --account-pass="${ADMIN_PASSWORD}"
patch -p1 < /drupal.pgsql-bytea.27.patch
# Install the chado db
export PGPASSWORD=$DB_PASS
gunzip -f /chado-master-tripal.sql.gz
# Set the search path to something useful
echo "alter database $DB_NAME set search_path = '$user',public,chado;" | psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME;
psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME -f /chado-master-tripal.sql
echo "CREATE INDEX bingroup_boxrange ON featuregroup USING gist (chado.boxrange(fmin, fmax)) WHERE (is_root = 1);" | psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME;
psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME -f /search.sql
export PGPASSWORD=$DB_PASS
gunzip /chado-master-tripal.sql.gz
# Set the search path to something useful
echo "alter database $DB_NAME set search_path = '$user',public,chado;" | psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME;
psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME -f /chado-master-tripal.sql
echo "CREATE INDEX bingroup_boxrange ON featuregroup USING gist (chado.boxrange(fmin, fmax)) WHERE (is_root = 1);" | psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME;
psql -U $DB_USER -h $DB_HOST -p $DB_PORT $DB_NAME -f /search.sql
drush pm-download ctools views tripal-7.x-2.x-dev
drush pm-enable ctools views views_ui libraries services
drush pm-enable rest_server ultimate_cron
wget --no-check-certificate https://drupal.org/files/drupal.pgsql-bytea.27.patch && patch -p1 < drupal.pgsql-bytea.27.patch
cd /var/www/html/sites/all/modules/views
patch -p1 < ../tripal/tripal_views/views-sql-compliant-three-tier-naming-1971160-30.patch
cd /var/www/html/
drush pm-enable tripal_core
if [ ! -z "$TRIPAL_DOWNLOAD_MODULES" ]; then
drush pm-download ${TRIPAL_DOWNLOAD_MODULES}
fi
if [ ! -z "$TRIPAL_GIT_CLONE_MODULES" ]; then
cd /var/www/html/sites/all/modules/
for repo in $TRIPAL_GIT_CLONE_MODULES; do
git clone $repo
done
cd /var/www/html/
fi
if [ ! -z "$THEME_GIT_CLONE" ]; then
cd /var/www/html/sites/all/themes/
for repo in $THEME_GIT_CLONE; do
git clone $repo
done
cd /var/www/html/
fi
if [ ! -z "$THEME" ]; then
# Activate the theme
drush pm-enable "$THEME"
drush vset theme_default "$THEME"
fi
drush pm-enable tripal_views tripal_db tripal_cv tripal_organism tripal_analysis tripal_feature ${TRIPAL_ENABLE_MODULES}
# Ensure permissions are available
drush role-add-perm 'anonymous user' 'access chado_analysis content'
drush role-add-perm 'anonymous user' 'access chado_feature content'
drush role-add-perm 'anonymous user' 'access chado_organism content'
drush role-add-perm 'authenticated user' 'access chado_analysis content'
drush role-add-perm 'authenticated user' 'access chado_feature content'
drush role-add-perm 'authenticated user' 'access chado_organism content'
# Launch jobs automatically created
drush trp-run-jobs --username=${ADMIN_USER}
This folder contains scripts that will be executed as installation-process of a
Drupal-instance. See /README.md for details.
Drupal-instance.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment