Commit 483efbbd authored by carlosribas's avatar carlosribas
Browse files

New dockerfile

parent b334d872
......@@ -14,17 +14,20 @@ RUN apt-get update && apt-get install -y \
git \
vim \
supervisor && \
useradd -m -d /srv/rnacentral -s /bin/bash rnacentral
rm -rf /var/lib/apt/lists/*
ENV RNACENTRAL_HOME=/srv/rnacentral
ENV RNACENTRAL_LOCAL=$RNACENTRAL_HOME/local
ENV SUPERVISOR_CONF_DIR=${SUPERVISOR_CONF_DIR:-"/srv/rnacentral/supervisor"}
ARG RNACENTRAL_BRANCH
ENV RNACENTRAL_LOCAL=/srv/rnacentral/local
ENV SUPERVISOR_CONF_DIR=/srv/rnacentral/supervisor
ARG LOCAL_DEVELOPMENT
# Create folders. Install Infernal and node.js
# Create folders
RUN \
mkdir -p $RNACENTRAL_LOCAL && \
mkdir -p $SUPERVISOR_CONF_DIR && \
mkdir /srv/rnacentral/log
# Install Infernal and node.js
RUN \
mkdir -p $RNACENTRAL_HOME/local && \
cd $RNACENTRAL_LOCAL && \
curl -OL http://eddylab.org/infernal/infernal-1.1.1.tar.gz && \
tar -xvzf infernal-1.1.1.tar.gz && \
......@@ -39,23 +42,39 @@ RUN \
curl -sL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs
USER rnacentral
# Create the rnacentral user
RUN useradd -m -d /srv/rnacentral -s /bin/bash rnacentral
# Set work directory
ENV RNACENTRAL_HOME=/srv/rnacentral/rnacentral-webcode
RUN mkdir -p $RNACENTRAL_HOME
WORKDIR $RNACENTRAL_HOME
# Copy requirements
COPY rnacentral/requirements* .
# Install requirements
RUN pip3 install -r requirements.txt
# Download RNAcentral, install requirements and node.js dependencies
# Install packages for local development if needed
RUN \
cd $RNACENTRAL_HOME && \
BRANCH="${RNACENTRAL_BRANCH:-master}" && \
git clone -b "$BRANCH" https://github.com/RNAcentral/rnacentral-webcode.git && \
pip3 install -r $RNACENTRAL_HOME/rnacentral-webcode/rnacentral/requirements.txt && \
LOCAL_DEV="${LOCAL_DEVELOPMENT:-false}" && \
if [ "$LOCAL_DEV" = "True" ] ; then \
pip3 install -r $RNACENTRAL_HOME/rnacentral-webcode/rnacentral/requirements_dev.txt ; \
fi && \
cd $RNACENTRAL_HOME/rnacentral-webcode/rnacentral/portal/static && npm install --only=production && \
mkdir $RNACENTRAL_HOME/static
WORKDIR $RNACENTRAL_HOME/rnacentral-webcode
COPY ./entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
LOCAL_DEV="${LOCAL_DEVELOPMENT:-False}" && \
if [ "$LOCAL_DEV" = "True" ] ; then pip3 install -r requirements_dev.txt ; fi
# Install NPM dependencies
ADD rnacentral/portal/static/package.json rnacentral/portal/static/
RUN cd rnacentral/portal/static && npm install --only=production
# Copy and chown all the files to the rnacentral user
COPY rnacentral/ $RNACENTRAL_HOME/
RUN chown -R rnacentral:rnacentral /srv/rnacentral
# Set user
USER rnacentral
# Run entrypoint
COPY ./entrypoint.sh $RNACENTRAL_HOME
ENTRYPOINT ["/srv/rnacentral/rnacentral-webcode/entrypoint.sh"]
# Supervisor
CMD [ "/bin/sh", "-c", "/usr/bin/supervisord -c ${SUPERVISOR_CONF_DIR}/supervisord.conf" ]
......@@ -22,16 +22,15 @@ S3_SECRET=${S3_SECRET}
SUPERVISOR_CONF_DIR=${SUPERVISOR_CONF_DIR:-"/srv/rnacentral/supervisor"}
# Entrypoint variable
RNACENTRAL_PROJECT_PATH="${RNACENTRAL_HOME}/rnacentral-webcode/rnacentral"
LOGS="${RNACENTRAL_HOME}/log"
LOGS=/srv/rnacentral/log
# Add local_settings file
if [ -f "${RNACENTRAL_PROJECT_PATH}"/rnacentral/local_settings.py ]
if [ -f "${RNACENTRAL_HOME}"/rnacentral/local_settings.py ]
then
echo "INFO: RNAcentral local_settings.py file already provisioned"
else
echo "INFO: Creating RNAcentral local_settings.py file"
cat <<-EOF > "${RNACENTRAL_PROJECT_PATH}"/rnacentral/local_settings.py
cat <<-EOF > "${RNACENTRAL_HOME}"/rnacentral/local_settings.py
import os
from .utils import get_environment
SECRET_KEY = "$SECRET_KEY"
......@@ -74,8 +73,8 @@ else
}
}
EOF
sed -i "3 a DEBUG = ${DJANGO_DEBUG}" "${RNACENTRAL_PROJECT_PATH}"/rnacentral/local_settings.py
chown -R rnacentral "${RNACENTRAL_PROJECT_PATH}"/rnacentral/local_settings.py
sed -i "3 a DEBUG = ${DJANGO_DEBUG}" "${RNACENTRAL_HOME}"/rnacentral/local_settings.py
chown -R rnacentral "${RNACENTRAL_HOME}"/rnacentral/local_settings.py
fi
# Supervisor setup
......@@ -84,8 +83,6 @@ then
echo "INFO: Supervisord configuration file already provisioned"
else
echo "INFO: Creating Supervisord configuration file"
mkdir -p "$SUPERVISOR_CONF_DIR"
mkdir -p "${LOGS}"
cat <<-EOF > "${SUPERVISOR_CONF_DIR}"/supervisord.conf
[supervisord]
pidfile=${SUPERVISOR_CONF_DIR}/supervisord.pid
......@@ -97,9 +94,9 @@ else
nodaemon=true
[program:rqworkers]
command=python $RNACENTRAL_HOME/rnacentral-webcode/rnacentral/manage.py rqworker
directory=$RNACENTRAL_HOME/rnacentral-webcode/rnacentral
numprocs=4
command=python $RNACENTRAL_HOME/manage.py rqworker
directory=$RNACENTRAL_HOME
numprocs=1
process_name=%(program_name)s_%(process_num)s
autorestart=true
autostart=true
......@@ -107,7 +104,7 @@ else
stdout_logfile=${LOGS}/rqworkers.out.log
[program:rnacentral]
command=$RNACENTRAL_HOME/.local/bin/gunicorn --chdir $RNACENTRAL_HOME/rnacentral-webcode/rnacentral --bind 0.0.0.0:8000 rnacentral.wsgi:application
command=gunicorn --chdir $RNACENTRAL_HOME --bind 0.0.0.0:8000 rnacentral.wsgi:application
user=rnacentral
autostart=true
autorestart=true
......@@ -115,6 +112,7 @@ else
stdout_logfile=${LOGS}/rnacentral.out.log
environment=HOME="$RNACENTRAL_HOME"
EOF
chown -R rnacentral "${SUPERVISOR_CONF_DIR}"/supervisord.conf
fi
exec "$@"
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment