# Stage 1: Build the Go binary
FROM debian:bookworm-slim AS builder

# Install necessary dependencies for building Go
#RUN apt-get update && apt-get install -y gcc git

# Set environment variables for Golang
ENV GO_VERSION=1.19.0
ENV GOPATH=/home/godsp/
ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
ENV GO111MODULE="off"

# Copy Golang binary and project files
COPY go /usr/local/go
COPY godsp /home/godsp
#COPY godotenv  /home/godsp/src/github.com/joho/godotenv

# Set the working directory to the Go project directory
WORKDIR /home/godsp/dsp-main

# Verify Go installation and build the Go binary
RUN go version
RUN go build -o main main.go

# Stage 2: Create the final image with a smaller base
FROM debian:bookworm-slim
RUN mkdir -p /root/go/log

# Copy the built Go binary from the builder stage
COPY --from=builder /home/godsp/dsp-main/main /usr/local/bin/main

COPY godsp/dsp-main/configuration.env /usr/local/bin/configuration.env

# Set the default working directory
WORKDIR /usr/local/bin

# Default command to run the Go binary
CMD ["./main"]

