dev: add Makefile

This commit is contained in:
Mohamed Sohail 2023-03-08 17:19:33 +03:00 committed by GitHub
parent bbd4b57fa8
commit b8583c57ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 5 deletions

View File

@ -14,6 +14,7 @@ RUN go mod download
COPY . .
RUN go build -o cic-custodial -ldflags="-X main.build=${BUILD_COMMIT} -s -w" cmd/service/*
FROM debian:bullseye-slim
ENV DEBIAN_FRONTEND=noninteractive
@ -25,6 +26,7 @@ COPY --from=build /build/cic-custodial .
COPY migrations migrations/
COPY config.toml .
COPY queries.sql .
COPY LICENSE .
EXPOSE 5000

17
Makefile Normal file
View File

@ -0,0 +1,17 @@
BIN := cic-custodial
BUILD_CONF := CGO_ENABLED=1 GOOS=linux GOARCH=amd64
BUILD_COMMIT := $(git rev-parse --short HEAD)
.PHONY: build
clean:
rm ${BIN}
build:
${BUILD_CONF} go build -ldflags="-X main.build=${BUILD_COMMIT} -s -w" -o ${BIN} cmd/service/*
run:
${BUILD_CONF} go run cmd/service/*
run-debug:
${BUILD_CONF} go run cmd/service/* -debug

View File

@ -212,6 +212,7 @@ func initPub(jsCtx nats.JetStreamContext) *pub.Pub {
return pub
}
func initSub(natsConn *nats.Conn, jsCtx nats.JetStreamContext, cu *custodial.Custodial) *sub.Sub {
sub, err := sub.NewSub(sub.SubOpts{
CustodialContainer: cu,

View File

@ -46,6 +46,8 @@ func init() {
}
func main() {
lo.Info("main: starting cic-custodial", "build", build)
parsedQueries := initQueries()
celoProvider := initCeloProvider()
postgresPool := initPostgresPool()

View File

@ -8,8 +8,8 @@ import (
)
const (
StreamName string = "CUSTODIAL"
StreamSubjects string = "CUSTODIAL.*"
streamName string = "CUSTODIAL"
streamSubjects string = "CUSTODIAL.*"
AccountNewNonce string = "CUSTODIAL.accountNewNonce"
AccountRegister string = "CUSTODIAL.accountRegister"
AccountGiftGas string = "CUSTODIAL.systemNewAccountGas"
@ -39,13 +39,13 @@ type (
)
func NewPub(o PubOpts) (*Pub, error) {
stream, _ := o.JsCtx.StreamInfo(StreamName)
stream, _ := o.JsCtx.StreamInfo(streamName)
if stream == nil {
_, err := o.JsCtx.AddStream(&nats.StreamConfig{
Name: StreamName,
Name: streamName,
MaxAge: o.PersistDuration,
Storage: nats.FileStorage,
Subjects: []string{StreamSubjects},
Subjects: []string{streamSubjects},
Duplicates: o.DedupDuration,
})
if err != nil {