Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM openresty/openresty:alpine-fat

RUN apk add --no-cache git
RUN luarocks install lua-resty-http
RUN mkdir -p /usr/local/openresty/lualib/plugins/
COPY ./lua /usr/local/openresty/lualib/plugins/crowdsec
COPY ./config/template.conf /etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf
RUN git clone https://github.com/crowdsecurity/lua-cs-bouncer.git
RUN mkdir -p /usr/local/openresty/lualib/plugins/crowdsec/ /etc/crowdsec/bouncers/
RUN cp lua-cs-bouncer/nginx/*.lua /usr/local/openresty/lualib/plugins/crowdsec/
RUN cp lua-cs-bouncer/nginx/template.conf /etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf
RUN rm -rf ./lua-cs-bouncer/
COPY ./openresty /etc/nginx/conf.d
COPY ./docker/docker_start.sh /

Expand Down
9 changes: 6 additions & 3 deletions Dockerfile.lua-bouncer-plugin
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM busybox:latest
FROM alpine:latest

COPY ./lua /crowdsec
RUN apk add --no-cache git
RUN git clone https://github.com/crowdsecurity/lua-cs-bouncer.git
RUN mkdir -p /crowdsec
RUN cp lua-cs-bouncer/nginx/*.lua /crowdsec
RUN cp lua-cs-bouncer/nginx/template.conf /crowdsec/crowdsec-bouncer.conf
COPY ./ingress-nginx /crowdsec
COPY ./config/template.conf /crowdsec/crowdsec-bouncer.conf
COPY ./docker/docker_start.sh /

ENV IS_LUALIB_IMAGE=true
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
BUILD_VERSION?="$(shell git for-each-ref --sort=-v:refname --count=1 --format '%(refname)' | cut -d '/' -f3)"
OUTDIR="crowdsec-openresty-bouncer-${BUILD_VERSION}/"
LUA_DIR="${OUTDIR}lua"
CONFIG_DIR="${OUTDIR}config"
OUT_ARCHIVE="crowdsec-openresty-bouncer.tgz"
LUA_BOUNCER_BRANCH?=main
default: release
release:
mkdir "${OUTDIR}"
cp -r ./lua/ "${OUTDIR}"
cp -r ./config/ ${OUTDIR}
git clone -b ${LUA_BOUNCER_BRANCH} https://github.com/crowdsecurity/lua-cs-bouncer.git
mkdir -p "${OUTDIR}"
mkdir -p "${LUA_DIR}"
mkdir -p "${CONFIG_DIR}"
cp -r lua-cs-bouncer/nginx/*.lua "${LUA_DIR}"
cp -r lua-cs-bouncer/nginx/template.conf ${CONFIG_DIR}
cp -r ./openresty/ ${OUTDIR}
cp install.sh ${OUTDIR}
cp uninstall.sh ${OUTDIR}
chmod +x ${OUTDIR}install.sh
chmod +x ${OUTDIR}uninstall.sh
tar cvzf ${OUT_ARCHIVE} ${OUTDIR}
rm -rf ${OUTDIR}
rm -rf "lua-cs-bouncer/"
clean:
rm -rf "${OUTDIR}"
rm -rf "${OUT_ARCHIVE}"
8 changes: 0 additions & 8 deletions config/template.conf

This file was deleted.

3 changes: 2 additions & 1 deletion debian/files
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
crowdsec-openresty-bouncer_0.1.0_source.buildinfo - -
crowdsec-openresty-bouncer_0.1.0_amd64.buildinfo - -
crowdsec-openresty-bouncer_0.1.0_amd64.deb - -
12 changes: 7 additions & 5 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ export BUILD_VERSION=v${DEB_VERSION}-debian-pragmatic
override_dh_systemd_start:
echo "Not running dh_systemd_start"
override_dh_auto_clean:
rm -rf lua-cs-bouncer
override_dh_auto_test:
override_dh_auto_build:
override_dh_auto_install:
mkdir -p debian/crowdsec-openresty-bouncer/usr/local/openresty/nginx/conf/conf.d/
cp openresty/crowdsec_openresty.conf debian/crowdsec-openresty-bouncer/usr/local/openresty/nginx/conf/conf.d/
git clone https://github.com/crowdsecurity/lua-cs-bouncer.git
mkdir -p debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua/config.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua/crowdsec.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua/access.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua/recaptcha.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua-cs-bouncer/nginx/config.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua-cs-bouncer/nginx/crowdsec.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua-cs-bouncer/nginx/access.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
cp lua-cs-bouncer/nginx/recaptcha.lua debian/crowdsec-openresty-bouncer/usr/local/openresty/lualib/plugins/crowdsec/
mkdir -p debian/crowdsec-openresty-bouncer/etc/crowdsec/bouncers/
cp config/template.conf debian/crowdsec-openresty-bouncer/etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf
cp lua-cs-bouncer/nginx/template.conf debian/crowdsec-openresty-bouncer/etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf
override_dh_usrlocal:
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ gen_config_file() {
SUFFIX=`tr -dc A-Za-z0-9 </dev/urandom | head -c 8`
API_KEY=`cscli bouncers add crowdsec-openresty-bouncer-${SUFFIX} -o raw`
API_KEY=${API_KEY} CROWDSEC_LAPI_URL="http://127.0.0.1:8080" envsubst < ./config/template.conf > "${CONFIG_PATH}crowdsec-openresty-bouncer.conf"
echo "New API key generated in config '${CONFIG_PATH}crowdsec-openresty-bouncer.conf'"
}

check_openresty_dependency() {
Expand Down
8 changes: 0 additions & 8 deletions lua/access.lua

This file was deleted.

92 changes: 0 additions & 92 deletions lua/config.lua

This file was deleted.

Loading