From e97f59a570ada6d71c4291cc275163834f3db542 Mon Sep 17 00:00:00 2001 From: Artem Titoulenko Date: Fri, 24 Dec 2021 15:17:07 -0500 Subject: [PATCH] attempting to reduce docker image size --- Dockerfile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index daca241..331a76a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,14 @@ -from golang:1.17-alpine3.14 +FROM golang:1.17-alpine3.14 AS build -workdir /app -copy go.mod go.sum /app -run go mod download +WORKDIR /app +COPY go.mod go.sum /app +RUN (([ ! -d "/app/vendor" ] && go mod download && go mod vendor) || true) -copy . /app -run go build -o /app/aim +COPY . /app +RUN go build -ldflags="-s -w" -mod vendor -o "aim" main.go +RUN chmod +x "aim" + +FROM scratch AS prod EXPOSE 5190 ARG OSCAR_HOST @@ -13,4 +16,5 @@ ARG OSCAR_PORT ARG OSCAR_BOS_HOST ARG OSCAR_BOS_PORT -cmd /app/aim +COPY --from=build /app/aim /app/aim +ENTRYPOINT /app/aim