Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Carlos Ribas
rnacentral-webcode
Commits
ca4a2924
Commit
ca4a2924
authored
May 13, 2021
by
carlosribas
Browse files
Docker for local development
parent
ff6ff70e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
241 additions
and
0 deletions
+241
-0
Dockerfile-local
Dockerfile-local
+65
-0
docker-compose.local.yml
docker-compose.local.yml
+58
-0
entrypoint-local.sh
entrypoint-local.sh
+118
-0
No files found.
Dockerfile-local
0 → 100644
View file @
ca4a2924
#------------------------------------------------------------------------------
#
# This Dockerfile is meant for containerized deployment with Kubernetes.
#
#-------------------------------------------------------------------------------
FROM python:3.8-slim
RUN apt-get update && apt-get install -y \
g++ \
build-essential \
curl \
tar \
git \
vim \
supervisor && \
rm -rf /var/lib/apt/lists/*
ENV RNACENTRAL_LOCAL=/srv/rnacentral/local
ENV SUPERVISOR_CONF_DIR=/srv/rnacentral/supervisor
# Create folders
RUN \
mkdir -p $RNACENTRAL_LOCAL && \
mkdir -p $SUPERVISOR_CONF_DIR && \
mkdir /srv/rnacentral/log && \
mkdir /srv/rnacentral/static
# Install Infernal and node.js
RUN \
cd $RNACENTRAL_LOCAL && \
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 && \
./configure --prefix=$RNACENTRAL_LOCAL/infernal-1.1.1 && \
make && \
make install && \
cd easel && \
make install && \
cd $RNACENTRAL_LOCAL && \
rm infernal-1.1.1.tar.gz && \
curl -sL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs
# 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 && pip3 install -r requirements_dev.txt
# Install NPM dependencies
ADD rnacentral/portal/static/package.json rnacentral/portal/static/
RUN cd rnacentral/portal/static && npm install --only=production
# Run entrypoint
COPY ./entrypoint-local.sh /
ENTRYPOINT ["/entrypoint-local.sh"]
# Supervisor
CMD [ "/bin/sh", "-c", "/usr/bin/supervisord -c ${SUPERVISOR_CONF_DIR}/supervisord.conf" ]
docker-compose.local.yml
0 → 100644
View file @
ca4a2924
version
:
'
3'
services
:
# RNAcentral website
rnacentral
:
build
:
context
:
.
dockerfile
:
Dockerfile-local
environment
:
-
DB_HOST=${DB_HOST}
-
DB_NAME=${DB_NAME}
-
DB_USER=${DB_USER}
-
DB_PASSWORD=${DB_PASSWORD}
-
DB_PORT=${DB_PORT}
-
SECRET_KEY=${SECRET_KEY}
-
DJANGO_DEBUG=${DJANGO_DEBUG}
-
S3_HOST=${S3_HOST}
-
S3_KEY=${S3_KEY}
-
S3_SECRET=${S3_SECRET}
-
EBI_SEARCH_ENDPOINT=${EBI_SEARCH_ENDPOINT}
command
:
python manage.py runserver 0.0.0.0:8000
ports
:
-
8000:8000
volumes
:
-
./openssl/openssl.cnf:/etc/ssl/openssl.cnf
-
./rnacentral:/srv/rnacentral/rnacentral-webcode
depends_on
:
-
redis
networks
:
-
redis-network
-
memcached-network
# Redis server
redis
:
image
:
redis:6.0.8-alpine
ports
:
-
8051:8051
command
:
redis-server --port
8051
restart
:
always
networks
:
-
redis-network
# Memcached server
memcached
:
image
:
memcached:1.6.7-alpine
ports
:
-
8052:8052
command
:
memcached -m 512m -p
8052
depends_on
:
-
rnacentral
networks
:
-
memcached-network
networks
:
redis-network
:
driver
:
bridge
memcached-network
:
driver
:
bridge
\ No newline at end of file
entrypoint-local.sh
0 → 100755
View file @
ca4a2924
#!/bin/sh
set
-e
# SYSTEM OPTIONS (set on Docker build)
RNACENTRAL_HOME
=
$RNACENTRAL_HOME
# External database settings
DB_HOST
=
${
DB_HOST
:-
'hh-pgsql-public.ebi.ac.uk'
}
DB_NAME
=
${
DB_NAME
:-
'pfmegrnargs'
}
DB_USER
=
${
DB_USER
:-
'reader'
}
DB_PORT
=
${
DB_PORT
:-
'5432'
}
DB_PASSWORD
=
${
DB_PASSWORD
:-
'NWDMCE5xdipIjRrp'
}
# RNAcentral specific settings
SECRET_KEY
=
${
SECRET_KEY
:-
$(
python
-c
'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
)
}
DJANGO_DEBUG
=
${
DJANGO_DEBUG
:-
'False'
}
EBI_SEARCH_ENDPOINT
=
${
EBI_SEARCH_ENDPOINT
:-
'http://www.ebi.ac.uk/ebisearch/ws/rest/rnacentral'
}
S3_HOST
=
${
S3_HOST
}
S3_KEY
=
${
S3_KEY
}
S3_SECRET
=
${
S3_SECRET
}
# Supervisor
SUPERVISOR_CONF_DIR
=
${
SUPERVISOR_CONF_DIR
:-
"/srv/rnacentral/supervisor"
}
# Entrypoint variable
LOGS
=
/srv/rnacentral/log
# Add debug_toolbar info
if
!
grep
-q
debug_toolbar
"
${
RNACENTRAL_HOME
}
"
/rnacentral/urls.py
;
then
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
# Add local_settings file
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_HOME
}
"/rnacentral/local_settings.py
import os
from .utils import get_environment
SECRET_KEY = "
$SECRET_KEY
"
DEBUG = True
EBI_SEARCH_ENDPOINT = "
$EBI_SEARCH_ENDPOINT
"
ENVIRONMENT = get_environment()
INTERNAL_IPS = ('127.0.0.1', '192.168.99.1')
DEBUG_TOOLBAR_CONFIG = {'SHOW_TOOLBAR_CALLBACK': lambda request: DEBUG}
COMPRESS_ENABLED = False
S3_SERVER = {
"HOST": "
$S3_HOST
",
"KEY": "
$S3_KEY
",
"SECRET": "
$S3_SECRET
",
"BUCKET": "ebi-rnacentral",
}
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.MemcachedCache",
"LOCATION": "memcached",
},
"sitemaps": {
"BACKEND": "rnacentral.utils.cache.SitemapsCache",
"LOCATION": os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'rnacentral', 'sitemaps')
}
}
RQ_QUEUES = {
"default": {
"HOST": "redis",
"PORT": 8051,
"DB": 0,
"DEFAULT_TIMEOUT": 360,
"REMOTE_SERVER": None,
}
}
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "
$DB_NAME
",
"USER": "
$DB_USER
",
"PASSWORD": "
$DB_PASSWORD
",
"HOST": "
$DB_HOST
",
"PORT": "
$DB_PORT
",
}
}
EOF
fi
# Supervisor setup
if
[
-f
"
${
SUPERVISOR_CONF_DIR
}
"
/supervisord.conf
]
then
echo
"INFO: Supervisord configuration file already provisioned"
else
echo
"INFO: Creating Supervisord configuration file"
cat
<<-
EOF
> "
${
SUPERVISOR_CONF_DIR
}
"/supervisord.conf
[supervisord]
pidfile=
${
SUPERVISOR_CONF_DIR
}
/supervisord.pid
logfile=
${
LOGS
}
/supervisord.log
user=rnacentral
logfile_maxbytes=50MB
logfile_backups=2
loglevel=info
nodaemon=true
[program:rqworkers]
command=python
$RNACENTRAL_HOME
/manage.py rqworker
directory=
$RNACENTRAL_HOME
/rnacentral
numprocs=1
process_name=%(program_name)s_%(process_num)s
autorestart=true
autostart=true
stderr_logfile=
${
LOGS
}
/rqworkers.err.log
stdout_logfile=
${
LOGS
}
/rqworkers.out.log
EOF
fi
exec
"
$@
"
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment