diff --git a/.github/workflows/release_publish_docker-image.yml b/.github/workflows/release_publish_docker-image.yml index 102e28276..3a90fea1b 100644 --- a/.github/workflows/release_publish_docker-image.yml +++ b/.github/workflows/release_publish_docker-image.yml @@ -60,8 +60,7 @@ jobs: file: ./Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags_slim }} - build-args: | - BUILD_ENV=slim + target: slim platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386 labels: | org.opencontainers.image.source=${{ github.event.repository.html_url }} diff --git a/Dockerfile b/Dockerfile index 2fbece717..8eb91d699 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ # vim: set ft=dockerfile: -ARG BUILD_ENV=full ARG GOVERSION=1.19 FROM golang:${GOVERSION}-alpine AS build @@ -20,7 +19,7 @@ RUN apk add --no-cache git gcc libc-dev make bash gettext binutils-gold coreutil cscli parsers install crowdsecurity/whitelists && \ go install github.com/mikefarah/yq/v4@v4.30.6 -FROM alpine:latest as build-slim +FROM alpine:latest as slim RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community tzdata bash && \ mkdir -p /staging/etc/crowdsec && \ @@ -37,7 +36,7 @@ RUN yq -n '.url="http://0.0.0.0:8080"' | install -m 0600 /dev/stdin /staging/etc ENTRYPOINT /bin/bash docker_start.sh -FROM build-slim as build-plugins +FROM slim as 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 @@ -47,12 +46,10 @@ COPY --from=build /go/src/crowdsec/plugins/notifications/slack/slack.yaml /stagi 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 -FROM build-slim as build-geoip +FROM slim as geoip COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec -FROM build-plugins as build-full +FROM plugins as full COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec - -FROM build-${BUILD_ENV} diff --git a/Dockerfile.debian b/Dockerfile.debian index ebae4d376..595da2b57 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -1,5 +1,4 @@ # vim: set ft=dockerfile: -ARG BUILD_ENV=full ARG GOVERSION=1.19 FROM golang:${GOVERSION}-bullseye AS build @@ -24,7 +23,7 @@ RUN apt-get update && \ cscli parsers install crowdsecurity/whitelists && \ go install github.com/mikefarah/yq/v4@v4.30.6 -FROM debian:bullseye-slim as build-slim +FROM debian:bullseye-slim as slim ENV DEBIAN_FRONTEND=noninteractive ENV DEBCONF_NOWARNINGS="yes" @@ -53,7 +52,7 @@ RUN yq -n '.url="http://0.0.0.0:8080"' | install -m 0600 /dev/stdin /staging/etc ENTRYPOINT /bin/bash docker_start.sh -FROM build-slim as build-plugins +FROM slim as 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 @@ -63,12 +62,10 @@ COPY --from=build /go/src/crowdsec/plugins/notifications/slack/slack.yaml /stagi 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 -FROM build-slim as build-geoip +FROM slim as geoip COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec -FROM build-plugins as build-full +FROM plugins as full COPY --from=build /var/lib/crowdsec /staging/var/lib/crowdsec - -FROM build-${BUILD_ENV} diff --git a/docker/README.md b/docker/README.md index d7146fa5a..6e1d7ab20 100644 --- a/docker/README.md +++ b/docker/README.md @@ -48,10 +48,16 @@ You can build your images with Dockerfile and Dockerfile-debian. For example, if you want a Debian version without plugin notifiers: ```console -$ docker build -f Dockerfile.debian --build-arg=BUILD_ENV=slim +$ docker build -f Dockerfile.debian --target slim ``` -supported values for BUILD_ENV are: full, with-geoip, with-plugins, slim. +The supported values for target are: full, with-geoip, with-plugins, slim. + +Note: for crowdsec versions < 1.5.0, the syntax is + +```console +$ docker build -f Dockerfile.debian --build-arg=BUILD_ENV=slim +``` ## Required configuration