Skip to content

Commit

Permalink
Initial Commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost committed Jul 29, 2019
0 parents commit 0a878e9
Show file tree
Hide file tree
Showing 154 changed files with 51,702 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof
/api/conf/conf.toml
bin/
dist/
data/

# Capistrano related
.bundle
/.idea
71 changes: 71 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Make sure to check the documentation at http://goreleaser.com

project_name: rankdb

env:
- CGO_ENABLED=0
- GO111MODULE=on

before:
hooks:
- go mod download

builds:
-
main: ./cmd/rankdb/main.go
binary: rankdb
goos:
- linux
- windows
- darwin
- freebsd
goarch:
- amd64
- arm64
goarm:
- 6
- 7
-
id: rankdb-cli
main: ./api/tool/rankdb-cli/main.go
binary: rankdb-cli
goos:
- linux
- windows
- darwin
- freebsd
goarch:
- amd64
- arm64
goarm:
- 6
- 7

archives:
-
replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
format_overrides:
- goos: windows
format: zip
files:
- conf/conf.stub.toml
- api/swagger/swagger.json
- api/swagger/swagger.yaml
- api/public/swagger/*
- LICENSE
- README.md

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
language: go

sudo: false

os:
- linux
- osx

go:
- 1.11.x
- 1.12.x
- master

env:
- GO111MODULE=on
# needed for docker deploy:
- DOCKER_USER=vivino

# needed for the docker pipe
services:
- docker


script:
- diff <(gofmt -d .) <(printf "")
- go test -v ./...
- go test -cpu=1,2,4 -short -race ./...
- GOOS=linux GOARCH=386 go install ./...

matrix:
allow_failures:
- go: 'master'
fast_finish: true

after_success:
# docker login is required if you want to push docker images.
# DOCKER_PASSWORD should be a secret in your .travis.yml configuration.
- test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD"

# calls goreleaser
deploy:
- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_OS_NAME = linux

37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM golang:1.12-alpine

LABEL maintainer="vivino.com"

ENV GOPATH /go
ENV CGO_ENABLED 0
ENV GO111MODULE on
ENV BASEPACKAGE github.com/Vivino/rankdb
ENV PACKAGEPATH /go/src/${BASEPACKAGE}/

WORKDIR ${PACKAGEPATH}

# TODO: Remove when github.com/Vivino/rankdb is available.
COPY . ${PACKAGEPATH}

RUN \
apk add --no-cache git && \
go get ${BASEPACKAGE} || true && \
go build -v -o=/go/bin/rankdb ${BASEPACKAGE}/cmd/rankdb && \
go build -v -o=/go/bin/rankdb-cli ${BASEPACKAGE}/api/tool/rankdb-cli

FROM alpine:3.10

EXPOSE 8080

COPY --from=0 /go/bin/rankdb /usr/bin/rankdb
COPY --from=0 /go/bin/rankdb-cli /usr/bin/rankdb-cli
COPY api/conf/conf.stub.toml /conf/conf.toml
COPY deploy/docker-entrypoint.sh /usr/bin/

VOLUME ["/data"]
VOLUME ["/conf"]

HEALTHCHECK --interval=1m CMD rankdb-cli --timeout=1s health health

CMD ["rankdb"]
WORKDIR /
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2019, Vivino
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
COMMIT := $(shell git rev-parse HEAD)
COMMIT_SHORT := $(shell git rev-parse HEAD | cut -c -7)
PROJECT := github.com/Vivino/rankdb
BUILD_ARCH :=
export GO111MODULE = on

all: test build

test: clean install
go test ./...
go test -race -short .

fulltest: clean install
go test -cover ./...
go test -race -short ./...

lint:
golint ./...
go vet ./...

clean:
rm bin/go-ranks || true
rm bin/go-ranks-cli || true

generate: install
go install github.com/tinylib/msgp
go generate ${PROJECT}
go generate ${PROJECT}/api
goimports -w .
gofmt -s -w ./

run: build
mkdir -p db/
./bin/go-ranks -config=./conf/conf.toml

build: install
mkdir -p bin/
${BUILD_ARCH} go build -o bin/go-ranks ${PROJECT}/cmd/rankdb
${BUILD_ARCH} go build -o bin/go-ranks-cli ${PROJECT}/api/tool/rankdb-cli

dist: build
goreleaser --snapshot --skip-publish --rm-dist

install:
@echo "Pre-compiling"
go install -v ${PROJECT}/...
go get -u golang.org/x/lint/golint

commit:
@echo ${COMMIT_SHORT}
Loading

0 comments on commit 0a878e9

Please sign in to comment.