2022-12-10 21:09:25 +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
|
2020-11-30 09:37:17 +00:00
|
|
|
|
|
|
|
FROM golang:${GOVERSION}-alpine AS build
|
|
|
|
|
|
|
|
WORKDIR /go/src/crowdsec
|
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
COPY . .
|
|
|
|
|
2021-11-03 15:56:44 +00:00
|
|
|
# wizard.sh requires GNU coreutils
|
2022-11-08 11:28:57 +00:00
|
|
|
RUN apk add --no-cache git gcc libc-dev make bash gettext binutils-gold coreutils && \
|
2022-11-28 09:35:12 +00:00
|
|
|
SYSTEM="docker" make clean release && \
|
2022-11-08 11:28:57 +00:00
|
|
|
cd crowdsec-v* && \
|
|
|
|
./wizard.sh --docker-mode && \
|
|
|
|
cd - && \
|
|
|
|
cscli hub update && \
|
|
|
|
cscli collections install crowdsecurity/linux && \
|
|
|
|
cscli parsers install crowdsecurity/whitelists
|
2021-03-12 10:00:08 +00:00
|
|
|
|
2022-11-08 11:28:57 +00:00
|
|
|
FROM alpine:latest as build-slim
|
2021-03-12 10:00:08 +00:00
|
|
|
|
2022-10-11 11:32:23 +00:00
|
|
|
RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community tzdata yq bash && \
|
|
|
|
mkdir -p /staging/etc/crowdsec && \
|
2022-11-08 11:28:57 +00:00
|
|
|
mkdir -p /staging/var/lib/crowdsec && \
|
2022-12-10 21:09:25 +00:00
|
|
|
mkdir -p /var/lib/crowdsec/data \
|
|
|
|
yq -n '.url="http://0.0.0.0:8080"' | install -m 0600 /dev/stdin /staging/etc/crowdsec/local_api_credentials.yaml
|
2022-11-28 09:35:12 +00:00
|
|
|
|
2022-02-01 11:35:57 +00:00
|
|
|
COPY --from=build /etc/crowdsec /staging/etc/crowdsec
|
2020-11-30 09:37:17 +00:00
|
|
|
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 /
|
2022-02-01 11:35:57 +00:00
|
|
|
COPY --from=build /go/src/crowdsec/docker/config.yaml /staging/etc/crowdsec/config.yaml
|
2022-11-08 11:28:57 +00:00
|
|
|
|
2022-12-10 21:09:25 +00:00
|
|
|
# NOTE: setting default values here will overwrite the ones set in config.yaml
|
|
|
|
# every time the container is started. We set the default in docker/config.yaml
|
|
|
|
# and document them in docker/README.md, but keep the variables empty here.
|
|
|
|
|
2022-11-28 09:35:12 +00:00
|
|
|
ENV CONFIG_FILE=/etc/crowdsec/config.yaml
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV LOCAL_API_URL=
|
2022-11-28 09:35:12 +00:00
|
|
|
ENV CUSTOM_HOSTNAME=localhost
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV PLUGIN_DIR=
|
2022-11-28 09:35:12 +00:00
|
|
|
ENV DISABLE_AGENT=false
|
|
|
|
ENV DISABLE_LOCAL_API=false
|
|
|
|
ENV DISABLE_ONLINE_API=false
|
|
|
|
ENV DSN=
|
|
|
|
ENV TYPE=
|
|
|
|
ENV TEST_MODE=false
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV USE_WAL=
|
2022-11-28 09:35:12 +00:00
|
|
|
|
|
|
|
# register to app.crowdsec.net
|
|
|
|
|
|
|
|
ENV ENROLL_INSTANCE_NAME=
|
|
|
|
ENV ENROLL_KEY=
|
|
|
|
ENV ENROLL_TAGS=
|
|
|
|
|
|
|
|
# log verbosity
|
|
|
|
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV LEVEL_TRACE=
|
|
|
|
ENV LEVEL_DEBUG=
|
|
|
|
ENV LEVEL_INFO=
|
2022-11-28 09:35:12 +00:00
|
|
|
|
|
|
|
# TLS setup ----------------------------------- #
|
|
|
|
|
|
|
|
ENV AGENT_USERNAME=
|
|
|
|
ENV AGENT_PASSWORD=
|
|
|
|
|
|
|
|
# TLS setup ----------------------------------- #
|
|
|
|
|
|
|
|
ENV USE_TLS=false
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV CACERT_FILE=
|
|
|
|
ENV CERT_FILE=
|
|
|
|
ENV KEY_FILE=
|
2022-11-28 09:35:12 +00:00
|
|
|
# comma-separated list of allowed OU values for TLS bouncer certificates
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV BOUNCERS_ALLOWED_OU=
|
2022-11-28 09:35:12 +00:00
|
|
|
# comma-separated list of allowed OU values for TLS agent certificates
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV AGENTS_ALLOWED_OU=
|
2022-11-28 09:35:12 +00:00
|
|
|
|
|
|
|
# Install the following hub items --------------#
|
|
|
|
|
|
|
|
ENV COLLECTIONS=
|
|
|
|
ENV PARSERS=
|
|
|
|
ENV SCENARIOS=
|
|
|
|
ENV POSTOVERFLOWS=
|
|
|
|
|
|
|
|
# Uninstall the following hub items ------------#
|
|
|
|
|
|
|
|
ENV DISABLE_COLLECTIONS=
|
|
|
|
ENV DISABLE_PARSERS=
|
|
|
|
ENV DISABLE_SCENARIOS=
|
|
|
|
ENV DISABLE_POSTOVERFLOWS=
|
|
|
|
|
2022-12-10 21:09:25 +00:00
|
|
|
ENV METRICS_PORT=
|
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
|
2022-11-28 09:35:12 +00:00
|
|
|
|
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
|
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-01 11:35:57 +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
|
2021-09-09 14:05:21 +00:00
|
|
|
COPY --from=build /usr/local/lib/crowdsec/plugins /usr/local/lib/crowdsec/plugins
|
2020-11-30 09:37:17 +00:00
|
|
|
|
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}
|