# Build stage
FROM golang:1.21-alpine AS builder

WORKDIR /app

# Copy go mod and sum files
COPY src/go.mod src/go.sum .

# Download dependencies
RUN go mod download

# Copy source code
COPY ./src/ .

# Build the application
RUN go build -o sheetless-server 

# Runtime stage
FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /app/

# Copy the binary from builder
COPY --from=builder /app .

# Expose port
EXPOSE 8080

# Run the application
CMD ["./sheetless-server"]
