-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
111 lines (86 loc) · 3.3 KB
/
Dockerfile
File metadata and controls
111 lines (86 loc) · 3.3 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Code generated by ADL CLI v0.26.0. DO NOT EDIT.
# This file was automatically generated from an ADL (Agent Definition Language) specification.
# Manual changes to this file may be overwritten during regeneration.
FROM golang:1.25-alpine AS builder
# Build arguments for version injection
ARG VERSION="0.4.3"
ARG AGENT_NAME="browser-agent"
ARG AGENT_DESCRIPTION="AI agent for browser automation and web testing using Playwright"
WORKDIR /app
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Install playwright CLI with right version for later use
RUN PWGO_VER=$(grep -oE "playwright-go v[0-9]+\.[0-9]+\.[0-9]+" /app/go.mod | sed 's/playwright-go v//g') \
&& go install github.com/playwright-community/playwright-go/cmd/playwright@v${PWGO_VER}
# Copy source code
COPY . .
# Build the application with optimized LDD flags and version injection
RUN CGO_ENABLED=0 GOOS=linux go build \
-a \
-installsuffix cgo \
-ldflags="-s -w -extldflags '-static' \
-X 'main.Version=${VERSION}' \
-X 'main.AgentName=${AGENT_NAME}' \
-X 'main.AgentDescription=${AGENT_DESCRIPTION}'" \
-trimpath \
-o main .
# Stage 2: Final image with browser dependencies
FROM ubuntu:24.04
# Build arguments for browser selection
ARG BROWSER_ENGINE=chromium
# Install system dependencies
# Note: x11-utils added for xdpyinfo (Xvfb health check)
RUN apt-get update && apt-get install -y \
ca-certificates \
tzdata \
curl \
xvfb \
x11-utils \
&& rm -rf /var/lib/apt/lists/*
# Create a2a group and agent user
RUN groupadd -g 1001 a2a && \
useradd -m -u 1001 -g a2a agent
WORKDIR /app
# Copy the binary and playwright CLI from builder stage
COPY --from=builder /app/main .
COPY --from=builder /go/bin/playwright /usr/local/bin/playwright
# Copy agent card and entrypoint script
COPY --from=builder /app/.well-known ./.well-known
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENV PLAYWRIGHT_BROWSERS_PATH=/home/agent/.cache/ms-playwright
# Create and set ownership for cache directory before playwright installation
RUN mkdir -p /home/agent/.cache/ms-playwright && \
chown -R agent:a2a /home/agent/.cache
# Install browsers based on build argument
# Supports: chromium, firefox, webkit, or "all" for multiple browsers
RUN if [ "$BROWSER_ENGINE" = "all" ]; then \
playwright install --with-deps chromium firefox webkit; \
elif [ "$BROWSER_ENGINE" = "firefox" ]; then \
playwright install --with-deps firefox; \
elif [ "$BROWSER_ENGINE" = "webkit" ]; then \
playwright install --with-deps webkit; \
else \
playwright install --with-deps chromium; \
fi
# Change ownership to agent user
RUN chown -R agent:a2a /app
# Switch to non-root user
USER agent
# Expose port
EXPOSE 8080
# Set environment variables
ENV A2A_SERVER_PORT=8080
# Browser configuration defaults (can be overridden at runtime)
ENV BROWSER_ENGINE=chromium
ENV BROWSER_HEADLESS=true
ENV BROWSER_STEALTH_MODE=false
ENV BROWSER_XVFB_ENABLED=false
ENV BROWSER_XVFB_DISPLAY=:99
ENV BROWSER_XVFB_SCREEN_RESOLUTION=1920x1080x24
# Run the application via entrypoint script
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]