2022-11-28 09:35:12 +00:00
|
|
|
# vim: set ft=dockerfile:
|
2024-01-29 21:05:26 +00:00
|
|
|
FROM golang:1.21.6-bookworm AS build
|
2022-02-15 16:10:15 +00:00
|
|
|
|
2024-01-29 21:05:26 +00:00
|
|
|
ARG BUILD_VERSION
|
2022-02-15 16:10:15 +00:00
|
|
|
|
|
|
|
WORKDIR /go/src/crowdsec
|
|
|
|
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
ENV DEBCONF_NOWARNINGS="yes"
|
|
|
|
|
2023-06-27 11:43:42 +00:00
|
|
|
# We like to choose the release of re2 to use, the debian version is usually older.
|
|
|
|
ENV RE2_VERSION=2023-03-01
|
2024-01-15 10:05:27 +00:00
|
|
|
ENV BUILD_VERSION=${BUILD_VERSION}
|
2023-06-27 11:43:42 +00:00
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
# wizard.sh requires GNU coreutils
|
|
|
|
RUN apt-get update && \
|
2023-06-27 11:43:42 +00:00
|
|
|
apt-get install -y -q git gcc libc-dev make bash gettext binutils-gold coreutils tzdata && \
|
|
|
|
wget https://github.com/google/re2/archive/refs/tags/${RE2_VERSION}.tar.gz && \
|
|
|
|
tar -xzf ${RE2_VERSION}.tar.gz && \
|
|
|
|
cd re2-${RE2_VERSION} && \
|
|
|
|
make && \
|
|
|
|
make install && \
|
2023-01-04 15:43:35 +00:00
|
|
|
echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
|
2023-12-14 15:11:11 +00:00
|
|
|
go install github.com/mikefarah/yq/v4@v4.40.4
|
2023-06-27 11:43:42 +00:00
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
RUN make clean release DOCKER_BUILD=1 BUILD_STATIC=1 && \
|
2022-11-08 11:28:57 +00:00
|
|
|
cd crowdsec-v* && \
|
|
|
|
./wizard.sh --docker-mode && \
|
2023-01-04 15:43:35 +00:00
|
|
|
cd - >/dev/null && \
|
2022-11-08 11:28:57 +00:00
|
|
|
cscli hub update && \
|
|
|
|
cscli collections install crowdsecurity/linux && \
|
2023-06-27 11:43:42 +00:00
|
|
|
cscli parsers install crowdsecurity/whitelists
|
2022-02-15 16:10:15 +00:00
|
|
|
|
2023-03-27 13:38:38 +00:00
|
|
|
# In case we need to remove agents here..
|
|
|
|
# cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete
|
|
|
|
|
2023-06-26 10:52:10 +00:00
|
|
|
FROM debian:bookworm-slim as slim
|
2022-02-15 16:10:15 +00:00
|
|
|
|
2023-01-04 15:43:35 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
ENV DEBCONF_NOWARNINGS="yes"
|
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y -q --install-recommends --no-install-suggests \
|
2022-02-15 16:10:15 +00:00
|
|
|
procps \
|
|
|
|
systemd \
|
|
|
|
iproute2 \
|
|
|
|
ca-certificates \
|
|
|
|
bash \
|
2023-11-23 10:08:14 +00:00
|
|
|
tzdata \
|
|
|
|
rsync && \
|
2022-02-15 16:10:15 +00:00
|
|
|
mkdir -p /staging/etc/crowdsec && \
|
2023-03-10 16:30:08 +00:00
|
|
|
mkdir -p /staging/etc/crowdsec/acquis.d && \
|
2022-11-08 11:28:57 +00:00
|
|
|
mkdir -p /staging/var/lib/crowdsec && \
|
2023-01-04 15:43:35 +00:00
|
|
|
mkdir -p /var/lib/crowdsec/data
|
2022-02-15 16:10:15 +00:00
|
|
|
|
2024-01-31 11:07:27 +00:00
|
|
|
COPY --from=build /go/bin/yq /usr/local/bin/crowdsec /usr/local/bin/cscli /usr/local/bin/
|
2022-02-15 16:10:15 +00:00
|
|
|
COPY --from=build /etc/crowdsec /staging/etc/crowdsec
|
|
|
|
COPY --from=build /go/src/crowdsec/docker/docker_start.sh /
|
|
|
|
COPY --from=build /go/src/crowdsec/docker/config.yaml /staging/etc/crowdsec/config.yaml
|
2023-01-04 15:43:35 +00:00
|
|
|
RUN yq -n '.url="http://0.0.0.0:8080"' | install -m 0600 /dev/stdin /staging/etc/crowdsec/local_api_credentials.yaml && \
|
|
|
|
yq eval -i ".plugin_config.group = \"nogroup\"" /staging/etc/crowdsec/config.yaml
|
2022-11-28 09:35:12 +00:00
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
ENTRYPOINT /bin/bash docker_start.sh
|
|
|
|
|
2023-01-19 10:02:23 +00:00
|
|
|
FROM slim as plugins
|
2022-11-08 11:28:57 +00:00
|
|
|
|
|
|
|
# Due to the wizard using cp -n, we have to copy the config files directly from the source as -n does not exist in busybox cp
|
|
|
|
# The files are here for reference, as users will need to mount a new version to be actually able to use notifications
|
2024-01-31 11:07:27 +00:00
|
|
|
COPY --from=build \
|
|
|
|
/go/src/crowdsec/cmd/notification-email/email.yaml \
|
|
|
|
/go/src/crowdsec/cmd/notification-http/http.yaml \
|
|
|
|
/go/src/crowdsec/cmd/notification-slack/slack.yaml \
|
|
|
|
/go/src/crowdsec/cmd/notification-splunk/splunk.yaml \
|
|
|
|
/go/src/crowdsec/cmd/notification-sentinel/sentinel.yaml \
|
|
|
|
/staging/etc/crowdsec/notifications/
|
|
|
|
|
2022-02-15 16:10:15 +00:00
|
|
|
COPY --from=build /usr/local/lib/crowdsec/plugins /usr/local/lib/crowdsec/plugins
|
|
|
|
|
2023-01-19 10:02:23 +00:00
|
|
|
FROM slim as geoip
|
2022-11-08 11:28:57 +00:00
|
|
|
|
|
|
|
COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec
|
|
|
|
|
2023-01-19 10:02:23 +00:00
|
|
|
FROM plugins as full
|
2022-11-08 11:28:57 +00:00
|
|
|
|
|
|
|
COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec
|