diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4a92e55 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +# these don't end up in the final image, but no need to consider them in the build context +*.md +LICENSE +images +ui diff --git a/Dockerfile b/Dockerfile index 3e0e7c3..e96ae91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:latest +FROM golang:latest AS builder LABEL app="slo-tracker" LABEL maintainer="roshan.aloor@gmail.com" @@ -8,9 +8,16 @@ LABEL description="slo-tracker : Track your product SLO" WORKDIR /app COPY . . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/slo-tracker . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o /app/slo-tracker . +FROM scratch + +# we don't need these certs for local development, but we copy in case you want +# to use this image for a production environment +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=builder /app/slo-tracker /app/slo-tracker + EXPOSE 8080 -CMD /app/slo-tracker \ No newline at end of file +CMD ["/app/slo-tracker"]