-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker build flavors: slim, with-plugins, with-geoip, full (#1862)
- Loading branch information
Showing
5 changed files
with
165 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,51 @@ | ||
ARG BUILD_ENV=full | ||
ARG GOVERSION=1.19 | ||
|
||
FROM golang:${GOVERSION}-alpine AS build | ||
|
||
WORKDIR /go/src/crowdsec | ||
|
||
COPY . . | ||
|
||
# wizard.sh requires GNU coreutils | ||
RUN apk add --no-cache git gcc libc-dev make bash gettext binutils-gold coreutils | ||
RUN apk add --no-cache git gcc libc-dev make bash gettext binutils-gold coreutils && \ | ||
SYSTEM="docker" make release && \ | ||
cd crowdsec-v* && \ | ||
./wizard.sh --docker-mode && \ | ||
cd - && \ | ||
cscli hub update && \ | ||
cscli collections install crowdsecurity/linux && \ | ||
cscli parsers install crowdsecurity/whitelists | ||
|
||
COPY . . | ||
FROM alpine:latest as build-slim | ||
|
||
RUN SYSTEM="docker" make release | ||
RUN cd crowdsec-v* && ./wizard.sh --docker-mode && cd - | ||
RUN cscli hub update && cscli collections install crowdsecurity/linux && cscli parsers install crowdsecurity/whitelists | ||
FROM alpine:latest | ||
RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community tzdata yq bash && \ | ||
mkdir -p /staging/etc/crowdsec && \ | ||
mkdir -p /staging/var/lib/crowdsec | ||
mkdir -p /staging/var/lib/crowdsec && \ | ||
mkdir -p /var/lib/crowdsec/data | ||
COPY --from=build /etc/crowdsec /staging/etc/crowdsec | ||
COPY --from=build /var/lib/crowdsec /staging/var/lib/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 | ||
#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 | ||
|
||
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 | ||
COPY --from=build /go/src/crowdsec/plugins/notifications/email/email.yaml /staging/etc/crowdsec/notifications/email.yaml | ||
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 | ||
|
||
ENTRYPOINT /bin/bash docker_start.sh | ||
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,64 @@ | ||
ARG BUILD_ENV=full | ||
ARG GOVERSION=1.19 | ||
|
||
FROM golang:${GOVERSION}-bullseye AS build | ||
|
||
WORKDIR /go/src/crowdsec | ||
|
||
# wizard.sh requires GNU coreutils | ||
RUN apt-get update && apt-get install -y git gcc libc-dev make bash gettext binutils-gold coreutils tzdata python3 python3-pip | ||
|
||
COPY . . | ||
|
||
RUN SYSTEM="docker" make release | ||
RUN cd crowdsec-v* && ./wizard.sh --docker-mode && cd - | ||
RUN cscli hub update && cscli collections install crowdsecurity/linux && cscli parsers install crowdsecurity/whitelists | ||
RUN GO111MODULE=on go get github.com/mikefarah/yq/v4 | ||
# wizard.sh requires GNU coreutils | ||
RUN apt-get update && \ | ||
apt-get install -y git gcc libc-dev make bash gettext binutils-gold coreutils tzdata && \ | ||
SYSTEM="docker" make release && \ | ||
cd crowdsec-v* && \ | ||
./wizard.sh --docker-mode && \ | ||
cd - && \ | ||
cscli hub update && \ | ||
cscli collections install crowdsecurity/linux && \ | ||
cscli parsers install crowdsecurity/whitelists && \ | ||
go install github.com/mikefarah/yq/v4@latest | ||
|
||
FROM debian:bullseye-slim | ||
FROM debian:bullseye-slim as build-slim | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y -q --install-recommends --no-install-suggests \ | ||
RUN apt-get update && \ | ||
apt-get install -y -q --install-recommends --no-install-suggests \ | ||
procps \ | ||
systemd \ | ||
iproute2 \ | ||
ca-certificates \ | ||
bash \ | ||
tzdata && \ | ||
mkdir -p /staging/etc/crowdsec && \ | ||
mkdir -p /staging/var/lib/crowdsec | ||
mkdir -p /staging/var/lib/crowdsec && \ | ||
mkdir -p /var/lib/crowdsec/data | ||
|
||
COPY --from=build /go/bin/yq /usr/local/bin/yq | ||
COPY --from=build /etc/crowdsec /staging/etc/crowdsec | ||
COPY --from=build /var/lib/crowdsec /staging/var/lib/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 | ||
RUN yq eval -i ".plugin_config.group = \"nogroup\"" /staging/etc/crowdsec/config.yaml | ||
#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 | ||
|
||
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 | ||
COPY --from=build /go/src/crowdsec/plugins/notifications/email/email.yaml /staging/etc/crowdsec/notifications/email.yaml | ||
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 | ||
|
||
ENTRYPOINT /bin/bash docker_start.sh | ||
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.