Dockerfile 2.67 KB
Newer Older
1
#------------------------------------------------------------------------------
2
#
3
# This Dockerfile is meant for containerized deployment with Kubernetes.
4
#
5
#-------------------------------------------------------------------------------
6

carlosribas's avatar
carlosribas committed
7
FROM python:3.8-slim
8

9 10 11
RUN apt-get update && apt-get install -y \
    g++ \
    build-essential \
12
    curl \
13 14
    tar \
    git \
carlosribas's avatar
carlosribas committed
15
    vim \
carlosribas's avatar
carlosribas committed
16
    supervisor && \
carlosribas's avatar
carlosribas committed
17
    rm -rf /var/lib/apt/lists/*
18

carlosribas's avatar
carlosribas committed
19 20
ENV RNACENTRAL_LOCAL=/srv/rnacentral/local
ENV SUPERVISOR_CONF_DIR=/srv/rnacentral/supervisor
21
ARG LOCAL_DEVELOPMENT
22

carlosribas's avatar
carlosribas committed
23 24 25 26 27
# Create folders
RUN \
    mkdir -p $RNACENTRAL_LOCAL && \
    mkdir -p $SUPERVISOR_CONF_DIR && \
    mkdir /srv/rnacentral/log
carlosribas's avatar
carlosribas committed
28
    mkdir /srv/static
carlosribas's avatar
carlosribas committed
29 30

# Install Infernal and node.js
31
RUN \
32
    cd $RNACENTRAL_LOCAL && \
33 34 35
    curl -OL http://eddylab.org/infernal/infernal-1.1.1.tar.gz && \
    tar -xvzf infernal-1.1.1.tar.gz && \
    cd infernal-1.1.1 && \
36
    ./configure --prefix=$RNACENTRAL_LOCAL/infernal-1.1.1 && \
37 38 39 40
    make && \
    make install && \
    cd easel && \
    make install && \
41
    cd $RNACENTRAL_LOCAL && \
carlosribas's avatar
carlosribas committed
42
    rm infernal-1.1.1.tar.gz && \
carlosribas's avatar
carlosribas committed
43
    curl -sL https://deb.nodesource.com/setup_lts.x | bash - && \
carlosribas's avatar
carlosribas committed
44
    apt-get install -y nodejs
45

carlosribas's avatar
carlosribas committed
46 47 48 49 50 51 52 53 54 55 56 57 58
# 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
carlosribas's avatar
carlosribas committed
59

carlosribas's avatar
carlosribas committed
60 61 62 63 64 65
# 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/
66
RUN chown -R rnacentral:rnacentral /srv
carlosribas's avatar
carlosribas committed
67

68 69 70 71 72 73 74 75 76 77 78
# Install and configure packages for local development if needed
RUN \
    LOCAL_DEV="${LOCAL_DEVELOPMENT:-False}" && \
    if [ "$LOCAL_DEV" = "True" ] ; then \
        pip3 install -r requirements_dev.txt ; \
        sed -i "13 a import debug_toolbar" "${RNACENTRAL_HOME}"/rnacentral/urls.py ; \
        sed -i "31 a \ \ \ \ url(r'^__debug__/', include(debug_toolbar.urls))," "${RNACENTRAL_HOME}"/rnacentral/urls.py ; \
        sed -i "129 a \ \ \ \ 'debug_toolbar.middleware.DebugToolbarMiddleware'," "${RNACENTRAL_HOME}"/rnacentral/settings.py ; \
        sed -i "188 a \ \ \ \ 'debug_toolbar'," "${RNACENTRAL_HOME}"/rnacentral/settings.py ; \
    fi

carlosribas's avatar
carlosribas committed
79 80 81 82 83 84
# Set user
USER rnacentral

# Run entrypoint
COPY ./entrypoint.sh $RNACENTRAL_HOME
ENTRYPOINT ["/srv/rnacentral/rnacentral-webcode/entrypoint.sh"]
85

carlosribas's avatar
carlosribas committed
86
# Supervisor
carlosribas's avatar
carlosribas committed
87
CMD [ "/bin/sh", "-c", "/usr/bin/supervisord -c ${SUPERVISOR_CONF_DIR}/supervisord.conf" ]