# Builder image
FROM --platform=linux/amd64 golang:1.21 as builder

WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN go build -mod=readonly -v -o pactual-backend main.go

# Runtime image
FROM --platform=linux/amd64 golang:1.21

WORKDIR /app

# Copy the binary from the builder stage
COPY --from=builder /src/pactual-backend .

# Copy the app/views/qor folder
COPY app/views/qor /app/app/views/qor

CMD ["/app/pactual-backend"]
