From a76223cbbab4d5c6089afeffdac128d2fdbf1b58 Mon Sep 17 00:00:00 2001 From: Masahiro Sano Date: Sun, 12 Mar 2023 16:22:16 +0900 Subject: [PATCH] add dockerfile (#85) --- Dockerfile | 15 +++++++++++++++ Makefile | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c68f666 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM golang:1.18 as build + +ARG VERSION + +WORKDIR /go/src/app +COPY . . + +RUN go mod download +RUN CGO_ENABLED=0 go build \ + -ldflags "-s -w -X github.com/cloudspannerecosystem/wrench/cmd.version=${VERSION}" \ + -o /go/bin/app/wrench + +FROM gcr.io/distroless/static-debian11 +COPY --from=build /go/bin/app/wrench / +ENTRYPOINT ["/wrench"] diff --git a/Makefile b/Makefile index 9e41559..9039eaf 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ SPANNER_EMULATOR_HOST_REST := localhost:9020 export SPANNER_PROJECT_ID ?= wrench-test-project export SPANNER_INSTANCE_ID ?= wrench-test-instance +REGISTRY := mercari/wrench + .PHONY: test test: go test -race -v ./... @@ -21,3 +23,6 @@ build: setup-emulator: curl -s "${SPANNER_EMULATOR_HOST_REST}/v1/projects/${SPANNER_PROJECT_ID}/instances" --data '{"instanceId": "'${SPANNER_INSTANCE_ID}'"}' + +docker-build: + docker build . -t $(REGISTRY):$(VERSION) --build-arg VERSION=$(VERSION)