diff --git a/Makefile b/Makefile index 89a4a70..1f55ba7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,16 @@ +SHELL=/usr/bin/env bash + +ANTS_REPO?=github.com/probe-lab/ashby +ANTS_COMMIT?=839c2f242c67825ff7884515e929c7ba5b16e84e + +TAG?=$(shell date +%F)-$(shell echo -n ${ANTS_REPO}-${ANTS_COMMIT} | sha256sum - | cut -c -8)-$(shell git describe --always --tag --dirty) +IMAGE_NAME?=probelab:ants-${TAG} +REPO?=019120760881.dkr.ecr.us-east-1.amazonaws.com +REPO_USER?=AWS +REPO_REGION?=us-east-1 + + + tools: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.15.2 go install github.com/volatiletech/sqlboiler/v4@v4.13.0 @@ -11,3 +24,14 @@ migrate-up: migrate-down: migrate -database 'postgres://ants_watch:password@localhost:5432/ants_watch?sslmode=disable' -path db/migrations down + +.PHONY: build +build: + echo ${TAG} + docker build --platform="linux/amd64" -t ${IMAGE_NAME} . + +.PHONY: push +push: + aws ecr get-login-password --profile probelab --region ${REPO_REGION} | docker login --username ${REPO_USER} --password-stdin ${REPO} + docker tag ${IMAGE_NAME} ${REPO}/${IMAGE_NAME} + docker push ${REPO}/${IMAGE_NAME} diff --git a/db/client_db.go b/db/client_db.go index e6e173b..a094b7a 100644 --- a/db/client_db.go +++ b/db/client_db.go @@ -184,7 +184,7 @@ func partitionQuery(table string, lower time.Time, upper time.Time) string { } func (c *DBClient) applyMigrations(cfg *config.Database, Handler *sql.DB) { - tmpDir, err := os.MkdirTemp("", "nebula") + tmpDir, err := os.MkdirTemp("", "ants-watch") if err != nil { log.WithError(err).WithField("pattern", "ants-watch").Warnln("Could not create tmp directory for migrations") return diff --git a/queen.go b/queen.go index aef3d9e..e385481 100644 --- a/queen.go +++ b/queen.go @@ -26,10 +26,10 @@ import ( "github.com/volatiletech/null/v8" "github.com/dennis-tra/nebula-crawler/maxmind" - "github.com/dennis-tra/nebula-crawler/tele" "github.com/dennis-tra/nebula-crawler/udger" "github.com/probe-lab/ants-watch/db" "github.com/probe-lab/ants-watch/db/models" + tele "github.com/probe-lab/ants-watch/metrics" ) var logger = log.Logger("ants-queen") @@ -105,7 +105,18 @@ func getDbClient(ctx context.Context) *db.DBClient { } mP, _ := tele.NewMeterProvider() - tP, _ := tele.NewTracerProvider(ctx, "", 0) + + tracesPort := os.Getenv("TRACES_PORT") + tracesPortAsInt, err := strconv.Atoi(tracesPort) + if err != nil { + logger.Errorf("Port must be an integer: %w", err) + } + + tP, _ := tele.NewTracerProvider( + ctx, + os.Getenv("TRACES_HOST"), + tracesPortAsInt, + ) dbc, err := db.InitDBClient(ctx, &config.Database{ DatabaseHost: os.Getenv("DB_HOST"),