Dockerfile.client 763 B

12345678910111213141516171819202122232425262728293031323334353637
  1. FROM golang:1.24-alpine AS builder
  2. # Set working directory
  3. WORKDIR /app
  4. # Copy go mod files first for better caching
  5. COPY go.mod go.sum ./
  6. RUN go mod download
  7. # Copy source code
  8. COPY . .
  9. # Build the client
  10. RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o client ./test/postgres/client.go
  11. # Final stage
  12. FROM alpine:latest
  13. # Install ca-certificates and netcat for health checks
  14. RUN apk --no-cache add ca-certificates netcat-openbsd
  15. WORKDIR /root/
  16. # Copy the binary from builder stage
  17. COPY --from=builder /app/client .
  18. # Make it executable
  19. RUN chmod +x ./client
  20. # Set environment variables with defaults
  21. ENV POSTGRES_HOST=localhost
  22. ENV POSTGRES_PORT=5432
  23. ENV POSTGRES_USER=seaweedfs
  24. ENV POSTGRES_DB=default
  25. # Run the client
  26. CMD ["./client"]