diff --git a/backend/dockerfile b/backend/dockerfile index 7da819f..ec3bbcb 100644 --- a/backend/dockerfile +++ b/backend/dockerfile @@ -18,14 +18,26 @@ COPY . . # RUN go mod download # RUN go mod verify -RUN GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main . +RUN apt-get update && apt-get install -y \ + gcc \ + libc6-dev + +RUN GOFLAGS=-mod=vendor \ + CGO_ENABLED=1 \ + GOOS=linux \ + GOARCH=amd64 \ + CGO_LDFLAGS="-static -w -s" \ + go build \ + -ldflags '-extldflags "-static"' \ + -o main . # Final stage # Pick your poison # Ordered by size desc # FROM ubuntu:latest -# FROM alpine:latest -FROM scratch +FROM alpine:latest +# FROM scratch +RUN apk add --no-cache libc6-compat # Run this for ubuntu # RUN apt-get update && apt-get install -y curl vim git && apt-get clean @@ -40,6 +52,5 @@ COPY --from=base /etc/group /etc/group # Use the non-root user # USER small-user -EXPOSE 8090 CMD ["/main"] \ No newline at end of file