Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve builds #2347

Merged
merged 11 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 11 additions & 93 deletions .docker/prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,113 +1,31 @@
ARG VERSION=edge
ARG GVM_LIBS_VERSION=oldstable
ARG GVM_LIBS_VERSION=stable
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
FROM registry.community.greenbone.net/community/gvm-libs:${GVM_LIBS_VERSION} AS builder
ARG FEATURE_TOGGLE

COPY . /source
WORKDIR /source

RUN mkdir /build && \
mkdir /install && \
cd /build && \
cmake -DCMAKE_BUILD_TYPE=Release $FEATURE_TOGGLE /source && \
make DESTDIR=/install install
RUN sh /source/.github/install-dependencies.sh \
/source/.github/build-dependencies.list \
&& rm -rf /var/lib/apt/lists/*

RUN cmake -DCMAKE_BUILD_TYPE=Release -B/build /source && \
DESTDIR=/install cmake --build /build -j$(nproc) -- install

FROM registry.community.greenbone.net/community/gvm-libs:${GVM_LIBS_VERSION}

ARG DEBIAN_FRONTEND=noninteractive

# Runtime dependencies

# PDF Report
# texlive-fonts-recommended
# texlive-latex-extra

# HTML Reports, cert data and scan data details
# xsltproc

# verinice report
# xsltproc
# xmlstarlet
# zip

# RPM credential packages
# rpm
# fakeroot

# DEB credential packages
# dpkg
# fakeroot

# Windows Executable (.exe) credential installer
# nsis

# signature verification
# gnupg

# HTTP alerts
# wget

# SCP alert
# sshpass
# openssh-client

# Send alert
# socat

# SNMP alert
# snmp

# SMB alert
# python3
# smbclient

# s/mime email encryption
# gpgsm

# Required for set up certificates for GVM
# gnutls-bin

RUN apt-get update && \
apt-get install -y --no-install-recommends \
dpkg \
fakeroot \
nsis \
gosu \
gnupg \
gpgsm \
gnutls-bin \
libbsd0 \
libcjson1 \
libgpgme11 \
libical3 \
libpq5 \
msmtp \
msmtp-mta \
openssh-client \
postgresql-client-13 \
postgresql-client-common \
python3 \
rpm \
rsync \
socat \
smbclient \
snmp \
sshpass \
texlive-fonts-recommended \
texlive-latex-extra \
wget \
xmlstarlet \
xsltproc \
zip && \
rm -rf /var/lib/apt/lists/*
RUN --mount=type=bind,source=.github,target=/source/ \
sh /source/install-dependencies.sh /source/runtime-dependencies.list \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /install/ /

Expand Down
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.git
.github
.vscode
build
13 changes: 13 additions & 0 deletions .github/build-dependencies.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
build-essential
cmake
lcov
libbsd-dev
libcjson-dev
libglib2.0-dev
libgnutls28-dev
libgpgme-dev
libical-dev
libpq-dev
pkg-config
postgresql-server-dev-all
xsltproc
16 changes: 16 additions & 0 deletions .github/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# This script installs the dependencies of gvmd
set -e

BASEDIR=$(dirname "$0")
DEFAULT_DEPENDENCIES_FILE="$BASEDIR/build-dependencies.list"
DEPENDENCIES_FILE=${1:-$DEFAULT_DEPENDENCIES_FILE}

if [[ ! -f "$DEPENDENCIES_FILE" ]]; then
echo "Dependencies file not found: $DEPENDENCIES_FILE"
exit 1
fi

apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
$(grep -v '#' "$DEPENDENCIES_FILE")
80 changes: 80 additions & 0 deletions .github/runtime-dependencies.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Runtime dependencies

# PDF Report
# texlive-fonts-recommended
# texlive-latex-extra

# HTML Reports, cert data and scan data details
# xsltproc

# verinice report
# xsltproc
# xmlstarlet
# zip

# RPM credential packages
# rpm
# fakeroot

# DEB credential packages
# dpkg
# fakeroot

# Windows Executable (.exe) credential installer
# nsis

# signature verification
# gnupg

# HTTP alerts
# wget

# SCP alert
# sshpass
# openssh-client

# Send alert
# socat

# SNMP alert
# snmp

# SMB alert
# python3
# smbclient

# s/mime email encryption
# gpgsm

# Required for set up certificates for GVM
# gnutls-bin

dpkg
fakeroot
nsis
gosu
gnupg
gpgsm
gnutls-bin
libbsd0
libcjson1
libgpgme11
libical3
libpq5
msmtp
msmtp-mta
openssh-client
postgresql-client-common
python3
rpm
rsync
socat
smbclient
snmp
sshpass
texlive-fonts-recommended
texlive-latex-extra
wget
xmlstarlet
xsltproc
zip
38 changes: 31 additions & 7 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ jobs:
scan-build:
name: scan-build (clang static analyzer)
runs-on: ubuntu-latest
container: ${{ vars.IMAGE_REGISTRY }}/greenbone/gvmd-build:stable
container: ${{ vars.SELF_HOSTED_REGISTRY }}/community/gvm-libs:stable
steps:
- name: Check out gvmd
uses: actions/checkout@v4
- name: Install clang tools
run: |
apt update
apt install --no-install-recommends -y clang clang-format clang-tools
rm -rf /var/lib/apt/lists/*
- name: Install build dependencies
run: sh .github/install-dependencies.sh .github/build-dependencies.list
- name: Configure scan build
run: |
scan-build cmake -B build -DCMAKE_BUILD_TYPE=Debug
Expand All @@ -43,18 +44,41 @@ jobs:
path: ~/scan-build-report/
retention-days: 7

build-gvmd:
name: Build gvmd
runs-on: ubuntu-latest
strategy:
matrix:
container:
- stable
- oldstable
- testing
container: ${{ vars.SELF_HOSTED_REGISTRY }}/community/gvm-libs:${{ matrix.container }}
steps:
- uses: actions/checkout@v4
- name: Install build dependencies
run: sh .github/install-dependencies.sh .github/build-dependencies.list
- name: Configure and compile gvmd
run: |
rm -rf .git
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j $(nproc) -- install

test-units:
name: Unit Tests
runs-on: ubuntu-latest
container: ${{ vars.IMAGE_REGISTRY }}/greenbone/gvmd-build:stable
container: ${{ vars.SELF_HOSTED_REGISTRY }}/community/gvm-libs:stable
steps:
- name: Check out gvmd
uses: actions/checkout@v4
- name: Install git for Codecov uploader
run: |
apt update
apt install --no-install-recommends -y ca-certificates git
rm -rf /var/lib/apt/lists/*
- name: Check out gvmd
uses: actions/checkout@v4
- name: Install build dependencies
run: sh .github/install-dependencies.sh .github/build-dependencies.list
- name: "Instal cgreen"
uses: greenbone/actions/install-cgreen@v3
- name: Set git safe.directory
run: git config --global --add safe.directory '*'
- name: Build gvmd
Expand All @@ -66,6 +90,6 @@ jobs:
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: build/coverage/coverage.xml
files: build/coverage/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
64 changes: 0 additions & 64 deletions .github/workflows/build-container.yml

This file was deleted.

Loading
Loading