-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.integration
More file actions
73 lines (55 loc) · 2.09 KB
/
Copy pathDockerfile.integration
File metadata and controls
73 lines (55 loc) · 2.09 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
66
67
68
69
70
71
72
73
# syntax=docker/dockerfile:1
# Self-contained integration test image.
# Builds the arc binary and compiled test binary, starts the server,
# and runs the tests — all inside a single container.
# ===========================================================================
# Stage 1: Build arc binary + integration test binary
# ===========================================================================
FROM golang:1.26-alpine AS builder
WORKDIR /build
RUN apk add --no-cache git
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build the arc CLI binary (no web UI needed for integration tests)
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /out/arc ./cmd/arc
# Compile the integration test binary
RUN CGO_ENABLED=0 go test -c -tags integration -o /out/integration.test ./tests/integration/
# ===========================================================================
# Stage 2: Runtime — minimal image with both binaries
# ===========================================================================
FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata git
COPY --from=builder /out/arc /usr/local/bin/arc
COPY --from=builder /out/integration.test /usr/local/bin/integration.test
# Inline entrypoint: start server, wait for health, run tests.
COPY <<'EOF' /entrypoint.sh
#!/bin/sh
set -e
PORT=7432
DB_PATH="/tmp/arc-integration-test.db"
# Start the arc server in the background
arc server start --foreground --port "$PORT" --db "$DB_PATH" &
SERVER_PID=$!
# Wait for the server to become healthy
echo "Waiting for arc server on port $PORT..."
attempts=0
until wget -q --spider "http://127.0.0.1:${PORT}/health" 2>/dev/null; do
attempts=$((attempts + 1))
if [ "$attempts" -ge 30 ]; then
echo "Server failed to start within 30s"
kill "$SERVER_PID" 2>/dev/null || true
exit 1
fi
sleep 1
done
echo "Server ready."
# Run the integration tests
ARC_BINARY=/usr/local/bin/arc /usr/local/bin/integration.test -test.v -test.count=1
TEST_EXIT=$?
# Clean up
kill "$SERVER_PID" 2>/dev/null || true
exit "$TEST_EXIT"
EOF
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]