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"]