-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.test
More file actions
36 lines (27 loc) · 1.18 KB
/
Dockerfile.test
File metadata and controls
36 lines (27 loc) · 1.18 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
# Dockerfile.test — Docker test environment for reproducible E2E testing
# Builds a test runner image with Go toolchain and linting tools.
# Source code is mounted at runtime via docker-compose, not copied into the image.
FROM golang:1.25-bookworm
# Pin tool versions to match CI (.github/workflows/ci.yml)
ARG GOFUMPT_VERSION=v0.7.0
ARG GOLANGCI_LINT_VERSION=v2.1.6
# Install gofumpt and golangci-lint
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} && \
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
# Set up working directory
WORKDIR /app
# Cache Go module dependencies
# Copy only module files first to leverage Docker layer caching
COPY go.mod go.sum ./
RUN go mod download
# Create non-root user for test execution
RUN groupadd --gid 1001 testuser && \
useradd --uid 1001 --gid 1001 --create-home testuser && \
mkdir -p /app/test-results && \
chown -R testuser:testuser /app
USER testuser
# Default environment for test execution
ENV CGO_ENABLED=0
ENV CI=true
# Default command runs the full test suite with coverage
CMD ["go", "test", "./...", "-v", "-count=1", "-timeout", "5m", "-coverprofile=test-results/coverage.out"]