Skip to content

Commit

Permalink
Add os-uno devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Molter73 committed Apr 2, 2024
1 parent d538129 commit 92bf186
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: all
all: collector falco clean
all: collector falco os-uni clean
kluars xlate $(CURDIR)/lua | podman play kube -

.PHONY: clean
Expand All @@ -13,3 +13,7 @@ collector:
.PHONY: falco
falco:
make -C falco-libs build

.PHONY: os-uni
os-uni:
make -C os-uni build
3 changes: 2 additions & 1 deletion collector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ RUN dnf install -y epel-release && \
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
echo "" > /etc/profile.d/ccache.sh && \
echo 'export MAKEFLAGS="-j$(nproc)"' >> /root/.bashrc

ENV CC=/usr/local/bin/gcc
ENV CXX=/usr/local/bin/g++
Expand Down
1 change: 1 addition & 0 deletions collector/clangd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Diagnostics:
- readability-identifier-length
- modernize-use-nodiscard
- modernize-use-trailing-return-type
- cppcoreguidelines-avoid-magic-numbers
CheckOptions:
readability-identifier-naming.NamespaceCase: lower_case
readability-identifier-naming.ClassCase: CamelCase
Expand Down
25 changes: 19 additions & 6 deletions lua/init.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
local collector_repo = os.getenv('GOPATH') .. '/src/github.com/stackrox/collector'
local falco_repo = os.getenv('GOPATH') .. '/src/github.com/falcosecurity/libs'
local os_uni_repo = os.getenv('GOPATH') .. '/src/github.com/molter73/os-uni'
local user_name = os.getenv("USER")
local collector_home_mountpath = '/home/' .. user_name .. '/go/src/github.com/stackrox/collector'

local collector = require('collector')
local falco = require('falco')
local os_uni = require('os-uni')

local collector_claim = collector.volume_claim()
local falco_claim = falco.volume_claim()
Expand All @@ -17,19 +21,21 @@ local volumes = {
{ name = 'docker-sock', hostPath = { path = '/var/run/docker.sock', } },
{ name = 'collector-repo', hostPath = { path = collector_repo, } },
{ name = 'falco-repo', hostPath = { path = falco_repo, } },
{ name = 'os-uni-repo', hostPath = { path = os_uni_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 = '/root/.cache/ccache', name = 'collector-ccache', },
{ 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', },
{ mountPath = collector_home_mountpath, name = 'collector-repo', },
},
}

Expand All @@ -49,6 +55,12 @@ local falco_opts = {
}
}

local os_uni_opts = {
repo_path = os_uni_repo,
volumes = {
{ mountPath = os_uni_repo, name = 'os-uni-repo', },
},
}

local metadata = {
name = 'devcontainers',
Expand All @@ -62,6 +74,7 @@ local spec = {
containers = {
collector.setup(collector_opts),
falco.setup(falco_opts),
os_uni.setup(os_uni_opts),
},
volumes = volumes,
}
Expand Down
24 changes: 24 additions & 0 deletions lua/os-uni.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local name = 'os-uni-builder'

local M = {}

M.setup = function(opts)
local repo_path = opts.repo_path or os.exit(1)
return {
name = name,
image = 'quay.io/mmoltras/devcontainers:os-uni',
workingDir = repo_path,
command = { '/bin/bash', },
env = {
{ name = 'CMAKE_EXPORT_COMPILE_COMMANDS', value = 'ON', },
},
securityContext = {
privileged = true,
},
volumeMounts = opts.volumes or {},
stdin = true,
tty = true,
}
end

return M
18 changes: 18 additions & 0 deletions os-uni/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM fedora:39

# hadolint ignore=DL3041
RUN dnf install -y \
gcc \
gdb \
procps \
make \
ncurses \
python3-pip \
# vvv clangd vvv
clang-tools-extra \
bear && \
dnf clean all

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

WORKDIR /workdir
7 changes: 7 additions & 0 deletions os-uni/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: all
all: build

.PHONY: build
build:
docker build -t quay.io/mmoltras/devcontainers:os-uni \
-f $(CURDIR)/Containerfile $(CURDIR)
13 changes: 13 additions & 0 deletions os-uni/clangd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Diagnostics:
ClangTidy:
Add:
- bugprone*
- cppcoreguidelines*
- modernize*
- performance*
- readability*
Remove:
- readability-identifier-length
- modernize-use-nodiscard
- modernize-use-trailing-return-type
- cppcoreguidelines-avoid-magic-numbers

0 comments on commit 92bf186

Please # to comment.