Skip to content

Commit

Permalink
Add ccache to falco and collector devcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
Molter73 committed Oct 20, 2023
1 parent 883d2c8 commit 9e7df1c
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 33 deletions.
12 changes: 10 additions & 2 deletions collector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
FROM quay.io/stackrox-io/collector-builder:cache

RUN dnf install -y \
RUN dnf install -y epel-release && \
dnf install -y \
ccache \
clang-tools-extra \
clang-analyzer \
podman-docker && \
dnf clean all
dnf clean all && \
ln -s $(which ccache) /usr/local/bin/gcc && \
ln -s $(which ccache) /usr/local/bin/g++ && \
echo "" > /etc/profile.d/ccache.sh

ENV CC=/usr/local/bin/gcc
ENV CXX=/usr/local/bin/g++

COPY clangd.yaml /root/.config/clangd/config.yaml

Expand Down
2 changes: 2 additions & 0 deletions falco-libs/compile-falco.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function configure () {
-DBUILD_LIBSCAP_MODERN_BPF=ON \
-DUSE_BUNDLED_LIBBPF="${use_bundled_libbpf}" \
-DUSE_BUNDLED_ZLIB=ON \
-DUSE_BUNDLED_UTHASH=ON \
-DUSE_BUNDLED_TINYDIR=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCREATE_TEST_TARGETS=ON \
-DBUILD_SHARED_LIBS="${build_shared_libs}" \
Expand Down
9 changes: 8 additions & 1 deletion falco-libs/fedora.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM fedora:38
RUN dnf install -y \
gcc \
gcc-c++ \
ccache \
libasan \
libubsan \
bpftool \
Expand Down Expand Up @@ -46,13 +47,19 @@ RUN dnf install -y \
# Set some symlinks to allow building of drivers.
kernel_version=$(uname -r) && \
ln -s "/host/lib/modules/$kernel_version" "/lib/modules/$kernel_version" && \
ln -s "/host/usr/src/kernels/$kernel_version" "/usr/src/kernels/$kernel_version"
ln -s "/host/usr/src/kernels/$kernel_version" "/usr/src/kernels/$kernel_version" && \
ln -s $(which ccache) /usr/local/bin/gcc && \
ln -s $(which ccache) /usr/local/bin/g++ && \
echo "" > /etc/profile.d/ccache.sh

# Install docker CLI
RUN dnf config-manager --add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo && \
dnf install -y docker-ce-cli && \
dnf clean all

ENV CC=/usr/local/bin/gcc
ENV CXX=/usr/local/bin/g++

COPY clangd.yaml /root/.config/clangd/config.yaml
COPY compile-falco.sh /usr/bin/
12 changes: 12 additions & 0 deletions lua/collector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ M.setup = function(opts)
}
end

M.volume_claim = function()
return {
apiVersion = 'v1',
kind = 'PersistentVolumeClaim',
metadata = { name = 'collector-ccache', },
spec = {
accessModes = { 'ReadWriteOnce' },
resources = { requests = { storage = '5Gi' } },
},
}
end

return M
12 changes: 12 additions & 0 deletions lua/falco.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ M.setup = function(opts)
}
end

M.volume_claim = function()
return {
apiVersion = 'v1',
kind = 'PersistentVolumeClaim',
metadata = { name = 'falco-ccache', },
spec = {
accessModes = { 'ReadWriteOnce' },
resources = { requests = { storage = '5Gi' } },
},
}
end

return M
72 changes: 42 additions & 30 deletions lua/init.lua
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
local collector_repo = os.getenv('GOPATH') .. '/src/github.com/stackrox/collector'
local falco_repo = os.getenv('GOPATH') .. '/src/github.com/falcosecurity/libs'

local collector = require('collector')
local falco = require('falco')

