diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..fa0a76fde --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM golang:1.22.5 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"] diff --git a/go.mod b/go.mod index d23044355..b25d03c88 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/iam-veeramalla/go-web-app +module https://github.com/iamraqueeb/go-web-app go 1.22.5