-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.integration
More file actions
65 lines (47 loc) · 1.54 KB
/
Dockerfile.integration
File metadata and controls
65 lines (47 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Dockerfile for Integration Tests
# Provides multi-stage builds for database and Kubernetes integration tests
# Reference: integration-testing Skill
# Base stage: Setup Go environment with all dependencies
FROM golang:1.25-alpine AS base
RUN apk add --no-cache \
bash \
git \
ca-certificates \
postgresql-client \
redis \
curl \
docker \
make
WORKDIR /app
# Copy go module files for caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Database Integration Tests
FROM base AS db-test-final
ENV CGO_ENABLED=1
ENV GOOS=linux
# Install gcc for SQLite/database support
RUN apk add --no-cache gcc musl-dev
CMD ["bash", "-c", "go test -v -timeout 30m -tags=integration ./test/integration/..."]
# Kubernetes Integration Tests
FROM base AS k8s-test-final
ENV CGO_ENABLED=0
ENV GOOS=linux
# Install KinD and kubectl for Kubernetes testing
RUN go install sigs.k8s.io/kind@v0.20.0 && \
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt) && \
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" && \
chmod +x kubectl && \
mv kubectl /usr/local/bin/
# Build binary for testing
RUN go build -o /app/platform-api ./cmd/api && \
go build -o /app/platform-scheduler ./cmd/scheduler
CMD ["bash", "-c", ".github/skills/cicd-pipeline-optimization/scripts/k8s-integration-test.sh"]
# Run all tests
FROM base AS test-final
ENV CGO_ENABLED=1
ENV GOOS=linux
RUN apk add --no-cache gcc musl-dev docker
CMD ["bash", "-c", "go test -v -race -timeout 30m ./..."]