forked from s12v/awsbeats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (49 loc) · 2.52 KB
/
Dockerfile
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
# See https://stackoverflow.com/a/48324849 for how ARG before FROM works
# Used from within the first FROM
ARG GO_VERSION=${GO_VERSION:-1.11.4}
# Used from within the second FROM
ARG BEAT_DOCKER_IMAGE
FROM golang:${GO_VERSION} AS awsbeats
LABEL maintainr "Yusuke KUOKA <[email protected]>"
# "MAINTAINER" is deprecated in favor of the above label. But required to make codacy happy
MAINTAINER Yusuke KUOKA <[email protected]>
COPY . /go/src/github.com/s12v/awsbeats
WORKDIR /go/src/github.com/s12v/awsbeats
ARG BEATS_VERSION=${BEATS_VERSION:-6.5.4}
ARG GO_PLATFORM=${GO_PLATFORM:-linux-amd64}
ARG AWSBEATS_VERSION=${AWSBEATS_VERSION:-1-snapshot}
ARG BEAT_NAME=${BEAT_NAME:-filebeat}
RUN curl --verbose --fail https://raw.githubusercontent.com/golang/dep/master/install.sh -o install.sh && sh install.sh && rm install.sh
RUN go get github.com/elastic/beats || true
RUN /go/bin/dep ensure
# You need to enable CGO on both the plugin and the beat.
# Otherwise, for example, filebeat w/ CGO fails to load the plugin w/o CGO, emitting an error like:
# Exiting: plugin.Open("kinesis"): plugin was built with a different version of package net
RUN CGO_ENABLED=1 GOOS=linux make build
FROM golang:${GO_VERSION} AS beats
LABEL maintainr "Yusuke KUOKA <[email protected]>"
COPY Makefile /build/Makefile
WORKDIR /build
ARG BEATS_VERSION=${BEATS_VERSION:-6.1.2}
ARG GO_VERSION=${GO_VERSION:-1.10.2}
ARG GO_PLATFORM=${GO_PLATFORM:-linux-amd64}
ARG BEAT_NAME=${BEAT_NAME:-filebeat}
ARG BEAT_GITHUB_REPO
ARG BEAT_GO_PKG
#RUN go get github.com/elastic/beats || true
# Beats requires CGO for plugin support as per https://github.com/elastic/beats/commit/d21decb720e7fdeb986f4ebac413cc816353aa55
RUN CGO_ENABLED=1 make beats && \
pwd && find ./target
FROM ${BEAT_DOCKER_IMAGE}
LABEL maintainr "Yusuke KUOKA <[email protected]>"
ARG AWSBEATS_VERSION=${AWSBEATS_VERSION:-1-snapshot}
ARG BEATS_VERSION=${BEATS_VERSION:-6.1.2}
ARG GO_VERSION=${GO_VERSION:-1.10.2}
ARG GO_PLATFORM=${GO_PLATFORM:-linux-amd64}
ARG BEAT_NAME=${BEAT_NAME:-filebeat}
COPY --from=awsbeats /go/src/github.com/s12v/awsbeats/target/kinesis-${AWSBEATS_VERSION}-${BEATS_VERSION}-go${GO_VERSION}-linux-amd64.so /usr/share/${BEAT_NAME}/kinesis.so
COPY --from=beats /build/target/${BEAT_NAME}-${BEATS_VERSION}-go${GO_VERSION}-linux-amd64 /usr/share/${BEAT_NAME}/${BEAT_NAME}
# Usage:
# docker run --rm s12v/awsbeats:canary cat filebeat.yml > filebeat.yml
# cat outputs.yml >> filebeat.yml
# docker run --rm -v $(pwd)/filebeat.yml:/etc/filebeat/filebeat.yml s12v/awsbeats:canary filebeat --plugin kinesis.so -e -v