Thibault bui Koechlin %!s(int64=5) %!d(string=hai) anos
pai
achega
7c7b765d50
Modificáronse 6 ficheiros con 0 adicións e 210 borrados
  1. 0 73
      Dockerfile
  2. 0 32
      docker/README.md
  3. 0 4
      docker/acquis.yaml
  4. 0 15
      docker/docker.yaml
  5. 0 44
      docker/rsyslog.conf
  6. 0 42
      docker/wrapper.sh

+ 0 - 73
Dockerfile

@@ -1,73 +0,0 @@
-############################
-# STEP 1 build executable binary
-############################
-
-FROM golang:alpine AS builder
-
-RUN apk update && apk add make gettext gcc g++
-
-
-WORKDIR $GOPATH/src/JohnDoeCrowdSec/granola
-
-# COPY the source
-COPY ./ .
-
-RUN make build
-
-RUN make install
-
-RUN cp ./docker/docker.yaml /etc/crowdsec/docker.yaml
-RUN cp ./docker/acquis.yaml /etc/crowdsec/config/
-
-############################
-# STEP 2
-############################
-
-FROM alpine:latest
-
-COPY --from=builder /usr/local/bin/crowdsec /usr/local/bin/crowdsec
-COPY --from=builder /usr/local/bin/cscli /usr/local/bin/cscli
-
-
-COPY --from=builder /etc/crowdsec /etc/crowdsec
-COPY --from=builder /var/run/crowdsec /var/run/crowdsec
-
-RUN apk add --update bash rsyslog && rm -rf /var/cache/apk/*
-
-###########################
-##### Prepare rsyslog #####
-###########################
-
-RUN mkdir -p /etc/rsyslog.d/
-RUN mkdir -p /var/spool/rsyslog/
-RUN mkdir -p /var/log/rsyslog
-RUN touch /var/log/syslog
-
-EXPOSE 514 514
-
-COPY ./docker/rsyslog.conf /etc/rsyslog.conf
-
-###########################################
-###### Configure crowdsec ###########
-###########################################
-
-RUN cscli config token "6ba94afde0fbf41310f7191934bc1d920245c9f1" 
-RUN cscli config installdir "/etc/crowdsec/config/"
-RUN cscli config dbpath "/var/run/crowdsec/crowdsec.db"
-
-RUN cscli update
-
-RUN cscli install collection crowdsec/base-http-scenarios
-RUN cscli install collection crowdsec/linux
-RUN cscli install collection crowdsec/nginx
-RUN cscli install collection crowdsec/sshd
-
-######################################
-## Wrapper to launch multi services ##
-######################################
-
-COPY ./docker/wrapper.sh .
-RUN chmod +x ./wrapper.sh
-
-ENTRYPOINT ["./wrapper.sh"]
-

+ 0 - 32
docker/README.md

@@ -1,32 +0,0 @@
-# Crowdwatch with docker
-
-
-## Getting Started
-
-Go in the main folder of crowdsec (if you are in the folder `docker/` please `cd ..`)
-
-
-- Build the docker image
-
-```
-docker build -t crowdsec .
-```
-
-
-- Run the docker
-
-
-```
-docker run -d -p 514:514 --name crowdsec -v /var/run/crowdsec/crowdsec.db:/var/run/crowdsec/crowdsec.db crowdsec
-```
-
-:warning: Be sure that your ban plugin will get decision from the db located in `/var/run/crowdsec/crowdsec.db` on your host.
-
-
-
-
-## TODO:
-
- - Be sure that bans are applied on the host
-    - Check that the sqlite db is created by crowdsec in the docker and read by the ban plugin on the host
- - Forward traffic to the docker syslog (127.0.0.1:514) and check that logs are correctly parsed

+ 0 - 4
docker/acquis.yaml

@@ -1,4 +0,0 @@
-filenames:
-  - /var/log/syslog
-labels:
-  type: syslog

+ 0 - 15
docker/docker.yaml

@@ -1,15 +0,0 @@
-working_dir: /tmp/
-data_dir: /var/run/crowdsec/
-config_dir: /etc/crowdsec
-pid_dir: /var/run/
-log_dir: /var/log/
-log_mode: stdout
-log_level: debug
-profiling: false
-sqlite_path: /var/run/crowdsec/crowdsec.db
-apimode: false
-daemon: false
-prometheus: true
-#for prometheus agent / golang debugging
-http_listen: 127.0.0.1:6060
-

+ 0 - 44
docker/rsyslog.conf

@@ -1,44 +0,0 @@
-#################
-#### MODULES ####
-#################
-# Uncomment out the following lines and comment out everything else to get debugging for variables
-# *.* /var/log/debugfmt;RSYSLOG_DebugFormat
-
-module(load="imudp")
-module(load="imtcp")
-
-###########################
-#### GLOBAL DIRECTIVES ####
-###########################
-
-#
-# Use traditional timestamp format.
-# To enable high precision timestamps, comment out the following line.
-#
-$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
-
-#
-# Where to place spool and state files
-#
-$WorkDirectory /var/spool/rsyslog
-
-#
-# Include all config files in /etc/rsyslog.d/
-#
-$IncludeConfig /etc/rsyslog.d/*.conf
-global(net.enableDNS="off")
-
-###########################
-# Input Parameters
-###########################
-
-input(type="imtcp" port="514")
-input(type="imudp" port="514")
-
-###########################
-#### Central log stuff ####
-###########################
-
-$template RemoteLogs, "/var/log/syslog"
-*.* ?RemoteLogs
-& ~

+ 0 - 42
docker/wrapper.sh

@@ -1,42 +0,0 @@
-#!/bin/sh
-
-CROWDSEC="crowdsec"
-SYSLOG_NG="rsyslogd"
-
-
-# Start the second process
-rsyslogd -n -f /etc/rsyslog.conf &
-status=$?
-if [ $status -ne 0 ]; then
-  echo "Failed to start ${SYSLOG_NG}: $status"
-  exit $status
-fi
-
-
-# Start the first process
-/usr/local/bin/crowdsec -c /etc/crowdsec/docker.yaml &
-status=$?
-if [ $status -ne 0 ]; then
-  echo "Failed to start ${CROWDSEC}: $status"
-  exit $status
-fi
-
-
-# Naive check runs checks once a minute to see if either of the processes exited.
-# This illustrates part of the heavy lifting you need to do if you want to run
-# more than one service in a container. The container exits with an error
-# if it detects that either of the processes has exited.
-# Otherwise it loops forever, waking up every 60 seconds
-
-while sleep 60; do
-  ps aux |grep ${CROWDSEC} |grep -q -v grep
-  PROCESS_1_STATUS=$?
-  ps aux |grep ${SYSLOG_NG} |grep -q -v grep
-  PROCESS_2_STATUS=0
-  # If the greps above find anything, they exit with 0 status
-  # If they are not both 0, then something is wrong
-  if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
-    echo "One of the processes has already exited."
-    exit 1
-  fi
-done