Skip to content

Commit

Permalink
resync sotera firmament project
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Frame authored and Michael Frame committed Jul 31, 2015
1 parent 93c1154 commit a682b7c
Show file tree
Hide file tree
Showing 23 changed files with 628 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
7 changes: 7 additions & 0 deletions docker/memex/_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
#docker push jreeme/data-container:7.0
docker push jreeme/mysql:7.0
docker push jreeme/mongo:7.0
docker push jreeme/loopback:7.0
docker push jreeme/webapp:7.0
docker push jreeme/tangelo:7.0
14 changes: 14 additions & 0 deletions docker/memex/_remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
docker rm data-container
docker rm mysql
docker rm mongo
docker rm loopback
docker rm webapp
docker rm tangelo

#docker rmi jreeme/data-container:7.0
#docker rmi jreeme/mysql:7.0
#docker rmi jreeme/mongo:7.0
#docker rmi jreeme/loopback:7.0
#docker rmi jreeme/webapp:7.0
#docker rmi jreeme/tangelo:7.0
3 changes: 3 additions & 0 deletions docker/memex/data-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM jreeme/data-container:1.1

CMD ["/bin/bash"]
3 changes: 3 additions & 0 deletions docker/memex/data-container/_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
docker build --rm -t memex/data-container:7.0 .

7 changes: 7 additions & 0 deletions docker/memex/datawake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
docker run -dt --name data-container -h data-container jreeme/data-container:7.0
docker run -dt --volumes-from data-container --name mongo -h mongo jreeme/mongo:7.0
docker run -dt --volumes-from data-container --name mysql -h mysql jreeme/mysql:7.0
docker run -dt --name loopback -h loopback --link mongo:mongo --link mysql:mysql -p 8701:8701 -p 3001:3001 jreeme/loopback:7.0
docker run -dt --name webapp -h webapp --link loopback:loopback -p 8702:8701 -p 3002:3001 jreeme/webapp:7.0
docker run -dt --name tangelo -h tangelo --link mysql:mysql -p 80:80 jreeme/tangelo:7.0
3 changes: 3 additions & 0 deletions docker/memex/mongo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM jreeme/mongo:2.6

CMD ["/bin/bash"]
3 changes: 3 additions & 0 deletions docker/memex/mongo/_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
docker build --rm -t memex/mongo:7.0 .

3 changes: 3 additions & 0 deletions docker/memex/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM jreeme/mysql:5.5.2

CMD ["/bin/bash"]
3 changes: 3 additions & 0 deletions docker/memex/mysql/_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
docker build --rm -t memex/mysql:7.0 .

54 changes: 54 additions & 0 deletions docker/mysql/5.5/5.5.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM debian:wheezy
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql

# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
RUN apt-get update && apt-get install -y perl --no-install-recommends && rm -rf /var/lib/apt/lists/*

# mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
RUN apt-get update && apt-get install -y libaio1 && rm -rf /var/lib/apt/lists/*

# gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5

ENV MYSQL_MAJOR 5.5
ENV MYSQL_VERSION 5.5.45

# note: we're pulling the *.asc file from mysql.he.net instead of dev.mysql.com because the official mirror 404s that file for whatever reason - maybe it's at a different path?
RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& curl -SL "http://dev.mysql.com/get/Downloads/MySQL-$MYSQL_MAJOR/mysql-$MYSQL_VERSION-linux2.6-x86_64.tar.gz" -o mysql.tar.gz \
&& curl -SL "http://mysql.he.net/Downloads/MySQL-$MYSQL_MAJOR/mysql-$MYSQL_VERSION-linux2.6-x86_64.tar.gz.asc" -o mysql.tar.gz.asc \
&& apt-get purge -y --auto-remove curl \
&& gpg --verify mysql.tar.gz.asc \
&& mkdir /usr/local/mysql \
&& tar -xzf mysql.tar.gz -C /usr/local/mysql --strip-components=1 \
&& rm mysql.tar.gz* \
&& rm -rf /usr/local/mysql/mysql-test /usr/local/mysql/sql-bench \
&& rm -rf /usr/local/mysql/bin/*-debug /usr/local/mysql/bin/*_embedded \
&& find /usr/local/mysql -type f -name "*.a" -delete \
&& apt-get update && apt-get install -y binutils && rm -rf /var/lib/apt/lists/* \
&& { find /usr/local/mysql -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove binutils
ENV PATH $PATH:/usr/local/mysql/bin:/usr/local/mysql/scripts

# replicate some of the way the APT package configuration works
# this is only for 5.5 since it doesn't have an APT repo, and will go away when 5.5 does
RUN mkdir -p /etc/mysql/conf.d \
&& { \
echo '[mysqld]'; \
echo 'user = mysql'; \
echo 'datadir = /var/lib/mysql'; \
echo '!includedir /etc/mysql/conf.d/'; \
} > /etc/mysql/my.cnf

VOLUME /var/lib/mysql

COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 3306
CMD ["mysqld"]
99 changes: 99 additions & 0 deletions docker/mysql/5.5/5.5.0/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash
set -e

get_option () {
local section=$1
local option=$2
local default=$3
ret=$(my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
[ -z $ret ] && ret=$default
echo $ret
}

# if command starts with an option, prepend mysqld
if [ "${1:0:1}" = '-' ]; then
set -- mysqld "$@"
fi

if [ "$1" = 'mysqld' ]; then
# Get config
DATADIR="$("$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
SOCKET=$(get_option mysqld socket "/tmp/mysql.sock")
HOSTNAME=$(hostname)
PIDFILE=$(get_option mysqld pid-file "$DATADIR/mysqld.pid")

if [ ! -d "$DATADIR/mysql" ]; then
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
exit 1
fi

mkdir -p "$DATADIR"
chown -R mysql:mysql "$DATADIR"

echo 'Running mysql_install_db'
mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --basedir=/usr/local/mysql
echo 'Finished mysql_install_db'

mysqld --user=mysql --datadir="$DATADIR" --skip-networking --basedir=/usr/local/mysql --pid-file="$PIDFILE" &
for i in $(seq 30 -1 0); do
[ -S "$SOCKET" ] && break
echo 'MySQL init process in progress...'
sleep 1
done
if [ $i = 0 ]; then
echo >&2 'MySQL init process failed.'
exit 1
fi

# These statements _must_ be on individual lines, and _must_ end with
# semicolons (no line breaks or comments are permitted).
# TODO proper SQL escaping on ALL the things D:

tempSqlFile=$(mktemp /tmp/mysql-first-time.XXXXXX.sql)
cat > "$tempSqlFile" <<-EOSQL
-- What's done in this file shouldn't be replicated
-- or products like mysql-fabric won't work
SET @@SESSION.SQL_LOG_BIN=0;
DELETE FROM mysql.user ;
CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
DROP DATABASE IF EXISTS test ;
EOSQL

if [ "$MYSQL_DATABASE" ]; then
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" >> "$tempSqlFile"
fi

if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
echo "CREATE USER '"$MYSQL_USER"'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"' ;" >> "$tempSqlFile"

if [ "$MYSQL_DATABASE" ]; then
echo "GRANT ALL ON \`"$MYSQL_DATABASE"\`.* TO '"$MYSQL_USER"'@'%' ;" >> "$tempSqlFile"
fi
fi

echo 'FLUSH PRIVILEGES ;' >> "$tempSqlFile"

mysql -uroot < "$tempSqlFile"

rm -f "$tempSqlFile"
kill $(cat $PIDFILE)
for i in $(seq 30 -1 0); do
[ -f "$PIDFILE" ] || break
echo 'MySQL init process in progress...'
sleep 1
done
if [ $i = 0 ]; then
echo >&2 'MySQL hangs during init process.'
exit 1
fi
echo 'MySQL init process done. Ready for start up.'
fi

chown -R mysql:mysql "$DATADIR"
fi

exec "$@"
54 changes: 54 additions & 0 deletions docker/mysql/5.5/5.5.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM ubuntu:15.04
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql

# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
RUN apt-get update && apt-get install -y perl --no-install-recommends && rm -rf /var/lib/apt/lists/*

# mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
RUN apt-get update && apt-get install -y libaio1 && rm -rf /var/lib/apt/lists/*

# gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5

ENV MYSQL_MAJOR 5.5
ENV MYSQL_VERSION 5.5.45

# note: we're pulling the *.asc file from mysql.he.net instead of dev.mysql.com because the official mirror 404s that file for whatever reason - maybe it's at a different path?
RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& curl -SL "http://dev.mysql.com/get/Downloads/MySQL-$MYSQL_MAJOR/mysql-$MYSQL_VERSION-linux2.6-x86_64.tar.gz" -o mysql.tar.gz \
&& curl -SL "http://mysql.he.net/Downloads/MySQL-$MYSQL_MAJOR/mysql-$MYSQL_VERSION-linux2.6-x86_64.tar.gz.asc" -o mysql.tar.gz.asc \
&& apt-get purge -y --auto-remove curl \
&& gpg --verify mysql.tar.gz.asc \
&& mkdir /usr/local/mysql \
&& tar -xzf mysql.tar.gz -C /usr/local/mysql --strip-components=1 \
&& rm mysql.tar.gz* \
&& rm -rf /usr/local/mysql/mysql-test /usr/local/mysql/sql-bench \
&& rm -rf /usr/local/mysql/bin/*-debug /usr/local/mysql/bin/*_embedded \
&& find /usr/local/mysql -type f -name "*.a" -delete \
&& apt-get update && apt-get install -y binutils && rm -rf /var/lib/apt/lists/* \
&& { find /usr/local/mysql -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove binutils
ENV PATH $PATH:/usr/local/mysql/bin:/usr/local/mysql/scripts

# replicate some of the way the APT package configuration works
# this is only for 5.5 since it doesn't have an APT repo, and will go away when 5.5 does
RUN mkdir -p /etc/mysql/conf.d \
&& { \
echo '[mysqld]'; \
echo 'user = mysql'; \
echo 'datadir = /var/lib/mysql'; \
echo '!includedir /etc/mysql/conf.d/'; \
} > /etc/mysql/my.cnf

VOLUME /var/lib/mysql

COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 3306
CMD ["mysqld"]
99 changes: 99 additions & 0 deletions docker/mysql/5.5/5.5.1/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash
set -e

get_option () {
local section=$1
local option=$2
local default=$3
ret=$(my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
[ -z $ret ] && ret=$default
echo $ret
}

# if command starts with an option, prepend mysqld
if [ "${1:0:1}" = '-' ]; then
set -- mysqld "$@"
fi

if [ "$1" = 'mysqld' ]; then
# Get config
DATADIR="$("$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
SOCKET=$(get_option mysqld socket "/tmp/mysql.sock")
HOSTNAME=$(hostname)
PIDFILE=$(get_option mysqld pid-file "$DATADIR/mysqld.pid")

if [ ! -d "$DATADIR/mysql" ]; then
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
exit 1
fi

mkdir -p "$DATADIR"
chown -R mysql:mysql "$DATADIR"

echo 'Running mysql_install_db'
mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --basedir=/usr/local/mysql
echo 'Finished mysql_install_db'

mysqld --user=mysql --datadir="$DATADIR" --skip-networking --basedir=/usr/local/mysql --pid-file="$PIDFILE" &
for i in $(seq 30 -1 0); do
[ -S "$SOCKET" ] && break
echo 'MySQL init process in progress...'
sleep 1
done
if [ $i = 0 ]; then
echo >&2 'MySQL init process failed.'
exit 1
fi

# These statements _must_ be on individual lines, and _must_ end with
# semicolons (no line breaks or comments are permitted).
# TODO proper SQL escaping on ALL the things D:

tempSqlFile=$(mktemp /tmp/mysql-first-time.XXXXXX.sql)
cat > "$tempSqlFile" <<-EOSQL
-- What's done in this file shouldn't be replicated
-- or products like mysql-fabric won't work
SET @@SESSION.SQL_LOG_BIN=0;
DELETE FROM mysql.user ;
CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
DROP DATABASE IF EXISTS test ;
EOSQL

if [ "$MYSQL_DATABASE" ]; then
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" >> "$tempSqlFile"
fi

if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
echo "CREATE USER '"$MYSQL_USER"'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"' ;" >> "$tempSqlFile"

if [ "$MYSQL_DATABASE" ]; then
echo "GRANT ALL ON \`"$MYSQL_DATABASE"\`.* TO '"$MYSQL_USER"'@'%' ;" >> "$tempSqlFile"
fi
fi

echo 'FLUSH PRIVILEGES ;' >> "$tempSqlFile"

mysql -uroot < "$tempSqlFile"

rm -f "$tempSqlFile"
kill $(cat $PIDFILE)
for i in $(seq 30 -1 0); do
[ -f "$PIDFILE" ] || break
echo 'MySQL init process in progress...'
sleep 1
done
if [ $i = 0 ]; then
echo >&2 'MySQL hangs during init process.'
exit 1
fi
echo 'MySQL init process done. Ready for start up.'
fi

chown -R mysql:mysql "$DATADIR"
fi

exec "$@"
Loading

0 comments on commit a682b7c

Please sign in to comment.