diff --git a/api/Dockerfile b/api/Dockerfile index 56d3b2c..f546b5c 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,31 +1,34 @@ # Stage 1: Build the application -FROM golang:1.25.3-alpine AS builder +FROM golang:1.25.3-alpine AS base +FROM base AS builder +COPY . /app WORKDIR /app # Copy go.mod and go.sum first to leverage Docker's caching -COPY go.mod go.sum ./ +ENV GOPROXY=direct +RUN apk add git RUN go mod download -# Copy the rest of the application source code -COPY . . - # Build the Go application # CGO_ENABLED=0 disables Cgo for a fully static binary # -a links all packages statically # -installsuffix cgo_non_shared avoids issues with shared libraries -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo_non_shared -o main . +RUN CGO_ENABLED=0 GOOS=linux go build + +RUN ls -al # Stage 2: Create the final lean image -FROM alpine:latest +FROM base WORKDIR /root/ # Copy the built binary from the builder stage -COPY --from=builder /app/main . - +COPY --from=builder /app/ordr-api . +COPY --from=builder /app/.env . # Expose the port your Gin application listens on (e.g., 8080) EXPOSE 8080 # Command to run the application -CMD ["./ordr-api"] \ No newline at end of file +ENV GIN_MODE=release +CMD ["./ordr-api"] diff --git a/api/main.go b/api/main.go index 3fc26cd..1e1db5e 100644 --- a/api/main.go +++ b/api/main.go @@ -59,7 +59,8 @@ func main() { authenticator, auth_err := auth.New() if auth_err != nil { - log.Fatal("ERROR: Failed to initialize Authenticator") + log.Printf("ERROR: Failed to initialize Authenticator %s", auth_err.Error()) + log.Fatal("ERROR: Failed to initialize authenticator...") return }