From b6b899f1cebb25c74b3281941b771c7f259425b9 Mon Sep 17 00:00:00 2001 From: Levatax <levatax@randomchars.net> Date: Sat, 19 Oct 2024 11:28:44 +0000 Subject: [PATCH] build: add Dockerfile --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..69706ca --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# Start from the official Golang image +FROM golang:1.22-alpine as builder + +# Set the working directory inside the container +WORKDIR /app + +# Install necessary packages +RUN apk add --no-cache git + +# Copy go.mod and go.sum files to install dependencies +COPY go.mod go.sum ./ + +# Download and cache dependencies +RUN go mod download + +# Copy the rest of the application source code +COPY . . + +# Build the application +RUN go build -o waitlist . + +# Start a new minimal image for the application +FROM alpine:latest + +# Set the working directory inside the new container +WORKDIR /app + +# Install necessary packages in the minimal image +RUN apk add --no-cache ca-certificates + +# Copy the built binary from the previous stage +COPY --from=builder /app/waitlist . + +# Expose the port the app runs on +EXPOSE 3000 + +# Run the application +CMD ["./waitlist"] \ No newline at end of file -- GitLab