From 5c8ab0671dfa917d2dc050adbcf0c6616ad89b2b Mon Sep 17 00:00:00 2001 From: Mitch Kelley Date: Sun, 5 May 2019 07:48:11 -0400 Subject: [PATCH] use multistage build, pass macos dwarf flag for local dev --- catalog-go/.gitignore | 2 ++ catalog-go/Dockerfile | 11 +++++++---- catalog-go/Makefile | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 catalog-go/.gitignore create mode 100644 catalog-go/Makefile diff --git a/catalog-go/.gitignore b/catalog-go/.gitignore new file mode 100644 index 0000000..e9e2c28 --- /dev/null +++ b/catalog-go/.gitignore @@ -0,0 +1,2 @@ + +*.out \ No newline at end of file diff --git a/catalog-go/Dockerfile b/catalog-go/Dockerfile index 5eb7a7e..758ba86 100644 --- a/catalog-go/Dockerfile +++ b/catalog-go/Dockerfile @@ -1,9 +1,12 @@ -FROM golang:1.12 - +FROM golang:1.12 as builder WORKDIR /go/src/app COPY . /go/src/app RUN go get -d -v ./... -RUN go install -v ./... +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags "-N -l" -ldflags="-compressdwarf=false" -o catalog-go . -CMD ["app"] \ No newline at end of file +FROM alpine:3.9 +COPY --from=builder /go/src/app /app +WORKDIR /app +EXPOSE 8080 +CMD ["/app/catalog-go"] \ No newline at end of file diff --git a/catalog-go/Makefile b/catalog-go/Makefile new file mode 100644 index 0000000..b4ffb2e --- /dev/null +++ b/catalog-go/Makefile @@ -0,0 +1,4 @@ + +.PHONY: compile-local +compile-local: + CGO_ENABLED=0 go build -gcflags "-N -l" -ldflags="-compressdwarf=false" -o catalog-go.out .