From 760a95c3ba90020c9220be70e4b73c631be0dc0d Mon Sep 17 00:00:00 2001 From: "Urko." Date: Fri, 23 Feb 2024 07:55:21 +0100 Subject: [PATCH] feat: add Dockerfile --- Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..283b48e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Use the official Go image as a parent image +FROM golang:1.22 as builder + +# Set the working directory inside the container +WORKDIR /app + +# Copy the go.mod and go.sum files +COPY go.* ./ + +# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed +RUN go mod download + +# Copy the source code into the container +COPY . . + +# Build the application +RUN CGO_ENABLED=0 GOOS=linux go build -v -o btcpaychecker cmd/btcpaychecker/main.go + +# Use the alpine image for a smaller footprint +FROM alpine:latest +RUN apk --no-cache add ca-certificates + +WORKDIR /root/ + +# Copy the pre-built binary file from the previous stage +COPY --from=builder /app/btcpaychecker . + +# Command to run the executable +CMD ["./btcpaychecker"]