Skip to content

Commit

Permalink
Docker: allow setting BUILD_VERSION as a build argument (crowdsecurit…
Browse files Browse the repository at this point in the history
…y#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
  • Loading branch information
mmetc authored Jan 15, 2024
1 parent 6ca053c commit 03bb194
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_docker-image_on_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# vim: set ft=dockerfile:
ARG GOVERSION=1.21.5
ARG GOVERSION=1.21.6
ARG BUILD_VERSION

FROM golang:${GOVERSION}-alpine3.18 AS build

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 && \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 && \
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion mk/platform/unix_common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03bb194

Please sign in to comment.