From afd705b1c53093d553828b116761e41768e4dc7f Mon Sep 17 00:00:00 2001 From: protolambda Date: Fri, 7 Aug 2020 02:37:15 +0200 Subject: [PATCH] scratch docker amd64 --- Dockerfile | 17 ++++++++--------- Makefile | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 260bc32..0657cf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ -# build for amd64 -FROM golang:1.13.5 AS build +FROM golang:alpine as build -ENV ROOT "/tmp/eth2stats-client" +RUN apk add --no-cache ca-certificates build-base -WORKDIR $ROOT +WORKDIR /build ADD go.mod go.mod ADD go.sum go.sum @@ -12,13 +11,13 @@ ADD . . RUN make build -# create application container for amd64 -FROM ubuntu +FROM scratch -RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* +COPY --from=build /etc/ssl/certs/ca-certificates.crt \ + /etc/ssl/certs/ca-certificates.crt -WORKDIR / +COPY --from=build /build/eth2stats-client /eth2stats-client -COPY --from=build /tmp/eth2stats-client/eth2stats-client . +WORKDIR / ENTRYPOINT ["/eth2stats-client"] diff --git a/Makefile b/Makefile index 3d9e7ea..dd3b2a3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION := "$(shell git describe --abbrev=0 --tags 2> /dev/null || echo 'v0.0.0')+$(shell git rev-parse --short HEAD)" build: - go build -ldflags "-X main.buildVersion=$(VERSION)" + go build -ldflags "-X main.buildVersion=$(VERSION) -extldflags "-static"" -o eth2stats-client run: go run main.go