-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (61 loc) · 2.38 KB
/
Dockerfile
File metadata and controls
74 lines (61 loc) · 2.38 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
FROM --platform=linux/amd64 golang:1.25 AS builder
RUN apt-get update && apt-get install -y git libpcap-dev
# Tools dependencies
# dnsx
RUN go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest
# naabu
RUN go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest
# httpx
RUN go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
# tlsx
RUN go install -v github.com/projectdiscovery/tlsx/cmd/tlsx@latest
# nuclei
RUN go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# Copy source code
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build pd-agent binary
# CGO_ENABLED=1 is required for libpcap/gopacket support (passive discovery feature)
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -o /go/bin/pd-agent ./cmd/pd-agent/main.go
FROM --platform=linux/amd64 ubuntu:latest
# install dependencies
# required: libpcap-dev, chrome
RUN apt update && apt install -y \
bind9-dnsutils \
ca-certificates \
nmap \
libpcap-dev \
wget \
gnupg \
&& wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt update \
&& apt install -y google-chrome-stable \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables for Chrome
ENV CHROME_BIN=/usr/bin/google-chrome-stable
ENV CHROME_PATH=/usr/bin/
ENV CHROME_NO_SANDBOX=true
# Copy tools binaries
COPY --from=builder /go/bin/dnsx /usr/local/bin/
COPY --from=builder /go/bin/naabu /usr/local/bin/
COPY --from=builder /go/bin/httpx /usr/local/bin/
COPY --from=builder /go/bin/tlsx /usr/local/bin/
COPY --from=builder /go/bin/nuclei /usr/local/bin/
# Copy agent binary
COPY --from=builder /go/bin/pd-agent /usr/local/bin/pd-agent
# Create writable output directory for existing ubuntu user (UID 1000)
RUN mkdir -p /home/ubuntu/output && \
chown -R ubuntu:ubuntu /home/ubuntu
# Set default environment variables (can be overridden at runtime)
ENV PDCP_API_KEY=""
ENV PDCP_TEAM_ID=""
# Switch to non-root user
USER ubuntu
WORKDIR /home/ubuntu
# ENTRYPOINT allows passing command-line arguments at runtime
# Environment variables should be passed via -e flags or docker-compose
ENTRYPOINT ["pd-agent"]