Bladeren bron

docker: build same re2 version for alpine/debian; bump yq (#2311)

also slightly improve layer cache usage
mmetc 2 jaren geleden
bovenliggende
commit
6e18c652cb
2 gewijzigde bestanden met toevoegingen van 23 en 15 verwijderingen
  1. 8 9
      Dockerfile
  2. 15 6
      Dockerfile.debian

+ 8 - 9
Dockerfile

@@ -5,29 +5,28 @@ FROM golang:${GOVERSION}-alpine AS build
 
 
 WORKDIR /go/src/crowdsec
 WORKDIR /go/src/crowdsec
 
 
-COPY . .
-
-# Alpine does not ship a static version of re2, we can build it ourselves
-# Later versions require 'abseil', which is likewise not available in its static form
+# We like to choose the release of re2 to use, and Alpine does not ship a static version anyway.
 ENV RE2_VERSION=2023-03-01
 ENV RE2_VERSION=2023-03-01
 
 
 # wizard.sh requires GNU coreutils
 # wizard.sh requires GNU coreutils
-RUN apk add --no-cache git g++ gcc libc-dev make bash gettext binutils-gold coreutils icu-static re2-dev pkgconfig && \
+RUN apk add --no-cache git g++ gcc libc-dev make bash gettext binutils-gold coreutils icu-static pkgconfig && \
     wget https://github.com/google/re2/archive/refs/tags/${RE2_VERSION}.tar.gz && \
     wget https://github.com/google/re2/archive/refs/tags/${RE2_VERSION}.tar.gz && \
     tar -xzf ${RE2_VERSION}.tar.gz && \
     tar -xzf ${RE2_VERSION}.tar.gz && \
     cd re2-${RE2_VERSION} && \
     cd re2-${RE2_VERSION} && \
     make && \
     make && \
     make install && \
     make install && \
     echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
     echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
-    cd - && \
-    make clean release DOCKER_BUILD=1 BUILD_STATIC=1 && \
+    go install github.com/mikefarah/yq/v4@v4.34.1
+
+COPY . .
+
+RUN make clean release DOCKER_BUILD=1 BUILD_STATIC=1 && \
     cd crowdsec-v* && \
     cd crowdsec-v* && \
     ./wizard.sh --docker-mode && \
     ./wizard.sh --docker-mode && \
     cd - >/dev/null && \
     cd - >/dev/null && \
     cscli hub update && \
     cscli hub update && \
     cscli collections install crowdsecurity/linux && \
     cscli collections install crowdsecurity/linux && \
-    cscli parsers install crowdsecurity/whitelists && \
-    go install github.com/mikefarah/yq/v4@v4.31.2
+    cscli parsers install crowdsecurity/whitelists
 
 
     # In case we need to remove agents here..
     # In case we need to remove agents here..
     # cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete
     # cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete

+ 15 - 6
Dockerfile.debian

@@ -5,23 +5,32 @@ FROM golang:${GOVERSION}-bookworm AS build
 
 
 WORKDIR /go/src/crowdsec
 WORKDIR /go/src/crowdsec
 
 
-COPY . .
-
 ENV DEBIAN_FRONTEND=noninteractive
 ENV DEBIAN_FRONTEND=noninteractive
 ENV DEBCONF_NOWARNINGS="yes"
 ENV DEBCONF_NOWARNINGS="yes"
 
 
+# We like to choose the release of re2 to use, the debian version is usually older.
+ENV RE2_VERSION=2023-03-01
+
 # wizard.sh requires GNU coreutils
 # wizard.sh requires GNU coreutils
 RUN apt-get update && \
 RUN apt-get update && \
-    apt-get install -y -q git gcc libc-dev make bash gettext binutils-gold coreutils tzdata libre2-dev && \
+    apt-get install -y -q git gcc libc-dev make bash gettext binutils-gold coreutils tzdata && \
+    wget https://github.com/google/re2/archive/refs/tags/${RE2_VERSION}.tar.gz && \
+    tar -xzf ${RE2_VERSION}.tar.gz && \
+    cd re2-${RE2_VERSION} && \
+    make && \
+    make install && \
     echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
     echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
-    make clean release DOCKER_BUILD=1 BUILD_STATIC=1 && \
+    go install github.com/mikefarah/yq/v4@v4.34.1
+
+COPY . .
+
+RUN make clean release DOCKER_BUILD=1 BUILD_STATIC=1 && \
     cd crowdsec-v* && \
     cd crowdsec-v* && \
     ./wizard.sh --docker-mode && \
     ./wizard.sh --docker-mode && \
     cd - >/dev/null && \
     cd - >/dev/null && \
     cscli hub update && \
     cscli hub update && \
     cscli collections install crowdsecurity/linux && \
     cscli collections install crowdsecurity/linux && \
-    cscli parsers install crowdsecurity/whitelists && \
-    go install github.com/mikefarah/yq/v4@v4.31.2
+    cscli parsers install crowdsecurity/whitelists
 
 
     # In case we need to remove agents here..
     # In case we need to remove agents here..
     # cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete
     # cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete