Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bhupeshbhatia committed Nov 29, 2018
0 parents commit c6b8bde
Show file tree
Hide file tree
Showing 32 changed files with 2,770 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.history
.vagrant
.vscode
vendor*
29 changes: 29 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SERVICE_NAME=agg-flashsalecap-cmd
KAFKA_LOG_PRODUCER_TOPIC=log.sink

ETCD_HOSTS=etcd:2379

# ===> Kafka
KAFKA_BROKERS=kafka:9092

KAFKA_CONSUMER_EVENT_GROUP=agg.flashsale.cmd.event.1
KAFKA_CONSUMER_EVENT_QUERY_GROUP=agg.flashsale.cmd.eq.1

KAFKA_CONSUMER_EVENT_TOPIC=event.persistence.response
KAFKA_CONSUMER_EVENT_QUERY_TOPIC=esquery.response
KAFKA_PRODUCER_EVENT_TOPIC=event.rns_eventstore.events
KAFKA_PRODUCER_EVENT_QUERY_TOPIC=esquery.request
KAFKA_PRODUCER_RESPONSE_TOPIC=agg.flashsale.response

# ===> Mongo
# MONGO_HOSTS=mongo:27017
MONGO_HOSTS=mongo:27017
MONGO_USERNAME=root
MONGO_PASSWORD=root

MONGO_DATABASE=rns_projections
MONGO_AGG_COLLECTION=agg_flashsale
MONGO_META_COLLECTION=aggregate_meta

MONGO_CONNECTION_TIMEOUT_MS=3000
MONGO_RESOURCE_TIMEOUT_MS=5000
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.history
.vscode
vendor*
debug*
17 changes: 17 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
linters:
enable:
- dupl
- gocyclo
- maligned
- misspell
- lll
- unparam

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
lll:
line-length: 90
unparam:
algo: rta
41 changes: 41 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
project_name: agg-flashsalecap-cmd

builds:
- main: ./main/
env:
- CGO_ENABLED=0
goos:
- linux
- windows

archive:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format: binary

sign:
artifacts: none

release:
github:
owner: TerrexTech
name: agg-flashsalecap-cmd

changelog:
sort: asc
filters:
exclude:
- '^bors:'
- '^docs:'
- typo

dockers:
- image: terrextech/agg-flashsalecap-cmd
binary: agg-flashsalecap-cmd
dockerfile: Dockerfile_ci
goos: linux
goarch: amd64
tag_templates:
- "{{ .Tag }}"
- latest
extra_files:
- .env
66 changes: 66 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
dist: trusty

services:
- docker

language: go

go:
- "1.11"

# Only clone the most recent commit
git:
depth: 1

branches:
except:
- staging.tmp

env:
global:
- DEP_VERSION="0.5.0"
- DOCKER_COMPOSE_VERSION=1.22.0

addons:
apt:
packages:
- docker-ce

before_install:
# Download dep binary to $GOPATH/bin
- if [[ ! -z ${TRAVIS_TAG} ]]; then
curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep &&
chmod +x $GOPATH/bin/dep;
fi

# Docker-Compose
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname
-s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

install:
# Only install local deps if its a tagged-commit
- if [[ ! -z ${TRAVIS_TAG} ]]; then dep ensure; fi

before_script:
- chmod +x ./run_test.sh

script:
- ./run_test.sh

after_script:
- docker-compose -f ./test/docker-compose.yaml down --volumes --rmi all

after_success:
- test -n "$TRAVIS_TAG"
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

deploy:
- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash -s -- --debug --skip-validate
on:
all_branches: true
tags: true
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# ===> Build Image
FROM golang:1.11.0-alpine3.8 AS builder
LABEL maintainer="Jaskaranbir Dhillon"

ARG SOURCE_REPO

ENV DEP_VERSION=0.5.0 \
CGO_ENABLED=0 \
GOOS=linux

# Download and install dep and git
ADD https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep
RUN apk add --update git

WORKDIR $GOPATH/src/github.com/TerrexTech/${SOURCE_REPO}

# Copy the code from the host and compile it
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure --vendor-only -v
COPY . ./

RUN go build -v -a -installsuffix nocgo -o /app ./main

# ===> Run Image
FROM scratch
LABEL maintainer="Jaskaranbir Dhillon"

COPY --from=builder /app ./
ENTRYPOINT ["./app"]
6 changes: 6 additions & 0 deletions Dockerfile_ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Dockerfile used by GoReleaser
FROM scratch
LABEL maintainer="Jaskaranbir Dhillon"

COPY /agg-flashsalecap-cmd ./
ENTRYPOINT ["./agg-flashsalecap-cmd"]
22 changes: 22 additions & 0 deletions Dockerfile_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dockerfile for building base image for tests
FROM golang:1.11.0-alpine3.8
LABEL maintainer="Jaskaranbir Dhillon"

ARG SOURCE_REPO

ENV DEP_VERSION=0.5.0

# Download and install dep and git
ADD https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep
RUN apk add --update git

WORKDIR $GOPATH/src/github.com/TerrexTech/${SOURCE_REPO}

# Copy the code from the host and compile it
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure --vendor-only -v

COPY . ./

CMD go run main/*.go
Loading

0 comments on commit c6b8bde

Please sign in to comment.