From 07f4b88b53c4c21c576a11347a6cbba47bce3103 Mon Sep 17 00:00:00 2001 From: Alexandre Peixoto Ferreira Date: Sun, 11 Sep 2022 09:39:34 -0500 Subject: [PATCH] Compile device-manager statically and use scratch base image Signed-off-by: Alexandre Peixoto Ferreira --- Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d9fafd7..a54074c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,15 +10,13 @@ COPY . . RUN echo $PATH;export CGO_LDFLAGS_ALLOW='-Wl,--unresolved-symbols=ignore-in-object-files' && \ go mod init arm.com/smarter-device-management && go mod tidy && go mod vendor && \ - go build -ldflags="-s -w" . + CGO_ENABLED=0 go build -ldflags='-s -w -extldflags="-static"' . -FROM alpine - -RUN apk update && apk upgrade +FROM scratch WORKDIR /root COPY conf.yaml /root/config/conf.yaml COPY --from=build /arm.com/smarter-device-management/smarter-device-management /usr/bin/smarter-device-management -CMD ["smarter-device-management","-logtostderr=true","-v=0"] +CMD ["/usr/bin/smarter-device-management","-logtostderr=true","-v=0"]