diff --git a/.travis.yml b/.travis.yml index 31b24f81..575011d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,4 @@ script: - make test after_success: - - echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin - - export REPO=$DOCKER_USER/tile38 - - export COMMIT_SHORT=$(git rev-parse --short HEAD) - - docker build -f docker/Dockerfile -t $REPO:$COMMIT_SHORT . - - export TAG=`if [ ! -z "$TRAVIS_TAG" ]; then echo $TRAVIS_TAG; elif [ "$TRAVIS_BRANCH" == "master" ]; then echo "edge"; else echo ""; fi` - - if [[ ! -z "$TAG" && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then docker tag $REPO:$COMMIT_SHORT $REPO:$TAG && docker push $REPO:$TAG && echo "Pushed $REPO:$TAG"; else echo "Not pushing, either not on master or on a PR"; fi - - if [[ ! -z "$TRAVIS_TAG" ]]; then docker tag $REPO:$COMMIT_SHORT $REPO:latest && docker push $REPO:latest && echo "Pushed $REPO:latest"; else echo "Not pushing, no tag"; fi + - ./build.sh docker-push diff --git a/docker/Dockerfile b/Dockerfile similarity index 74% rename from docker/Dockerfile rename to Dockerfile index 559d8f3d..fb4a92b5 100644 --- a/docker/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:3.4 -ADD ./tile38-server /usr/local/bin -ADD ./tile38-cli /usr/local/bin +ADD tile38-server /usr/local/bin +ADD tile38-cli /usr/local/bin RUN addgroup -S tile38 && \ adduser -S -G tile38 tile38 && \ diff --git a/build.sh b/build.sh index 08908670..bbb4fd61 100755 --- a/build.sh +++ b/build.sh @@ -24,6 +24,56 @@ if [ "$1" == "update-version" ]; then exit fi +if [ "$1" == "docker-push" ]; then + # GIT_BRANCH - such as master or something else. + export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + # GIT_VERSION - always the last verison number, like 1.12.1. + export GIT_VERSION=$(git describe --tags --abbrev=0) + # GIT_TAG - either a version number, like 1.12.1, or the commit after the version, like 1.12.1-10-a718ef0. + export GIT_TAG=$(git describe --tags) + # GIT_COMMIT_SHORT - the short git commit number, like a718ef0. + export GIT_COMMIT_SHORT=$(git rev-parse --short HEAD) + # DOCKER_REPO - the base repository name to push the docker build to. + export DOCKER_REPO=$DOCKER_USER/tile38 + if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then + # never push from a pull request + echo "Not pushing, on a PR" + exit + fi + if [ "$GIT_BRANCH" != "master" ]; then + # only the master branch will work + echo "Not pushing, not on master" + exit + fi + if [ "$(git status | grep "nothing to commit, working tree clean")" == "" ]; then + # there's stuff to + echo "Not pushing, local git repo is dirty" + exit + fi + if [ "$(git status | grep "branch is up-to-date")" == "" ]; then + # branch must be up-to-date + echo "Not pushing, branch is not up-to-date with master" + exit + fi + push(){ + docker tag $DOCKER_REPO:$GIT_COMMIT_SHORT $DOCKER_REPO:$1 + docker push $DOCKER_REPO:$1 + echo "Pushed $DOCKER_REPO:$1" + } + # docker login + echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin + # build the docker image + docker build -f Dockerfile -t $DOCKER_REPO:$GIT_COMMIT_SHORT . + + if [ "$GIT_VERSION" == "$GIT_TAG" ]; then + push "$GIT_VERSION" + push "latest" + fi + push "edge" + exit +fi + + # Check go install if [ "$(which go)" == "" ]; then echo "error: Go is not installed. Please download and follow installation instructions at https://golang.org/dl to continue." diff --git a/docker/README.md b/docker/README.md deleted file mode 100644 index 43145854..00000000 --- a/docker/README.md +++ /dev/null @@ -1,25 +0,0 @@ -![Tile38 Logo](https://raw.githubusercontent.com/tidwall/tile38/master/pkg/assets/logo200.png) - -Tile38 is an open source (MIT licensed), in-memory geolocation data store, spatial index, and realtime geofence. It supports a variety of object types including lat/lon points, bounding boxes, XYZ tiles, Geohashes, and GeoJSON. - -*For more information visit: [http://tile38.com](http://tile38.com)* - -## Features - -- Spatial index with [search](#searching) methods such as Nearby, Within, and Intersects. -- Realtime [geofencing](#geofencing) through persistent sockets or [webhooks](http://tile38.com/commands/sethook). -- Object types of [lat/lon](#latlon-point), [bbox](#bounding-box), [Geohash](#geohash), [GeoJSON](#geojson), [QuadKey](#quadkey), and [XYZ tile](#xyz-tile). -- Support for lots of [Clients Libraries](#client-libraries) written in many different languages. -- Variety of protocols, including [http](#http) (curl), [websockets](#websockets), [telnet](#telnet), and the [Redis RESP](http://redis.io/topics/protocol). -- Server responses are [RESP](http://redis.io/topics/protocol) or [JSON](http://www.json.org). -- Full [command line interface](#cli). -- Leader / follower [replication](#replication). -- In-memory database that persists on disk. - -## Contact - -Josh Baker [@tidwall](http://twitter.com/tidwall) - -## License - -Tile38 source code is available under the MIT [License](/LICENSE).