Skip to content

Commit

Permalink
Adds possibility to add cmake flags to a container build
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtsfrei committed Apr 17, 2024
1 parent 75cfa30 commit d046f21
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .docker/prod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ ARG VERSION=edge
ARG GVM_LIBS_VERSION=oldstable
ARG DEBIAN_FRONTEND=noninteractive
ARG IMAGE_REGISTRY=ghcr.io
# when set it will added to the cmake command
# As an example:
# FEATURE_TOGGLES="-DOPENVASD=1"
# enables openvasd feature toggle.
ARG FEATURE_TOGGLE=""

FROM ${IMAGE_REGISTRY}/greenbone/gvmd-build:${VERSION} as builder
ARG FEATURE_TOGGLE

COPY . /source
WORKDIR /source

RUN mkdir /build && \
mkdir /install && \
cd /build && \
cmake -DCMAKE_BUILD_TYPE=Release /source && \
cmake -DCMAKE_BUILD_TYPE=Release $FEATURE_TOGGLE /source && \
make DESTDIR=/install install

FROM greenbone/gvm-libs:${GVM_LIBS_VERSION}
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
images:
name: Production Images
runs-on: ubuntu-latest
strategy:
matrix:
build:
- default
- openvasd
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -41,8 +46,9 @@ jobs:
type=ref,event=pr
# when a new git tag is created set stable and a latest tags
type=raw,value=latest,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
type=raw,value=stable,enable=${{ steps.latest.outputs.is-latest-tag == 'true' }}
type=raw,value=latest,enable=${{ steps.latest.outputs.is-latest-tag == 'true' && matrix.build == 'default'}}
type=raw,value=stable,enable=${{ steps.latest.outputs.is-latest-tag == 'true' && matrix.build == 'default'}}
type=raw,value=edge-openvasd,enable=${{ steps.latest.outputs.is-latest-tag == 'false' && matrix.build == 'openvasd' }}
- name: Set container build options
id: container-opts
run: |
Expand All @@ -53,6 +59,11 @@ jobs:
echo "version=edge" >> $GITHUB_OUTPUT
echo "gvm-libs-version=oldstable-edge" >> $GITHUB_OUTPUT
fi
if [[ "${{ matrix.build }}" = 'openvasd' ]]; then
echo 'ft=-DOPENVASD=1' >> $GITHUB_OUTPUT
else
echo 'ft=-DOPENVASD=0' >> $GITHUB_OUTPUT
fi
- name: Login to Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
Expand All @@ -71,6 +82,7 @@ jobs:
build-args: |
VERSION=${{ steps.container-opts.outputs.version }}
GVM_LIBS_VERSION=${{ steps.container-opts.outputs.gvm-libs-version }}
FEATURE_TOGGLE=${{ steps.container-opts.outputs.ft }}
IMAGE_REGISTRY=${{ vars.IMAGE_REGISTRY }}
file: .docker/prod.Dockerfile
platforms: linux/amd64,linux/arm64
Expand Down

0 comments on commit d046f21

Please sign in to comment.