Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts committed Dec 17, 2015
2 parents e988619 + 870b6fa commit 0895e1f
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 56 deletions.
101 changes: 95 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile for the PDC's HubDB service
#
#
# HubDB for PDC-collected aggregate data.
# HubDB for PDC-collected aggregate data. Based on Mongo official 3.0.
#
# Example:
# sudo docker pull pdcbc/hubdb
Expand All @@ -14,21 +14,110 @@
# - Mongo live db: -v </path/>:/data/db/:rw
# - Mongo dumps: -v </path/>:/data/dump/:rw
#
FROM mongo:3.0
# Releases
# - https://github.com/PDCbc/gateway/releases
#
#
FROM phusion/baseimage
MAINTAINER [email protected]
ENV RELEASE 0.1.5
ENV RELEASE 0.1.6


################################################################################
# Start - modified from https://hub.docker.com/_/mongo/
################################################################################


# Create users and groups
#
RUN groupadd -r mongodb; \
useradd -r -g mongodb mongodb


# Packages
#
RUN apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates; \
rm -rf /var/lib/apt/lists/*


# MongoDB
#
ENV MONGO_MAJOR 3.0
ENV MONGO_VERSION 3.0.7
#
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 492EAFE8CD016A07919F1D2B9ECBEC467F0CEB10; \
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/$MONGO_MAJOR multiverse" > /etc/apt/sources.list.d/mongodb-org.list
RUN apt-get update; \
apt-get install -y \
mongodb-org=$MONGO_VERSION \
mongodb-org-server=$MONGO_VERSION \
mongodb-org-shell=$MONGO_VERSION \
mongodb-org-mongos=$MONGO_VERSION \
mongodb-org-tools=$MONGO_VERSION; \
rm -rf /var/lib/apt/lists/* \
/var/lib/mongodb \
/etc/mongod.conf


# Volume
#
RUN mkdir -p /data/db; \
chown -R mongodb:mongodb /data/db
VOLUME /data/db


# Port
#
EXPOSE 27017


################################################################################
# End - modified from https://hub.docker.com/_/mongo/
################################################################################


# Packages
#
RUN apt-get update; \
apt-get install -y \
git; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
git; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


# Prepare /app/ folder
#
WORKDIR /app/
RUN git clone https://github.com/pdcbc/hubdb.git . -b ${RELEASE}


# Mongo startup
#
RUN mkdir -p /etc/service/mongod/; \
SCRIPT=/etc/service/mongod/run; \
( \
echo "#!/bin/bash"; \
echo ""; \
echo "set -e -o nounset"; \
echo ""; \
echo ""; \
echo "# Start mongod"; \
echo "#"; \
echo "#exec mongod --storageEngine wiredTiger"; \
echo "exec mongod"; \
) \
>> ${SCRIPT}; \
chmod +x ${SCRIPT}


# Maintenance script and cron job
#
RUN SCRIPT=/app/mongo_maint.sh; \
( \
echo "# Run database dump/maintenance script (boot, daily 1:15 AM)"; \
echo "@reboot "${SCRIPT}; \
echo "15 1 * * * "${SCRIPT}; \
) \
| crontab -
47 changes: 0 additions & 47 deletions filterProviders.js

This file was deleted.

8 changes: 5 additions & 3 deletions mongo_maint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ set -e -o nounset
# Set db keys to prevent duplicates
#
mongo query_composer_development --eval \
'printjson( db.users.ensureIndex({ username : 1 }, { unique : true }))'
'printjson( db.users.ensureIndex({ username : 1 }, { unique: true }))'
mongo query_composer_development --eval \
'printjson( db.endpoints.ensureIndex({ base_url : 1 }, { unique : true }))'
'printjson( db.endpoints.ensureIndex({ base_url : 1 }, { unique: true }))'
mongo query_composer_development --eval \
'printjson( db.users.ensureIndex({ first_name: 1, last_name:1 }, { unique: true }))'
'printjson( db.users.ensureIndex({ username: 1 }, { unique: true }))'
mongo query_composer_development --eval \
'printjson( db.queries.ensureIndex({ description: 1 }, { unique: true }))'


# Dump MongoDB, report failure if unsuccessful
Expand Down

0 comments on commit 0895e1f

Please sign in to comment.