From 694757b87da97e7a02c23cb1f78b84f31469543d Mon Sep 17 00:00:00 2001 From: HAHWUL Date: Sat, 7 Dec 2024 23:49:50 +0900 Subject: [PATCH] Refactor Dockerfile to improve multi-stage build process and update base image Signed-off-by: HAHWUL --- Dockerfile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 529c8db4..19cc9cd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,22 @@ -# BUILDER +# === BUILDER === FROM golang:latest AS builder WORKDIR /go/src/app -COPY . . -RUN go get -d -v ./... +# Install dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the source code +COPY . . RUN go build -o dalfox -# RUNNING -FROM debian:buster +# === RUNNER === +FROM debian:bookworm RUN mkdir /app + +# Copy the binary from the builder stage COPY --from=builder /go/src/app/dalfox /app/dalfox COPY --from=builder /go/src/app/samples /app/samples + WORKDIR /app/ CMD ["/app/dalfox"]