# Dockerfile for Geek-Life v2.0 Multi-Tenant
FROM golang:1.19-alpine AS builder

WORKDIR /app

# Install dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
COPY . .

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o geek-life app/*.go

# Final stage
FROM alpine:latest

RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/

# Copy the binary
COPY --from=builder /app/geek-life .
COPY --from=builder /app/migrations ./migrations/
COPY --from=builder /app/.env.example .

# Create non-root user
RUN adduser -D -s /bin/sh geeklife
USER geeklife

EXPOSE 8080

CMD ["./geek-life"]