Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
sudo: false
dist: trusty

language: go

go:
- 1.8
before_script: go get github.com/mitchellh/gox
script: go build
after_success: gox -osarch="linux/amd64" && echo $TRAVIS_TEST_RESULT
- 1.8.x
- 1.9.x

cache:
directories:
- ${TRAVIS_BUILD_DIR}/vendor

services:
- docker

install:
- go get github.com/golang/dep/cmd/dep
- dep ensure

before_script:
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";

script:
- make build

after_success:
- if [ -n "$TRAVIS_TAG" ]; then
make TAG=${TRAVIS_TAG} deploy;
fi
- make TAG=latest deploy
- make TAG=${TRAVIS_COMMIT} deploy
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM debian

# Non-root user `app`
RUN useradd app
WORKDIR /home/app

COPY bin/ipify-api ./

ENV LOGGING_LEVEL WARNING

COPY docker-entrypoint.sh ./

RUN chown -R app:app /home/app

# Change to user `app`
USER app

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

CMD ["./ipify-api"]
26 changes: 26 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[prune]
go-tests = true
unused-packages = true
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
TAG=latest
BIN=ipify-api
IMAGE=unchartedsky/$(BIN)

build:
dep ensure
go build -o bin/$(BIN) .

image: build
dep ensure
GOOS=linux GOARCH=amd64 go build -o bin/$(BIN) .
docker build -t $(IMAGE):$(TAG) .

deploy: image
docker push $(IMAGE):$(TAG)

.PHONY: clean

clean:
rm -rf bin/

cleanall: clean
rm -rf vendor/

9 changes: 9 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e

if [ "$1" != "./ipify-api" ]; then
exec "$@"
exit $?
fi

exec "$@" -logtostderr=true -stderrthreshold=${LOGGING_LEVEL}