Commit bbf85c79 authored by Thomas Downes's avatar Thomas Downes

Initial commit to containerize GraceDb

parent 47b7fbad
Pipeline #41215 failed with stages
in 32 seconds
---
image: docker:latest
variables:
DOCKER_DRIVER: overlay
DOCKER_BRANCH: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
DOCKER_LATEST: $CI_REGISTRY_IMAGE:latest
stages:
- branch
- latest
branch_image:
stage: branch
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build --pull -t $DOCKER_BRANCH .
- docker push $DOCKER_BRANCH
latest_image:
stage: latest
dependencies:
- branch_image
only:
refs:
- master
script:
- docker tag $DOCKER_BRANCH $DOCKER_LATEST
- docker push $DOCKER_LATEST
FROM ligo/base:stretch
LABEL name="LIGO GraceDB Django application" \
maintainer="tanner.prestegard@ligo.org" \
date="20180215"
WORKDIR /app
ADD . /app/gracedb_project
# Volumes
VOLUME /app/logs /app/project_data
RUN apt-get update
RUN apt-get install --assume-yes gcc \
python2.7 \
python-pip \
mariadb-client \
libmariadbclient-dev \
libldap2-dev \
libsasl2-dev \
libxml2-dev \
libsqlite3-dev \
python-glue \
python-pylal \
python-voeventlib
# Install npm, bower, bower_components
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && \
apt-get install nodejs && \
apt-get clean && \
npm install -g bower
# Install Python packages
RUN pip install -r ./gracedb_project/requirements.txt
EXPOSE 8000
# Give pip-installed packages priority over distribution packages
ENV PYTHONPATH /usr/local/lib/python2.7/dist-packages:$PYTHONPATH
ENV VIRTUAL_ENV dummy
# Set WORKDIR and run Gunicorn
WORKDIR /app/gracedb_project
#RUN python manage.py collectstatic --noinput
CMD ["gunicorn", "--reload", "--bind", "0.0.0.0:8000", "config.wsgi:application"]
...@@ -24,10 +24,10 @@ try: ...@@ -24,10 +24,10 @@ try:
if IS_PRODUCTION_SERVER: if IS_PRODUCTION_SERVER:
settings_file = 'production' settings_file = 'production'
else: else:
# If ./local.py is not found or IS_PRODUCTION_SERVER # If IS_PRODUCTION_SERVER is not defined, use development/test settings
# is not defined, use development/test settings
settings_file = 'dev' settings_file = 'dev'
except NameError: except ImportError:
# If local.py does not exist, use development/test settings
settings_file = 'dev' settings_file = 'dev'
settings_module = __import__(settings_file, globals(), locals()) settings_module = __import__(settings_file, globals(), locals())
......
...@@ -16,6 +16,9 @@ BASE_DIR = abspath(join(dirname(__file__), "..", "..")) ...@@ -16,6 +16,9 @@ BASE_DIR = abspath(join(dirname(__file__), "..", ".."))
CONFIG_ROOT = join(BASE_DIR, "config") CONFIG_ROOT = join(BASE_DIR, "config")
PROJECT_ROOT = join(BASE_DIR, "gracedb") PROJECT_ROOT = join(BASE_DIR, "gracedb")
# Other useful paths
PROJECT_DATA_DIR = join(BASE_DIR, "..", "project_data")
# Unauthenticated access ------------------------------------------------------ # Unauthenticated access ------------------------------------------------------
# This variable controls whether unauthenticated access is allowed *ANYWHERE* # This variable controls whether unauthenticated access is allowed *ANYWHERE*
# on this service, except the home page, which is always public. # on this service, except the home page, which is always public.
...@@ -196,16 +199,15 @@ SKYALERT_SUBMITTERS = ['Patrick Brady', 'Brian Moe'] ...@@ -196,16 +199,15 @@ SKYALERT_SUBMITTERS = ['Patrick Brady', 'Brian Moe']
# Stuff related to report/plot generation ------------------------------------- # Stuff related to report/plot generation -------------------------------------
# Latency histograms. Where they go and max latency to bin. # Latency histograms. Where they go and max latency to bin.
LATENCY_REPORT_DEST_DIR = GRACEDB_PATHS["latency"] LATENCY_REPORT_DEST_DIR = PROJECT_DATA_DIR
LATENCY_MAXIMUM_CHARTED = 1800 LATENCY_MAXIMUM_CHARTED = 1800
LATENCY_REPORT_WEB_PAGE_FILE_PATH = join(LATENCY_REPORT_DEST_DIR, LATENCY_REPORT_WEB_PAGE_FILE_PATH = join(PROJECT_DATA_DIR, "latency.inc")
"latency.inc")
# Uptime reporting # Uptime reporting
UPTIME_REPORT_DIR = GRACEDB_PATHS["uptime"] UPTIME_REPORT_DIR = PROJECT_DATA_DIR
# Rate file location # Rate file location
RATE_INFO_FILE = join(GRACEDB_PATHS["data"], "rate_info.json") RATE_INFO_FILE = join(PROJECT_DATA_DIR, "rate_info.json")
# URL prefix for serving report information (usually plots and tables) # URL prefix for serving report information (usually plots and tables)
# This is aliased to GRACEDB_PATHS["latency"] in the Apache virtualhost # This is aliased to GRACEDB_PATHS["latency"] in the Apache virtualhost
...@@ -213,11 +215,11 @@ RATE_INFO_FILE = join(GRACEDB_PATHS["data"], "rate_info.json") ...@@ -213,11 +215,11 @@ RATE_INFO_FILE = join(GRACEDB_PATHS["data"], "rate_info.json")
REPORT_INFO_URL_PREFIX = "/report_info/" REPORT_INFO_URL_PREFIX = "/report_info/"
# Directory for CBC IFAR Reports # Directory for CBC IFAR Reports
REPORT_IFAR_IMAGE_DIR = GRACEDB_PATHS["latency"] REPORT_IFAR_IMAGE_DIR = PROJECT_DATA_DIR
# Stuff for the new rates plot # Stuff for the new rates plot
BINNED_COUNT_PIPELINES = ['gstlal', 'MBTAOnline', 'CWB', 'oLIB', 'spiir'] BINNED_COUNT_PIPELINES = ['gstlal', 'MBTAOnline', 'CWB', 'oLIB', 'spiir']
BINNED_COUNT_FILE = join(GRACEDB_PATHS["data"], "binned_counts.json") BINNED_COUNT_FILE = join(PROJECT_DATA_DIR, "binned_counts.json")
# Defaults for RSS feed # Defaults for RSS feed
FEED_MAX_RESULTS = 50 FEED_MAX_RESULTS = 50
...@@ -238,7 +240,7 @@ DATABASES = { ...@@ -238,7 +240,7 @@ DATABASES = {
} }
# Location of database # Location of database
GRACEDB_DATA_DIR = GRACEDB_PATHS["database_data"] GRACEDB_DATA_DIR = join(BASE_DIR, "..", "db_data")
# First level subdirs with 2 chars, second level with 1 char # First level subdirs with 2 chars, second level with 1 char
# These DIR_DIGITS had better add up to a number less than 40 (which is # These DIR_DIGITS had better add up to a number less than 40 (which is
# the length of a SHA-1 hexdigest. Actually, it should be way less than # the length of a SHA-1 hexdigest. Actually, it should be way less than
...@@ -465,7 +467,7 @@ PASSWORD_EXPIRATION_TIME = timedelta(days=365) ...@@ -465,7 +467,7 @@ PASSWORD_EXPIRATION_TIME = timedelta(days=365)
# IP addresses of IFO control rooms # IP addresses of IFO control rooms
# Used to display signoff pages for operators # Used to display signoff pages for operators
# TP (10 Apr 2017): Virgo IP received from Florent Robinet, Franco Carbognani, # TP (10 Apr 2017): Virgo IP received from Florent Robinet, Franco Carbognani,
# and Sarah Antier. Corresponds to ctrl1.virgo.infn.it. # and Sarah Antier. Corresponds to ctrl1.virgo.infn.it.
CONTROL_ROOM_IPS = { CONTROL_ROOM_IPS = {
'H1': '198.129.208.178', 'H1': '198.129.208.178',
...@@ -481,6 +483,7 @@ LOG_FILE_BAK_CT = 10 ...@@ -481,6 +483,7 @@ LOG_FILE_BAK_CT = 10
LOG_FORMAT = 'extra_verbose' LOG_FORMAT = 'extra_verbose'
LOG_LEVEL = 'DEBUG' LOG_LEVEL = 'DEBUG'
LOG_DATEFMT = '%Y-%m-%d %H:%M:%S' LOG_DATEFMT = '%Y-%m-%d %H:%M:%S'
LOG_DIR = abspath(join(BASE_DIR, "..", "logs"))
# Note that mode for log files is 'a' (append) by default # Note that mode for log files is 'a' (append) by default
# The 'level' specifier on the handle is optional, and we # The 'level' specifier on the handle is optional, and we
...@@ -511,7 +514,7 @@ LOGGING = { ...@@ -511,7 +514,7 @@ LOGGING = {
'debug_file': { 'debug_file': {
'class': 'logging.handlers.ConcurrentRotatingFileHandler', 'class': 'logging.handlers.ConcurrentRotatingFileHandler',
'formatter': LOG_FORMAT, 'formatter': LOG_FORMAT,
'filename': join(GRACEDB_PATHS["logs"], "gracedb_debug.log"), 'filename': join(LOG_DIR, "gracedb_debug.log"),
'maxBytes': (20*1024*1024), 'maxBytes': (20*1024*1024),
'backupCount': LOG_FILE_BAK_CT, 'backupCount': LOG_FILE_BAK_CT,
'level': 'DEBUG', 'level': 'DEBUG',
...@@ -519,7 +522,7 @@ LOGGING = { ...@@ -519,7 +522,7 @@ LOGGING = {
'error_file': { 'error_file': {
'class': 'logging.handlers.ConcurrentRotatingFileHandler', 'class': 'logging.handlers.ConcurrentRotatingFileHandler',
'formatter': LOG_FORMAT, 'formatter': LOG_FORMAT,
'filename': join(GRACEDB_PATHS["logs"], "gracedb_error.log"), 'filename': join(LOG_DIR, "gracedb_error.log"),
'maxBytes': LOG_FILE_SIZE, 'maxBytes': LOG_FILE_SIZE,
'backupCount': LOG_FILE_BAK_CT, 'backupCount': LOG_FILE_BAK_CT,
'level': 'ERROR', 'level': 'ERROR',
...@@ -529,7 +532,7 @@ LOGGING = { ...@@ -529,7 +532,7 @@ LOGGING = {
'maxBytes': 1024*1024, 'maxBytes': 1024*1024,
'backupCount': 1, 'backupCount': 1,
'formatter': 'simple', 'formatter': 'simple',
'filename': join(GRACEDB_PATHS["logs"], "gracedb_performance.log"), 'filename': join(LOG_DIR, "gracedb_performance.log"),
}, },
'mail_admins': { 'mail_admins': {
'level': 'ERROR', 'level': 'ERROR',
......
...@@ -18,9 +18,10 @@ sys.path.append(BASE_DIR) ...@@ -18,9 +18,10 @@ sys.path.append(BASE_DIR)
sys.path.append(join(BASE_DIR, PROJECT_ROOT_NAME)) sys.path.append(join(BASE_DIR, PROJECT_ROOT_NAME))
# Activate the virtual environment # Activate the virtual environment
VIRTUALENV_ACTIVATOR = abspath(join(BASE_DIR, '..', VENV_NAME, 'bin', if ('VIRTUAL_ENV' not in os.environ):
'activate_this.py')) VIRTUALENV_ACTIVATOR = abspath(join(BASE_DIR, '..', VENV_NAME, 'bin',
execfile(VIRTUALENV_ACTIVATOR, dict(__file__=VIRTUALENV_ACTIVATOR)) 'activate_this.py'))
execfile(VIRTUALENV_ACTIVATOR, dict(__file__=VIRTUALENV_ACTIVATOR))
# Matplotlib config directory # Matplotlib config directory
os.environ['MPLCONFIGDIR'] = '/tmp/' os.environ['MPLCONFIGDIR'] = '/tmp/'
......
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