From c003a33d8beb431517cedd950f8e70bfe48f52d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Ziad=C3=A9?= Date: Thu, 31 Aug 2023 21:33:56 +0300 Subject: [PATCH] Add Dockerfile for building and running Go application --- Dockerfile | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..99205da --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Use the official Go image +FROM golang:1.19 AS build + +# Set the working directory +WORKDIR /app + +# Copy go mod and sum files +COPY go.mod go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy source code +COPY . . + +# Build the application +RUN go build -o main . + +# Use a lightweight image for deployment +FROM alpine:latest AS runtime + +# Install necessary libraries +RUN apk --no-cache add ca-certificates + +# Copy binary +COPY --from=build /app/main /app/ + +# Set the working directory +WORKDIR /app + +# Run the application +CMD [". --download-only"]