From 3724571b052870679cf59d50cfe55827cb2e1aee Mon Sep 17 00:00:00 2001 From: iamjooon2 Date: Thu, 22 Aug 2024 13:37:10 +0900 Subject: [PATCH] test --- Dockerfile | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f50246..cf44ae1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,19 @@ -# syntax=docker/dockerfile:1 +FROM golang:alpine AS builder -FROM golang:1.22.5 +ENV GO1225MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 -# Set destination for COPY -WORKDIR /app +WORKDIR /build +COPY go.mod go.sum main.go ./ -# Download Go modules -COPY go.mod go.sum ./ -RUN go mod tidy +RUN go mod download +RUN go build -o main . -# Copy the source code. Note the slash at the end, as explained in -# https://docs.docker.com/reference/dockerfile/#copy -COPY *.go ./ +WORKDIR /dist +RUN cp /build/main . -# Build -RUN CGO_ENABLED=1 GOOS=linux go build -o /techbloghub - -# Optional: -# To bind to a TCP port, runtime parameters must be supplied to the docker command. -# But we can document in the Dockerfile what ports -# the application is going to listen on by default. -# https://docs.docker.com/reference/dockerfile/#expose -EXPOSE 8080 - -# Run -CMD ["/techbloghub"] +FROM scratch +COPY --from=builder /dist/main . +ENTRYPOINT ["/techbloghub"] \ No newline at end of file