Skip to content

Commit

Permalink
Merge pull request #42 from ernestio/f-micro-container-671
Browse files Browse the repository at this point in the history
Migrate to micro container
  • Loading branch information
purehyperbole authored Sep 18, 2017
2 parents bcaa749 + 28d63a8 commit 02e8f1b
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 61 deletions.
37 changes: 37 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: 2
jobs:
build:
machine:
image: circleci/classic:201709-01
environment:
NATS_URI: nats://127.0.0.1:4222
ROOTPATH: /home/circleci/.go_workspace/src/github.com/ernestio
NATS_URI_TEST: nats://127.0.0.1:4222
GOBIN: /home/circleci/.go_workspace/bin
CURRENT_INSTANCE: http://ernest.local:80/
JWT_SECRET: test
IMPORT_PATH: "github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
ERNEST_LOG_FILE: '/tmp/ernest.log'
ERNEST_APPLY_DELAY: 1
ERNEST_CRYPTO_KEY: mMYlPIvI11z20H1BnBmB223355667788
working_directory: /home/circleci/.go_workspace/src/github.com/ernestio/monit
steps:
- checkout
- run:
name: Setup Hosts File
command: echo 127.0.0.1 ernest.local | sudo tee -a /etc/hosts
- run:
name: Install Dependencies
command: make dev-deps
- run:
name: Code Analysis
command: make lint
- run:
name: Unit Tests
command: make test
- run:
name: Integration Tests
command: |
git clone -b f-circleci-v2-680 [email protected]:ernestio/toolset.git /tmp/toolset/
cd /tmp/toolset/ernestci/ && bundle install
ruby /tmp/toolset/ernestci/run.rb $CIRCLE_WORKING_DIRECTORY/.ernest-ci
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.8.2-alpine

FROM golang:1.9.0-alpine3.6 as compiler
RUN apk add --update git && apk add --update make && rm -rf /var/cache/apk/*

ADD . /go/src/github.com/${GITHUB_ORG:-ernestio}/monit
WORKDIR /go/src/github.com/${GITHUB_ORG:-ernestio}/monit
RUN make deps && CGO_ENABLED=0 go install -a -ldflags '-s' .

RUN make deps && go install

ENTRYPOINT ./entrypoint.sh
FROM scratch
COPY --from=compiler /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=compiler /go/bin/monit .
ENTRYPOINT ["./monit"]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deps:
go get github.com/nats-io/nats
go get github.com/dgrijalva/jwt-go
go get github.com/r3labs/pattern
go get github.com/ernestio/ernest-config-client

dev-deps: deps
go get github.com/smartystreets/goconvey/convey
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Monit

master: [![CircleCI](https://circleci.com/gh/ernestio/monit/tree/master.svg?style=shield)](https://circleci.com/gh/ernestio/monit/tree/master)
develop: [![CircleCI](https://circleci.com/gh/ernestio/monit/tree/develop.svg?style=shield)](https://circleci.com/gh/ernestio/monit/tree/develop)

## Synopsis

This microservice listens to all `monitor.user` events that are fired off by the FSM. It allows users to listen to the event stream over SSE (Server Side Events)

These events are collected into an inbox based on the monitor id passed by the user on an action. The inbox is opened on `service.create`, `service.delete` and closed on `service.create.done` and `service.delete.done`. If no inbox with the given ID exists when a user connects, one will be created.

## Build status

* Master: [![CircleCI Master](https://circleci.com/gh/ernestio/monit/tree/master.svg?style=svg)](https://circleci.com/gh/ernestio/monit/tree/master)
* Develop: [![CircleCI Develop](https://circleci.com/gh/ernestio/monit/tree/develop.svg?style=svg)](https://circleci.com/gh/ernestio/monit/tree/develop)


## Installation

```
Expand Down
35 changes: 0 additions & 35 deletions circle.yml

This file was deleted.

7 changes: 0 additions & 7 deletions entrypoint.sh

This file was deleted.

10 changes: 3 additions & 7 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ package main

import (
"encoding/json"
"log"
"os"
"time"

"github.com/nats-io/nats"
ecc "github.com/ernestio/ernest-config-client"
)

type monitorConfig struct {
Expand All @@ -21,11 +20,8 @@ type monitorConfig struct {
func setup() {
var err error
// Open Nats connection
nc, err = nats.Connect(os.Getenv("NATS_URI"))
if err != nil {
log.Println("Could not connect to nats")
return
}
ec := ecc.NewConfig(os.Getenv("NATS_URI"))
nc = ec.Nats()

secret = os.Getenv("JWT_SECRET")
if secret == "" {
Expand Down

0 comments on commit 02e8f1b

Please sign in to comment.