From f63411188673033a7f24e5faa6d3b4b38819182c Mon Sep 17 00:00:00 2001 From: William Date: Tue, 20 Aug 2024 12:41:45 +0100 Subject: [PATCH] chore(build): add makefile, fix and publish docker image --- Dockerfile | 2 +- Makefile | 9 +++++++++ internal/adapter/repository/memdb_repository_test.go | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index 97e57e2..3103d96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ COPY . . # statically compile the go binary for the presumed target of amd64 linux # whilst its larger, its more portable and will run in a scratch container -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o api-server ./cmd/api-server +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o api-server ./cmd/api # hack to create the nobody user for the scratch container. # hadolint ignore=DL3059 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a144b78 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +.PHONY: test build build-docker +test: + go test -v ./... + +build: + go build cmd/api/main.go + +build-docker: + docker build --platform linux/amd64 -t willejs/port-service:latest . diff --git a/internal/adapter/repository/memdb_repository_test.go b/internal/adapter/repository/memdb_repository_test.go index e24f7fe..b308eb5 100644 --- a/internal/adapter/repository/memdb_repository_test.go +++ b/internal/adapter/repository/memdb_repository_test.go @@ -1,6 +1,8 @@ package repository_test import ( + "log/slog" + "os" "testing" "github.com/stretchr/testify/assert" @@ -10,7 +12,8 @@ import ( ) func TestMemDBPortRepository_GetAllPorts(t *testing.T) { - db, err := memdb.NewMemDB() + logger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) + db, err := memdb.NewMemDB(logger) assert.NoError(t, err) // Create the repository repo := repository.NewMemDBPortRepository(db)