-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
73 lines (58 loc) · 2.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#------------------------------------------------------------------------------
#
# This Dockerfile is meant for containerized deployment with Kubernetes.
#
#-------------------------------------------------------------------------------
FROM python:3.8.15-slim
RUN apt-get update && apt-get install -y \
g++ \
build-essential \
curl \
tar \
git \
vim && \
rm -rf /var/lib/apt/lists/*
ENV RNACENTRAL_LOCAL=/srv/rnacentral/local
ARG LOCAL_DEVELOPMENT
# Create folders
RUN \
mkdir -p $RNACENTRAL_LOCAL && \
mkdir /srv/rnacentral/log && \
mkdir /srv/rnacentral/static
# Install node.js
RUN \
cd $RNACENTRAL_LOCAL && \
curl -sL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs
# 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.txt .
# Install requirements
RUN pip3 install --upgrade pip && pip3 install -r requirements.txt
# 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/rnacentral
RUN chown -R rnacentral:rnacentral /srv
# Install and configure packages for local development if needed
RUN \
LOCAL_DEV="${LOCAL_DEVELOPMENT:-False}" && \
if [ "$LOCAL_DEV" = "True" ] ; then \
pip3 install -r rnacentral/requirements_dev.txt ; \
sed -i "13 a import debug_toolbar" "${RNACENTRAL_HOME}"/rnacentral/rnacentral/urls.py ; \
sed -i "30 a \ \ \ \ url(r'^__debug__/', include(debug_toolbar.urls))," "${RNACENTRAL_HOME}"/rnacentral/rnacentral/urls.py ; \
sed -i "126 a \ \ \ \ 'debug_toolbar.middleware.DebugToolbarMiddleware'," "${RNACENTRAL_HOME}"/rnacentral/rnacentral/settings.py ; \
sed -i "188 a \ \ \ \ 'debug_toolbar'," "${RNACENTRAL_HOME}"/rnacentral/rnacentral/settings.py ; \
fi
# Set user
USER rnacentral
# Run entrypoint
COPY ./entrypoint.sh $RNACENTRAL_HOME
ENTRYPOINT ["/srv/rnacentral/rnacentral-webcode/entrypoint.sh"]
CMD ["gunicorn", "--chdir", "/srv/rnacentral/rnacentral-webcode/rnacentral", "--bind", "0.0.0.0:8000", "rnacentral.wsgi:application", "--workers", "2", "--timeout", "120", "--max-requests", "1000", "--max-requests-jitter", "100", "--log-level=debug", "--access-logfile", "/dev/stdout", "--error-logfile", "/dev/stderr"]