Skip to content

Commit

Permalink
Introduce docker-compose support and deprecat railgun.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhamel committed Apr 22, 2022
1 parent 6d74dbf commit 1761e0f
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 52 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.17.6-alpine3.15 AS base

WORKDIR /go/src/trieugene
COPY . .
RUN go get -d -v ./...
RUN go install -v ./...

CMD ["trieugene", "dev"]
5 changes: 2 additions & 3 deletions dev.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: trieugene
up:
- homebrew:
- golangci/tap/golangci-lint
- golangci-lint
- go:
version: 1.13
version: "1.17.6"
modules: true
- railgun
commands:
build: make build
rougecombien: go run services/rougecombien/cmd/rougecombien/main.go dev
Expand Down
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
faktory:
container_name: faktory
image: contribsys/faktory
ports:
- "7419:7419"
- "7420:7420"
trieugene:
container_name: trieugene
build:
context: .
dockerfile: Dockerfile
environment:
TRIEUGENE_FAKTORY_URL: "tcp://faktory:7419"
FAKTORY_URL: "tcp://faktory:7419"
FAKTORY_PROVIDER: "tcp://faktory:7419"
links:
- faktory
rougecombien:
container_name: rougecombien
build:
context: .
dockerfile: services/rougecombien/Dockerfile
environment:
TRIEUGENE_FAKTORY_URL: "tcp://faktory:7419"
FAKTORY_URL: "tcp://faktory:7419"
FAKTORY_PROVIDER: "tcp://faktory:7419"
links:
- faktory
rotondo:
container_name: rotondo
build:
context: .
dockerfile: services/rotondo/Dockerfile
environment:
TRIEUGENE_FAKTORY_URL: "tcp://faktory:7419"
FAKTORY_URL: "tcp://faktory:7419"
FAKTORY_PROVIDER: "tcp://faktory:7419"
links:
- faktory
28 changes: 26 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module github.com/mlhamel/trieugene

go 1.13
go 1.17

require (
cloud.google.com/go v0.71.0 // indirect
cloud.google.com/go/storage v1.12.0
github.com/aws/aws-sdk-go v1.36.28
github.com/contribsys/faktory v1.3.0-1
Expand All @@ -16,8 +15,33 @@ require (
github.com/rs/zerolog v1.20.0
github.com/stretchr/testify v1.7.0
github.com/urfave/cli v1.22.5
)

require (
cloud.google.com/go v0.71.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
go.opencensus.io v0.22.5 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.35.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb // indirect
google.golang.org/grpc v1.33.2 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ github.com/contribsys/faktory_worker_go v1.4.2/go.mod h1:v53dJh0lrk18B/3zFJjAWM6
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -165,10 +164,8 @@ github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
Expand Down Expand Up @@ -251,7 +248,6 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201026091529-146b70c837a4 h1:awiuzyrRjJDb+OXi9ceHO3SDxVoN3JER57mhtqkdQBs=
golang.org/x/net v0.0.0-20201026091529-146b70c837a4/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
Expand All @@ -270,7 +266,6 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -459,11 +454,9 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (c *Config) Environment() environmentType {
}

func (c *Config) FaktoryURL() string {
return GetEnv("TRIEUGENE_FAKTORY_URL", "tcp://trieugene.myshopify.io:7419")
return GetEnv("TRIEUGENE_FAKTORY_URL", "tcp://faktory:7419")
}

func (c *Config) GCSURL() string {
Expand Down
53 changes: 40 additions & 13 deletions pkg/store/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,64 @@ import (
)

type GoogleCloudStorage struct {
cfg *config.Config
client *storage.Client
bucket *storage.BucketHandle
cfg *config.Config
client *storage.Client
bucket *storage.BucketHandle
bucketName string
}

func NewGoogleCloudStorage(ctx context.Context, cfg *config.Config) (Store, error) {
cfg.Logger().Debug().Msgf("NewGoogleCloudStorage: Initiating")
client, err := storage.NewClient(ctx)
if err != nil {
return nil, err
}

bucket := client.Bucket(cfg.BucketName())

instance := GoogleCloudStorage{
cfg: cfg,
client: client,
bucket: bucket,
bucketName: cfg.BucketName(),
cfg: cfg,
client: nil,
bucket: nil,
}

cfg.Logger().Debug().Msgf("NewGoogleCloudStorage: Succeed")

return &instance, nil
}

func (g *GoogleCloudStorage) Initialized() bool {
return g.client != nil && g.bucket != nil
}

func (g *GoogleCloudStorage) Init(ctx context.Context) error {
g.cfg.Logger().Debug().Msgf("Store/GoogleCloudStorage/Init: Start")

if g.Initialized() {
return nil
}
client, err := storage.NewClient(ctx)
if err != nil {
return err
}

g.client = client
g.bucket = g.client.Bucket(g.bucketName)

g.cfg.Logger().Debug().Msgf("GoogleCloudStorage/Init: Success")

return nil
}

func (g *GoogleCloudStorage) Setup(ctx context.Context) error {
return g.bucket.Create(ctx, g.cfg.ProjectID(), nil)
g.cfg.Logger().Debug().Msgf("Store/GoogleCloudStorage/Setup: Start")
err := g.bucket.Create(ctx, g.cfg.ProjectID(), nil)
if err != nil {
return err
}
g.cfg.Logger().Debug().Msgf("Store/GoogleCloudStorage/Setup: Start")
return nil
}

func (g *GoogleCloudStorage) Persist(ctx context.Context, filename string, data string) error {
g.cfg.Logger().Debug().Msgf("Store/GoogleCloudStorage/Persist: Start")
g.Init(ctx)

object := g.bucket.Object(filename)
w := object.NewWriter(ctx)
reader := bytes.NewReader([]byte(data))
Expand Down
6 changes: 4 additions & 2 deletions pkg/store/gcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ func TestNewGoogleCloudStorage(t *testing.T) {

func TestGoogleCloudStorageSetup(t *testing.T) {
ctx := context.Background()
store, _ := NewGoogleCloudStorage(ctx, config.NewConfig())

err := store.Setup(ctx)
store, err := NewGoogleCloudStorage(ctx, config.NewConfig())
require.NoError(t, err)

err = store.Setup(ctx)

require.NoError(t, err)
}
24 changes: 0 additions & 24 deletions railgun.yml

This file was deleted.

9 changes: 9 additions & 0 deletions services/rotondo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.17.6-alpine3.15 AS base

WORKDIR /go/src/rotondo
COPY . .
ADD go.mod .
RUN go get -d -v ./...
RUN go install -v ./...

CMD ["rotondo", "dev"]
9 changes: 9 additions & 0 deletions services/rougecombien/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.17.6-alpine3.15 AS base

WORKDIR /go/src/rougecombien
COPY . .
ADD go.mod .
RUN go get -d -v ./...
RUN go install -v ./...

CMD ["rougecombien", "dev"]

0 comments on commit 1761e0f

Please sign in to comment.