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