-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile.example
77 lines (60 loc) · 4 KB
/
Dockerfile.example
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
################################################################################
# STEP 1. Build plugins #
################################################################################
# Golang alpine, version must match main service's version
FROM golang:1.22.2-alpine AS plugins-builder
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates are required to call HTTPS endpoints
RUN apk update && apk add --no-cache gcc libc-dev git ca-certificates && update-ca-certificates
WORKDIR $GOPATH/src/github.com/cert-lv/graphoscope
COPY pdk ./pdk
COPY plugins ./plugins
COPY go.mod ./
COPY go.sum ./
# Fetch dependencies
RUN go get -d ./pdk/...
RUN go get -d ./plugins/src/...
# CGO_ENABLED=1 is required for the Golang plugins
ENV CGO_ENABLED=1 GOOS=linux GOARCH=amd64
# Build plugins
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/elasticsearch.v7.so plugins/src/elasticsearch.v7/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/elasticsearch.v8.so plugins/src/elasticsearch.v8/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/http.so plugins/src/http/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/rest.so plugins/src/rest/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/mongodb.so plugins/src/mongodb/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/postgresql.so plugins/src/postgresql/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/redis.so plugins/src/redis/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/mysql.so plugins/src/mysql/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/file-csv.so plugins/src/file/csv/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/misp.so plugins/src/misp/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/pastelyzer.so plugins/src/pastelyzer/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/abuseipdb.so plugins/src/abuseipdb/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/hashlookup.so plugins/src/hashlookup/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/circl_passive_ssl.so plugins/src/circl_passive_ssl/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/phishtank.so plugins/src/phishtank/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/ipinfo.so plugins/src/ipinfo/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/shodan.so plugins/src/shodan/*.go
RUN CGO_CFLAGS="-g -O2 -Wno-return-local-addr" go build -buildmode=plugin -ldflags="-w" -o /go/plugins/sources/sqlite.so plugins/src/sqlite/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/processors/taxonomy.so plugins/src/taxonomy/*.go
RUN go build -buildmode=plugin -ldflags="-w" -o /go/plugins/processors/modify.so plugins/src/modify/*.go
RUN mkdir /go/plugins/outputs
################################################################################
# STEP 2. Build the executable binary #
################################################################################
FROM golang:1.22.2-alpine
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# ca-certificates is required to call HTTPS endpoints
RUN apk update && apk add --no-cache gcc libc-dev git ca-certificates && update-ca-certificates
WORKDIR $GOPATH/src/github.com/cert-lv/graphoscope
COPY *.go ./
COPY pdk ./pdk
COPY go.mod ./
COPY go.sum ./
# Fetch dependencies
RUN go get -d .
# CGO_ENABLED=1 is required for the Golang plugins
ENV CGO_ENABLED=1 GOOS=linux GOARCH=amd64
# Build the binary
RUN go build -ldflags="-w -s" -a -o /go/graphoscope .