Dockerfile.test-client 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Multi-stage build for Test Client
  2. FROM golang:1.23-alpine AS builder
  3. # Install build dependencies
  4. RUN apk add --no-cache git ca-certificates tzdata
  5. # Set work directory
  6. WORKDIR /app
  7. # Copy go mod files
  8. COPY go.mod go.sum ./
  9. # Download dependencies
  10. RUN go mod download
  11. # Copy source code
  12. COPY cmd/ ./cmd/
  13. COPY pkg/ ./pkg/
  14. # Build the test binaries
  15. RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o test-rdma ./cmd/test-rdma
  16. RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o demo-server ./cmd/demo-server
  17. # Runtime stage
  18. FROM alpine:3.18
  19. # Install runtime dependencies and testing tools
  20. RUN apk --no-cache add \
  21. ca-certificates \
  22. curl \
  23. jq \
  24. bash \
  25. wget \
  26. netcat-openbsd \
  27. && rm -rf /var/cache/apk/*
  28. # Create app user
  29. RUN addgroup -g 1001 appgroup && \
  30. adduser -D -s /bin/bash -u 1001 -G appgroup appuser
  31. # Set work directory
  32. WORKDIR /app
  33. # Copy binaries from builder stage
  34. COPY --from=builder /app/test-rdma .
  35. COPY --from=builder /app/demo-server .
  36. # Copy test scripts
  37. COPY tests/ ./tests/
  38. RUN chmod +x ./tests/*.sh
  39. # Change ownership
  40. RUN chown -R appuser:appgroup /app
  41. # Switch to app user
  42. USER appuser
  43. # Default command
  44. CMD ["/bin/bash"]