2022-11-28 09:35:12 +00:00
|
|
|
# vim: set ft=dockerfile:
|
2022-11-08 11:28:57 +00:00
|
|
|
ARG BUILD_ENV=full
|
2022-08-26 11:31:49 +00:00
|
|
|
ARG GOVERSION=1.19
|
2022-02-15 16:10:15 +00:00
|
|
|
|
|
|
|
FROM golang:${GOVERSION}-bullseye AS build
|
|
|
|
|
|
|
|
WORKDIR /go/src/crowdsec
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
2022-12-12 10:00:04 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
ENV DEBCONF_NOWARNINGS="yes"
|
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
# wizard.sh requires GNU coreutils
|
|
|
|
RUN apt-get update && \
|
2022-12-12 10:00:04 +00:00
|
|
|
apt-get install -y -q git gcc libc-dev make bash gettext binutils-gold coreutils tzdata && \
|
2023-01-03 13:45:33 +00:00
|
|
|
echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
|
|
|
|
SYSTEM="docker" make clean release && \
|
2022-11-08 11:28:57 +00:00
|
|
|
cd crowdsec-v* && \
|
|
|
|
./wizard.sh --docker-mode && \
|
2023-01-03 13:45:33 +00:00
|
|
|
cd - >/dev/null && \
|
2022-11-08 11:28:57 +00:00
|
|
|
cscli hub update && \
|
|
|
|
cscli collections install crowdsecurity/linux && \
|
2023-01-03 15:49:25 +00:00
|
|
|
cscli parsers install crowdsecurity/whitelists && \
|
|
|
|
go install github.com/mikefarah/yq/v4@v4.30.6
|
2022-02-15 16:10:15 +00:00
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
FROM debian:bullseye-slim as build-slim
|
2022-02-15 16:10:15 +00:00
|
|
|
|
2023-01-03 13:45:33 +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 \
|
|
|
|
tzdata && \
|
|
|
|
mkdir -p /staging/etc/crowdsec && \
|
2022-11-08 11:28:57 +00:00
|
|
|
mkdir -p /staging/var/lib/crowdsec && \
|
2023-01-03 13:45:33 +00:00
|
|
|
mkdir -p /var/lib/crowdsec/data
|
2022-02-15 16:10:15 +00:00
|
|
|
|
|
|
|
COPY --from=build /go/bin/yq /usr/local/bin/yq
|
|
|
|
COPY --from=build /etc/crowdsec /staging/etc/crowdsec
|
|
|
|
COPY --from=build /usr/local/bin/crowdsec /usr/local/bin/crowdsec
|
|
|
|
COPY --from=build /usr/local/bin/cscli /usr/local/bin/cscli
|
|
|
|
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-03 13:45:33 +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
|
|
|
|
|
|
|
|
FROM build-slim as build-plugins
|
|
|
|
|
|
|
|
# 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
|
2022-02-28 11:04:31 +00:00
|
|
|
COPY --from=build /go/src/crowdsec/plugins/notifications/email/email.yaml /staging/etc/crowdsec/notifications/email.yaml
|
2022-02-15 16:10:15 +00:00
|
|
|
COPY --from=build /go/src/crowdsec/plugins/notifications/http/http.yaml /staging/etc/crowdsec/notifications/http.yaml
|
|
|
|
COPY --from=build /go/src/crowdsec/plugins/notifications/slack/slack.yaml /staging/etc/crowdsec/notifications/slack.yaml
|
|
|
|
COPY --from=build /go/src/crowdsec/plugins/notifications/splunk/splunk.yaml /staging/etc/crowdsec/notifications/splunk.yaml
|
|
|
|
COPY --from=build /usr/local/lib/crowdsec/plugins /usr/local/lib/crowdsec/plugins
|
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
FROM build-slim as build-geoip
|
|
|
|
|
|
|
|
COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec
|
|
|
|
|
|
|
|
FROM build-plugins as build-full
|
|
|
|
|
|
|
|
COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec
|
|
|
|
|
|
|
|
FROM build-${BUILD_ENV}
|