Skip to content

Commit

Permalink
Merge pull request #3 from mlhamel/feature/introduce-docker-compose-s…
Browse files Browse the repository at this point in the history
…upport

Introduce docker-compose support and deprecat railgun.
  • Loading branch information
mlhamel authored Apr 22, 2022
2 parents 29d418c + 0799272 commit 4cee859
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 135 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
36 changes: 27 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
module github.com/mlhamel/trieugene

go 1.13
go 1.17

require (
cloud.google.com/go/iam v0.3.0 // indirect
cloud.google.com/go/storage v1.21.0
github.com/aws/aws-sdk-go v1.43.14
github.com/benbjohnson/ego v0.4.0 // indirect
github.com/contribsys/faktory v1.6.0
github.com/contribsys/faktory_worker_go v1.6.0
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
github.com/go-co-op/gocron v1.13.0
github.com/gocarina/gocsv v0.0.0-20220304222734-caabc5f00d30
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/gorilla/mux v1.8.0
github.com/jstemmer/go-junit-report v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3
github.com/pior/runnable v0.8.0
github.com/rs/zerolog v1.26.1
github.com/stretchr/testify v1.7.0
github.com/urfave/cli v1.22.5
)

require (
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.5.0 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7 // indirect
golang.org/x/tools v0.1.9 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.71.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220308174144-ae0e22291548 // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
83 changes: 0 additions & 83 deletions go.sum

Large diffs are not rendered by default.

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 4cee859

Please sign in to comment.