-
Notifications
You must be signed in to change notification settings - Fork 401
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
8ed9baa
commit e8ea4e6
Showing
12 changed files
with
241 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
app: | ||
name: 'counter-service' | ||
version: '1.0.0' | ||
|
||
http: | ||
host: '0.0.0.0' | ||
port: 5002 | ||
|
||
rabbit_mq: | ||
url: amqp://guest:guest@172.28.191.206:5672/ | ||
|
||
logger: | ||
log_level: 'debug' | ||
rollbar_env: 'counter-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
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
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,24 @@ | ||
# 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/barista | ||
|
||
# Step 3: Final | ||
FROM scratch | ||
|
||
# COPY --from=builder /app/config /config | ||
# COPY --from=builder /app/migrations /migrations | ||
|
||
# GOPATH for scratch images is / | ||
COPY --from=builder /app/cmd/barista/config.yml / | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 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/counter | ||
|
||
# Step 3: Final | ||
FROM scratch | ||
|
||
EXPOSE 5002 | ||
|
||
# COPY --from=builder /app/config /config | ||
# COPY --from=builder /app/migrations /migrations | ||
|
||
# GOPATH for scratch images is / | ||
COPY --from=builder /app/cmd/counter/config.yml / | ||
COPY --from=builder /bin/app /app | ||
CMD ["/app"] |
Oops, something went wrong.