diff --git a/Dockerfile b/Dockerfile index 943bcad..2cbb5e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,24 @@ -FROM golang:1.22.5 AS builder +FROM golang:alpine AS builder -WORKDIR /app +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 -COPY go.mod go.sum ./ +WORKDIR /build -RUN go mod download +COPY go.mod go.sum ./cmd/main.go ./ -COPY . . +RUN go mod download +RUN go build -o techbloghub-server . -RUN CGO_ENABLED=0 GOOS=linux go build -o myapp . +WORKDIR /dist -FROM alpine:latest +RUN cp /build/techbloghub-server . -WORKDIR /root/ +FROM scratch -COPY --from=builder /app/myapp . +COPY --from=builder /dist/techbloghub-server /techbloghub-server -CMD ["./myapp"] +EXPOSE 8080 +ENTRYPOINT ["/techbloghub-server"] \ No newline at end of file