docker: distribute geoip db in slim image (#2920)

This commit is contained in:
mmetc 2024-04-03 13:34:35 +02:00 committed by GitHub
parent 63bd31b471
commit 26bcd0912a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 11 deletions

View file

@ -43,11 +43,12 @@ COPY --from=build /go/bin/yq /usr/local/bin/crowdsec /usr/local/bin/cscli /usr/l
COPY --from=build /etc/crowdsec /staging/etc/crowdsec COPY --from=build /etc/crowdsec /staging/etc/crowdsec
COPY --from=build /go/src/crowdsec/docker/docker_start.sh / COPY --from=build /go/src/crowdsec/docker/docker_start.sh /
COPY --from=build /go/src/crowdsec/docker/config.yaml /staging/etc/crowdsec/config.yaml COPY --from=build /go/src/crowdsec/docker/config.yaml /staging/etc/crowdsec/config.yaml
COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec
RUN yq -n '.url="http://0.0.0.0:8080"' | install -m 0600 /dev/stdin /staging/etc/crowdsec/local_api_credentials.yaml RUN yq -n '.url="http://0.0.0.0:8080"' | install -m 0600 /dev/stdin /staging/etc/crowdsec/local_api_credentials.yaml
ENTRYPOINT /bin/bash /docker_start.sh ENTRYPOINT /bin/bash /docker_start.sh
FROM slim as plugins FROM slim as full
# 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 # 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 # The files are here for reference, as users will need to mount a new version to be actually able to use notifications
@ -60,11 +61,3 @@ COPY --from=build \
/staging/etc/crowdsec/notifications/ /staging/etc/crowdsec/notifications/
COPY --from=build /usr/local/lib/crowdsec/plugins /usr/local/lib/crowdsec/plugins COPY --from=build /usr/local/lib/crowdsec/plugins /usr/local/lib/crowdsec/plugins
FROM slim as geoip
COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec
FROM plugins as full
COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec

View file

@ -6,7 +6,7 @@ CROWDSEC_TEST_VERSION="dev"
# All of the following flavors will be tested when using the "flavor" fixture # All of the following flavors will be tested when using the "flavor" fixture
CROWDSEC_TEST_FLAVORS="full" CROWDSEC_TEST_FLAVORS="full"
# CROWDSEC_TEST_FLAVORS="full,slim,debian" # CROWDSEC_TEST_FLAVORS="full,slim,debian"
# CROWDSEC_TEST_FLAVORS="full,slim,debian,geoip,plugins-debian-slim,debian-geoip,debian-plugins" # CROWDSEC_TEST_FLAVORS="full,slim,debian,debian-slim"
# network to use # network to use
CROWDSEC_TEST_NETWORK="net-test" CROWDSEC_TEST_NETWORK="net-test"

View file

@ -42,7 +42,7 @@ def test_flavor_content(crowdsec, flavor):
x = cs.cont.exec_run( x = cs.cont.exec_run(
'ls -1 /usr/local/lib/crowdsec/plugins/') 'ls -1 /usr/local/lib/crowdsec/plugins/')
stdout = x.output.decode() stdout = x.output.decode()
if 'slim' in flavor or 'geoip' in flavor: if 'slim' in flavor:
# the exact return code and full message depend # the exact return code and full message depend
# on the 'ls' implementation (busybox vs coreutils) # on the 'ls' implementation (busybox vs coreutils)
assert x.exit_code != 0 assert x.exit_code != 0