feat: add Dockerfile

This commit is contained in:
Urko. 2024-02-23 07:55:21 +01:00
parent 3678d0457c
commit 760a95c3ba
1 changed files with 29 additions and 0 deletions

29
Dockerfile Normal file
View File

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