From 8d9a8532e2ef8452eaf8236d4d846e95d198f08e Mon Sep 17 00:00:00 2001 From: Abdul Raqueeb Date: Sat, 11 Jan 2025 19:23:09 +0530 Subject: [PATCH] Create Dockerfile --- Dockerfile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..49ae73694 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM golang:1.22 as base + +# Set the working directory inside the container +WORKDIR /app + +# Copy the go.mod and go.sum files to the working directory +COPY go.mod ./ + +# Download all the dependencies +RUN go mod download + +# Copy the source code to the working directory +COPY . . + +# Build the application +RUN go build -o main . + +####################################################### +# Reduce the image size using multi-stage builds +# We will use a distroless image to run the application +FROM gcr.io/distroless/base + +# Copy the binary from the previous stage +COPY --from=base /app/main . + +# Copy the static files from the previous stage +COPY --from=base /app/static ./static + +# Expose the port on which the application will run +EXPOSE 8080 + +# Command to run the application +CMD ["./main"]