diff --git a/BUILD.md b/BUILD.md deleted file mode 100644 index cb2c4f7..0000000 --- a/BUILD.md +++ /dev/null @@ -1,13 +0,0 @@ -To build run the following command: - - docker build -t memsql/quickstart . - -To publish, do the above to override the latest tag, and then tag the Ops -version as well. - - docker tag memsql/quickstart:latest memsql/quickstart:MEMSQL_OPS_VERSION - -Then push - - docker push memsql/quickstart - docker push memsql/quickstart:MEMSQL_OPS_VERSION diff --git a/Dockerfile b/Dockerfile index 5b0d376..2d069fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ # https://github.com/memsql/memsql-docker-quickstart # -FROM debian:8.4 +FROM debian:8.6 MAINTAINER Carl Sverre RUN apt-get update && \ @@ -34,8 +34,9 @@ RUN mkdir /memsql /memsql-ops # download and install MemSQL Ops # then reduce size by symlinking objdir and lib from one install to the other -COPY setup_ops.sh /tmp/setup_ops.sh -RUN /tmp/setup_ops.sh +COPY setup.sh /tmp/setup.sh +ADD VERSIONS /tmp/VERSIONS +RUN /tmp/setup.sh # COPY helper scripts COPY memsql-shell /usr/local/bin/memsql-shell diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cdd6828 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +.PHONY: latest +latest: + docker build -t memsql/quickstart:latest -f Dockerfile . diff --git a/README.md b/README.md index d961f51..d716424 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ docker pull memsql/quickstart # Verify your machine satisfies our minimum requirements -docker run --rm --net=host memsql/quickstart check-system +docker run --rm memsql/quickstart check-system # Spin up a MemSQL cluster on your machine @@ -30,5 +30,15 @@ docker run --rm -it --link=memsql:memsql memsql/quickstart memsql-shell # Stop and remove the container -docker stop memsql && docker rm -v memsql +docker rm -fv memsql +``` + +### Custom schema file at start + +If you mount a SQL file to /schema.sql inside the container it will be loaded +when the cluster is started. Example: + +``` +echo "CREATE DATABASE test;" > schema.sql +docker run -d -v $(PWD)/schema.sql:/schema.sql -p 3306:3306 -p 9000:9000 --name=memsql memsql/quickstart ``` diff --git a/VERSIONS b/VERSIONS new file mode 100644 index 0000000..6b36da6 --- /dev/null +++ b/VERSIONS @@ -0,0 +1,3 @@ +export OPS_VERSION=5.5.0 +export MEMSQL_VERSION=321074d63e5f6f4bb6229c1fce597993e720daae + diff --git a/memsql-entrypoint.sh b/memsql-entrypoint.sh index 53d94e7..d2af1eb 100755 --- a/memsql-entrypoint.sh +++ b/memsql-entrypoint.sh @@ -1,15 +1,20 @@ #!/bin/bash set -e -if [ "$1" = "memsqld" ]; then - # Start up the cluster +if [[ "$1" = "memsqld" ]]; then memsql-ops start memsql-ops memsql-start --all memsql-ops memsql-list + # Check for a schema file at /schema.sql and load it + if [[ -e /schema.sql ]]; then + echo "Loading schema from /schema.sql" + cat /schema.sql + memsql < /schema.sql + fi + # Tail the logs to keep the container alive exec tail -F /memsql/master/tracelogs/memsql.log /memsql/leaf/tracelogs/memsql.log +else + exec "$@" fi - -exec "$@" - diff --git a/setup_ops.sh b/setup.sh similarity index 69% rename from setup_ops.sh rename to setup.sh index 0c1fdb7..3692d51 100755 --- a/setup_ops.sh +++ b/setup.sh @@ -2,7 +2,10 @@ set -e set -x -VERSION_URL="http://versions.memsql.com/memsql-ops/5.1.0" +# Expects this file to export $OPS_VERSION and $MEMSQL_VERSION +source /tmp/VERSIONS + +VERSION_URL="http://versions.memsql.com/memsql-ops/$OPS_VERSION" MEMSQL_VOLUME_PATH="/memsql" OPS_URL=$(curl -s "$VERSION_URL" | jq -r .tar) @@ -20,16 +23,29 @@ mkdir /tmp/memsql-ops tar -xzf /tmp/memsql_ops.tar.gz -C /tmp/memsql-ops --strip-components 1 /tmp/memsql-ops/install.sh \ --host 127.0.0.1 \ - --simple-cluster \ + --no-cluster \ --ops-datadir /memsql-ops \ --memsql-installs-dir /memsql-ops/installs +DEPLOY_EXTRA_FLAGS= +if [[ $MEMSQL_VERSION != "community" ]]; then + DEPLOY_EXTRA_FLAGS="--version-hash $MEMSQL_VERSION" +fi + +memsql-ops memsql-deploy --role master --community-edition $DEPLOY_EXTRA_FLAGS +memsql-ops memsql-deploy --role leaf --community-edition --port 3307 $DEPLOY_EXTRA_FLAGS + MASTER_ID=$(memsql-ops memsql-list --memsql-role=master -q) MASTER_PATH=$(memsql-ops memsql-path $MASTER_ID) LEAF_ID=$(memsql-ops memsql-list --memsql-role=leaf -q) LEAF_PATH=$(memsql-ops memsql-path $LEAF_ID) +# We need to clear the maximum-memory setting in the leaf's memsql.cnf otherwise +# when we move to another machine with a different amount of memory the memory +# imbalance nag will show up +memsql-ops memsql-update-config --key maximum_memory --delete $LEAF_ID + # symlink leaf's static directories to master for tgt in objdir lib; do rm -rf $LEAF_PATH/$tgt