Skip to content

Commit

Permalink
CI improvements (#1)
Browse files Browse the repository at this point in the history
This PR contains:
* Automatic version detection by using git tags
* Fix for the Makefile (double package target)
* Enable Travis CI to build the Docker images and push to Docker Hub
  • Loading branch information
tobilg committed Apr 24, 2018
1 parent af95127 commit 75e0abf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
16 changes: 15 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down
24 changes: 6 additions & 18 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 75e0abf

Please sign in to comment.