diff --git a/.travis.yml b/.travis.yml index 7ccc544a..74b18983 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,16 @@ language: go -script: make test + +services: + - docker + +script: + - make test + +after_success: + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --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 diff --git a/Makefile b/Makefile index 8de8d94d..6d0e72b3 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,5 @@ uninstall: rm -f /usr/local/bin/tile38-server rm -f /usr/local/bin/tile38-cli rm -f /usr/local/bin/tile38-benchmark -package: package: @./build.sh package diff --git a/build.sh b/build.sh index f515375e..24cd5d5f 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -VERSION="1.12.0" +VERSION=$(git describe --tags | sed 's/-/\n/g' | head -n 1) PROTECTED_MODE="no" # Hardcode some values to the core package @@ -120,7 +120,6 @@ function rmtemp { } trap rmtemp EXIT - if [ "$NOLINK" != "1" ]; then # symlink root to isolated directory mkdir -p "$TMP/go/src/github.com/tidwall" diff --git a/docker/Dockerfile b/docker/Dockerfile index ea216ed0..559d8f3d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,25 +1,13 @@ FROM alpine:3.4 -ENV TILE38_VERSION 1.12.0 -ENV TILE38_DOWNLOAD_URL https://github.com/tidwall/tile38/releases/download/$TILE38_VERSION/tile38-$TILE38_VERSION-linux-amd64.tar.gz +ADD ./tile38-server /usr/local/bin +ADD ./tile38-cli /usr/local/bin -RUN addgroup -S tile38 && adduser -S -G tile38 tile38 - -RUN apk update \ - && apk add ca-certificates \ - && update-ca-certificates \ - && apk add openssl \ - && wget -O tile38.tar.gz "$TILE38_DOWNLOAD_URL" \ - && tar -xzvf tile38.tar.gz \ - && rm -f tile38.tar.gz \ - && mv tile38-$TILE38_VERSION-linux-amd64/tile38-server /usr/local/bin \ - && mv tile38-$TILE38_VERSION-linux-amd64/tile38-cli /usr/local/bin \ - && rm -fR tile38-$TILE38_VERSION-linux-amd64 - -RUN mkdir /data && chown tile38:tile38 /data +RUN addgroup -S tile38 && \ + adduser -S -G tile38 tile38 && \ + mkdir /data && chown tile38:tile38 /data VOLUME /data -WORKDIR /data EXPOSE 9851 -CMD ["tile38-server"] +CMD ["tile38-server", "-d", "/data"]