-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathentrypoint-dev.sh
More file actions
executable file
·100 lines (92 loc) · 3.63 KB
/
entrypoint-dev.sh
File metadata and controls
executable file
·100 lines (92 loc) · 3.63 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/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}
# Add local_settings file
if [ -f "${RNACENTRAL_HOME}"/rnacentral/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/rnacentral/local_settings.py
import os
from .utils import get_environment
SECRET_KEY = "$SECRET_KEY"
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}
S3_SERVER = {
"HOST": "$S3_HOST",
"KEY": "$S3_KEY",
"SECRET": "$S3_SECRET",
"BUCKET": "ebi-rnacentral",
}
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "memcached:11211",
},
"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')
}
}
# Override cache settings for testing
import sys
if 'test' in sys.argv or 'pytest' in sys.modules:
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "test-cache",
},
"sitemaps": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "test-sitemaps-cache",
}
}
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "$DB_NAME",
"USER": "$DB_USER",
"PASSWORD": "$DB_PASSWORD",
"HOST": "$DB_HOST",
"PORT": "$DB_PORT",
"CONN_MAX_AGE": 0
}
}
# Use regular StaticFilesStorage to avoid manifest issues
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
EOF
sed -i "3 a DEBUG = ${DJANGO_DEBUG}" "${RNACENTRAL_HOME}"/rnacentral/rnacentral/local_settings.py
chown -R rnacentral "${RNACENTRAL_HOME}"/rnacentral/rnacentral/local_settings.py
fi
# Clean up any problematic source map files before collecting static files
echo "INFO: Cleaning up problematic source map files..."
find "${RNACENTRAL_HOME}" -name "*.map" -type f -exec rm -f {} \; 2>/dev/null || true
echo "INFO: Collecting static files..."
python "${RNACENTRAL_HOME}"/rnacentral/manage.py collectstatic --noinput --clear
# Run django compressor only if enabled
echo "INFO: Checking django compressor settings..."
COMPRESS_ENABLED=$(python "${RNACENTRAL_HOME}"/rnacentral/manage.py shell -c "from django.conf import settings; print(getattr(settings, 'COMPRESS_ENABLED', False))")
if [ "$COMPRESS_ENABLED" = "True" ]; then
echo "INFO: Running django compress"
python "${RNACENTRAL_HOME}"/rnacentral/manage.py compress
else
echo "INFO: Django compressor is disabled, skipping compression"
fi
exec "$@"