-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52d588f
commit 117bf3c
Showing
17 changed files
with
437 additions
and
27 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
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,14 +1,14 @@ | ||
app: | ||
name: 'counter-service' | ||
name: 'barista-service' | ||
version: '1.0.0' | ||
|
||
http: | ||
host: '0.0.0.0' | ||
port: 5002 | ||
|
||
rabbit_mq: | ||
url: amqp://guest:guest@172.25.33.104:5672/ | ||
url: amqp://guest:guest@172.28.255.101:5672/ | ||
|
||
logger: | ||
log_level: 'debug' | ||
rollbar_env: 'counter-service' | ||
rollbar_env: 'barista-service' |
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
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,14 @@ | ||
app: | ||
name: 'kitchen-service' | ||
version: '1.0.0' | ||
|
||
http: | ||
host: '0.0.0.0' | ||
port: 5004 | ||
|
||
rabbit_mq: | ||
url: amqp://guest:[email protected]:5672/ | ||
|
||
logger: | ||
log_level: 'debug' | ||
rollbar_env: 'kitchen-service' |
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,47 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/ilyakaznacheev/cleanenv" | ||
configs "github.com/thangchung/go-coffeeshop/pkg/config" | ||
) | ||
|
||
type ( | ||
Config struct { | ||
configs.App `yaml:"app"` | ||
configs.HTTP `yaml:"http"` | ||
configs.Log `yaml:"logger"` | ||
RabbitMQ `yaml:"rabbit_mq"` | ||
} | ||
|
||
RabbitMQ struct { | ||
URL string `env-required:"true" yaml:"url" env:"RABBITMQ_URL"` | ||
} | ||
) | ||
|
||
func NewConfig() (*Config, error) { | ||
cfg := &Config{} | ||
|
||
dir, err := os.Getwd() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// debug | ||
fmt.Println(dir) | ||
|
||
err = cleanenv.ReadConfig(dir+"/config.yml", cfg) | ||
if err != nil { | ||
return nil, fmt.Errorf("config error: %w", err) | ||
} | ||
|
||
err = cleanenv.ReadEnv(cfg) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return cfg, nil | ||
} |
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,25 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/golang/glog" | ||
"github.com/thangchung/go-coffeeshop/cmd/kitchen/config" | ||
"github.com/thangchung/go-coffeeshop/internal/kitchen/app" | ||
mylog "github.com/thangchung/go-coffeeshop/pkg/logger" | ||
) | ||
|
||
func main() { | ||
cfg, err := config.NewConfig() | ||
if err != nil { | ||
glog.Fatal(err) | ||
} | ||
|
||
logger := mylog.New(cfg.Level) | ||
|
||
a := app.New(logger, cfg) | ||
if err = a.Run(); err != nil { | ||
glog.Fatal(err) | ||
os.Exit(1) | ||
} | ||
} |
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
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
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
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,22 @@ | ||
# Step 1: Modules caching | ||
FROM golang:1.19.2-alpine3.16 as modules | ||
COPY go.mod go.sum /modules/ | ||
WORKDIR /modules | ||
RUN go mod download | ||
|
||
# Step 2: Builder | ||
FROM golang:1.19.2-alpine3.16 as builder | ||
COPY --from=modules /go/pkg /go/pkg | ||
COPY . /app | ||
WORKDIR /app | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ | ||
go build -tags migrate -o /bin/app ./cmd/kitchen | ||
|
||
# Step 3: Final | ||
FROM scratch | ||
|
||
# GOPATH for scratch images is / | ||
COPY --from=builder /app/cmd/kitchen/config.yml / | ||
COPY --from=builder /app/db/migrations /db/migrations | ||
COPY --from=builder /bin/app /app | ||
CMD ["/app"] |
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
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
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
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.