Docker: allow setting BUILD_VERSION as a build argument (#2736)

* Docker: allow setting BUILD_VERSION as a build argument
* CI: don't attempt to publish docker images outside of crowdecurity org
* use go 1.21.6 for docker and windows too
This commit is contained in:
mmetc 2024-01-15 11:05:27 +01:00 committed by GitHub
parent 6ca053ca67
commit 03bb194d2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 5 deletions

View file

@ -19,6 +19,7 @@ jobs:
push_to_registry:
name: Push Debian Docker image to Docker Hub
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'crowdsecurity' }}
steps:
- name: Check out the repo

View file

@ -19,6 +19,7 @@ jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'crowdsecurity' }}
steps:
- name: Check out the repo

View file

@ -1,5 +1,6 @@
# vim: set ft=dockerfile:
ARG GOVERSION=1.21.5
ARG GOVERSION=1.21.6
ARG BUILD_VERSION
FROM golang:${GOVERSION}-alpine3.18 AS build
@ -7,6 +8,7 @@ WORKDIR /go/src/crowdsec
# 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 BUILD_VERSION=${BUILD_VERSION}
# wizard.sh requires GNU coreutils
RUN apk add --no-cache git g++ gcc libc-dev make bash gettext binutils-gold coreutils pkgconfig && \

View file

@ -1,5 +1,6 @@
# vim: set ft=dockerfile:
ARG GOVERSION=1.21.5
ARG GOVERSION=1.21.6
ARG BUILD_VERSION
FROM golang:${GOVERSION}-bookworm AS build
@ -10,6 +11,7 @@ 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
ENV BUILD_VERSION=${BUILD_VERSION}
# wizard.sh requires GNU coreutils
RUN apt-get update && \

View file

@ -25,9 +25,9 @@ stages:
custom: 'tool'
arguments: 'install --global SignClient --version 1.3.155'
- task: GoTool@0
displayName: "Install Go 1.20"
displayName: "Install Go"
inputs:
version: '1.21.5'
version: '1.21.6'
- pwsh: |
choco install -y make

View file

@ -8,7 +8,11 @@ MKDIR=mkdir -p
GOOS ?= $(shell go env GOOS)
# Current versioning information from env
BUILD_VERSION?=$(shell git describe --tags)
# The $(or) is used to ignore an empty BUILD_VERSION when it's an envvar,
# like inside a docker build: docker build --build-arg BUILD_VERSION=1.2.3
# as opposed to a make parameter: make BUILD_VERSION=1.2.3
BUILD_VERSION:=$(or $(BUILD_VERSION),$(shell git describe --tags --dirty))
BUILD_TIMESTAMP=$(shell date +%F"_"%T)
DEFAULT_CONFIGDIR?=/etc/crowdsec
DEFAULT_DATADIR?=/var/lib/crowdsec/data