-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from insidieux/1.1.0
Resolving issues and updates
- Loading branch information
Showing
7 changed files
with
226 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
*.md | ||
Gopkg* | ||
Makefile | ||
LICENSE | ||
/vendor | ||
/idea | ||
config.yaml | ||
* | ||
|
||
!.docker/docker-entrypoint | ||
!slack-duty-bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
sudo: required | ||
|
||
language: go | ||
|
||
env: | ||
global: | ||
- SRC_DIR: /go/src/github.com/${TRAVIS_REPO_SLUG} | ||
- DOCKER_TAG: ${TRAVIS_TAG} | ||
|
||
services: | ||
- docker | ||
|
||
jobs: | ||
include: | ||
- stage: tests | ||
script: | ||
- make test SRC_DIR=${SRC_DIR} | ||
- stage: push image | ||
script: | ||
- make push SRC_DIR=${SRC_DIR} DOCKER_NAMESPACE=${DOCKER_NAMESPACE} DOCKER_TAG=${DOCKER_TAG} DOCKER_USER=${DOCKER_USER} DOCKER_PASSWORD=${DOCKER_PASSWORD} | ||
if: tag IS present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,59 @@ | ||
all: build | ||
|
||
APP?=slack-duty-bot | ||
# strict variables | ||
APP:=slack-duty-bot | ||
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
# build go binary variables | ||
SRC_DIR?=$(shell echo '/go/$(shell echo ${ROOT_DIR} | awk -F'/go/' '{print $$2}')') | ||
BUILD_OS?=linux | ||
BUILD_ARCH?=amd64 | ||
DOCKER_IMAGE?=insidieux/${APP} | ||
|
||
# docker build variables | ||
DOCKER_NAMESPACE?= | ||
DOCKER_IMAGE=${DOCKER_NAMESPACE}/${APP} | ||
DOCKER_TAG?=1.0.0 | ||
DOCKER_USER?=user | ||
DOCKER_PASSWORD?=password | ||
DOCKER_USER?= | ||
DOCKER_PASSWORD?= | ||
|
||
# run variables | ||
SDB_SLACK_TOKEN?=some-token | ||
SDB_SLACK_KEYWORD?=keyword | ||
|
||
clean: | ||
rm -f ${APP} | ||
|
||
dep-install: | ||
go get -v -u github.com/golang/dep/cmd/dep | ||
|
||
dep-ensure: dep-install | ||
rm -rf vendor | ||
dep ensure | ||
rm -rf .vendor-new | ||
|
||
test: dep-ensure | ||
go test -v -race ./... | ||
|
||
build: clean dep-ensure | ||
env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} CGO_ENABLED=0 go build -v -o ${APP} | ||
dep-ensure: | ||
docker run --rm \ | ||
-v ${ROOT_DIR}:${SRC_DIR} \ | ||
-w ${SRC_DIR} \ | ||
golang:1.10 \ | ||
bash -c "go get -v -u github.com/golang/dep/cmd/dep && dep ensure" | ||
|
||
container: build | ||
test: dep-ensure | ||
docker run --rm \ | ||
-v ${ROOT_DIR}:${SRC_DIR} \ | ||
-w ${SRC_DIR} \ | ||
golang:1.10 \ | ||
go test -v -race ./... | ||
|
||
build: dep-ensure | ||
rm -f ${APP} || true | ||
docker run --rm \ | ||
-v ${ROOT_DIR}:${SRC_DIR} \ | ||
-w ${SRC_DIR} \ | ||
golang:1.10 \ | ||
env GOOS=${BUILD_OS} GOARCH=${BUILD_ARCH} CGO_ENABLED=0 go build -o ${APP} -v main.go | ||
|
||
image: build | ||
docker rmi ${DOCKER_IMAGE}:${DOCKER_TAG} || true | ||
docker build \ | ||
--build-arg APP=${APP} \ | ||
-f .docker/Dockerfile \ | ||
-t ${DOCKER_IMAGE}:${DOCKER_TAG} \ | ||
. | ||
|
||
run: container | ||
docker stop ${APP} || true && docker rm ${APP} || true | ||
docker run \ | ||
--name ${APP} \ | ||
--rm \ | ||
-e SDB_SLACK_TOKEN=${SDB_SLACK_TOKEN} \ | ||
${DOCKER_IMAGE}:${DOCKER_TAG} \ | ||
--slack.keyword ${SDB_SLACK_KEYWORD} | ||
|
||
push: container | ||
push: image | ||
docker login docker.io -u ${DOCKER_USER} -p ${DOCKER_PASSWORD} | ||
docker push ${DOCKER_IMAGE}:${DOCKER_TAG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.