From 3afbe2044ed866f024224923f251fa6b6d67b2c4 Mon Sep 17 00:00:00 2001 From: Florian Beisel Date: Wed, 10 Jan 2024 01:11:25 +0100 Subject: [PATCH] fix: Dockerfile now builds a usable image --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ce3b69..436a1d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,23 @@ # Start from a Go base image -FROM golang:latest as builder +FROM golang:alpine3.19 AS builder # Set the working directory WORKDIR /app # Copy the source code into the container COPY . . +RUN go mod download # Build the application -RUN go build -o mybot . +RUN CGO_ENABLED=0 GOOS=linux go build -o mybot . # Use a small base image -FROM alpine:latest +FROM alpine:edge -WORKDIR /root/ +WORKDIR /app/ # Copy the binary from the builder stage -COPY --from=builder /app/mybot . +COPY --from=builder /app/mybot /app/ # Command to run the executable CMD ["./mybot"]