local collector_claim = collector.volume_claim()
local falco_claim = falco.volume_claim()
local volumes = {
{ name = 'proc-fs', hostPath = { path = '/proc', } },
{ name = 'sys-fs', hostPath = { path = '/sys', } },
{ name = 'etc-fs', hostPath = { path = '/etc', } },
{ name = 'dev-fs', hostPath = { path = '/dev', } },
{ name = 'usr-lib-fs', hostPath = { path = '/usr/lib', } },
{ name = 'usr-src-fs', hostPath = { path = '/usr/src', } },
{ name = 'modules-fs', hostPath = { path = '/lib/modules', } },
{ name = 'docker-sock', hostPath = { path = '/var/run/docker.sock', } },
{ name = 'collector-repo', hostPath = { path = collector_repo, } },
{ name = 'falco-repo', hostPath = { path = falco_repo, } },
{ name = 'proc-fs', hostPath = { path = '/proc', } },
{ name = 'sys-fs', hostPath = { path = '/sys', } },
{ name = 'etc-fs', hostPath = { path = '/etc', } },
{ name = 'dev-fs', hostPath = { path = '/dev', } },
{ name = 'usr-lib-fs', hostPath = { path = '/usr/lib', } },
{ name = 'usr-src-fs', hostPath = { path = '/usr/src', } },
{ name = 'modules-fs', hostPath = { path = '/lib/modules', } },
{ name = 'docker-sock', hostPath = { path = '/var/run/docker.sock', } },
{ name = 'collector-repo', hostPath = { path = collector_repo, } },
{ name = 'falco-repo', hostPath = { path = falco_repo, } },
{ name = 'collector-ccache', persistentVolumeClaim = { claimName = collector_claim.metadata.name } },
{ name = 'falco-ccache', persistentVolumeClaim = { claimName = falco_claim.metadata.name, } },
}

local collector_opts = {
repo_path = collector_repo,
volumes = {
{ mountPath = '/host/proc', name = 'proc-fs', readOnly = true, },
{ mountPath = '/host/sys', name = 'sys-fs', readOnly = true, },
{ mountPath = '/host/etc', name = 'etc-fs', readOnly = true, },
{ mountPath = '/host/usr/lib', name = 'usr-lib-fs', readOnly = true, },
{ mountPath = collector_repo, name = 'collector-repo', },
{ mountPath = '/host/proc', name = 'proc-fs', readOnly = true, },
{ mountPath = '/host/sys', name = 'sys-fs', readOnly = true, },
{ mountPath = '/host/etc', name = 'etc-fs', readOnly = true, },
{ mountPath = '/host/usr/lib', name = 'usr-lib-fs', readOnly = true, },
{ mountPath = '/root/.cache/ccache', name = 'collector-ccache', },
{ mountPath = collector_repo, name = 'collector-repo', },
},
}

local falco_opts = {
repo_path = falco_repo,
volumes = {
{ name = 'usr-src-fs', mountPath = '/usr/src', },
{ name = 'modules-fs', mountPath = '/lib/modules', },
{ name = 'docker-sock', mountPath = '/var/run/docker.sock', },
{ name = 'dev-fs', mountPath = '/host/dev', readOnly = true, },
{ name = 'proc-fs', mountPath = '/host/proc', readOnly = true, },
{ name = 'sys-fs', mountPath = '/host/sys', readOnly = true, },
{ name = 'etc-fs', mountPath = '/host/etc', readOnly = true, },
{ name = 'usr-lib-fs', mountPath = '/host/usr/lib', readOnly = true, },
{ mountPath = falco_repo, name = 'falco-repo', },
{ mountPath = '/host/dev', name = 'dev-fs', readOnly = true, },
{ mountPath = '/host/proc', name = 'proc-fs', readOnly = true, },
{ mountPath = '/host/sys', name = 'sys-fs', readOnly = true, },
{ mountPath = '/host/etc', name = 'etc-fs', readOnly = true, },
{ mountPath = '/host/usr/lib', name = 'usr-lib-fs', readOnly = true, },
{ mountPath = '/usr/src', name = 'usr-src-fs', },
{ mountPath = '/lib/modules', name = 'modules-fs', },
{ mountPath = '/var/run/docker.sock', name = 'docker-sock', },
{ mountPath = '/root/.cache/ccache', name = 'falco-ccache', },
{ mountPath = falco_repo, name = 'falco-repo', },
}
}

Expand All @@ -49,20 +58,23 @@ local metadata = {
}
}

local collector = require('collector').setup(collector_opts)
local falco = require('falco').setup(falco_opts)

local spec = {
containers = {
collector,
falco,
collector.setup(collector_opts),
falco.setup(falco_opts),
},
volumes = volumes,
}

return {
local pod = {
apiVersion = 'v1',
kind = 'Pod',
metadata = metadata,
spec = spec,
}

return {
collector_claim,
falco_claim,
pod,
}

0 comments on commit 9e7df1c

Please # to comment.