Skip to content

Commit 1a9c0a1

Browse files
authored
Merge pull request #5 from flashbots/dummy-dcap
Adds a dummy dcap image
2 parents 42ca68c + 899a169 commit 1a9c0a1

File tree

8 files changed

+81
-1
lines changed

8 files changed

+81
-1
lines changed
File renamed without changes.

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Usage
1818

1919
```shell
2020
nix develop -c $SHELL
21-
mkosi --force
21+
mkosi --force -I buildernet.conf
2222
```
2323

2424
> Note: Make sure the above command is not run with sudo, as this will clear necessary environment variables set by the nix shell

scripts/make_git_package.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#
3+
# Note env variables: DESTDIR, BUILDROOT, GOCACHE
4+
5+
make_git_package() {
6+
local package="$1"
7+
local version="$2"
8+
local git_url="$3"
9+
local build_cmd="$4"
10+
# All remaining arguments are artifact mappings in src:dest format
11+
12+
mkdir -p "$DESTDIR/usr/bin"
13+
14+
# Clone the repository
15+
local build_dir="$BUILDROOT/build/$package"
16+
git clone --depth 1 --branch "$version" "$git_url" "$build_dir"
17+
18+
# Build inside mkosi chroot with custom build command
19+
mkosi-chroot bash -c "cd '/build/$package' && $build_cmd"
20+
21+
# Process each artifact mapping
22+
for artifact_map in "${@:5}"; do
23+
# Split the mapping into source and destination
24+
local src=$(echo "$artifact_map" | cut -d':' -f1)
25+
local dest=$(echo "$artifact_map" | cut -d':' -f2)
26+
27+
# Create destination directory if needed
28+
mkdir -p "$(dirname "$DESTDIR$dest")"
29+
30+
# Copy the artifact
31+
cp "$build_dir/$src" "$DESTDIR$dest"
32+
done
33+
}
34+
35+
# Example usage:
36+
# make_git_package "myapp" "v1.0.0" "https://github.com/user/myapp.git" "make build" \
37+
# "bin/myapp:/usr/bin/myapp" \
38+
# "config/myapp.conf:/etc/myapp/myapp.conf"

tdx-dummy.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[Config]
2+
Include=base/base.conf
3+
Include=tdx-dummy/tdx-dummy.conf
4+
Include=devtools/devtools.conf

tdx-dummy/dummy-tdx-dcap.service

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Unit]
2+
Description=Dummy TDX DCAP server
3+
After=network-setup.service
4+
Wants=network-setup.service
5+
6+
[Service]
7+
Type=exec
8+
User=root
9+
Group=root
10+
ExecStart=/usr/bin/dummy-tdx-dcap --listen-addr 0.0.0.0:8080
11+
Restart=on-failure
12+
RestartSec=10
13+
StandardOutput=journal
14+
StandardError=journal
15+
16+
[Install]
17+
WantedBy=minimal.target

tdx-dummy/mkosi.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
source scripts/make_git_package.sh
5+
6+
make_git_package "dummy-tdx-dcap" "v0.0.1" "https://github.com/Ruteri/dummy-tdx-dcap" 'go build -trimpath -ldflags "-s -w -buildid= -X github.com/flashbots/go-template/common.Version=v0.0.1" -v -o ./build/httpserver cmd/httpserver/main.go' "build/httpserver:/usr/bin/dummy-tdx-dcap"

tdx-dummy/mkosi.postinst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
# Install systemd service units
5+
SERVICE_DIR="$BUILDROOT/etc/systemd/system"
6+
mkdir -p "$SERVICE_DIR"
7+
8+
install -m 644 "tdx-dummy/dummy-tdx-dcap.service" "$SERVICE_DIR/"

tdx-dummy/tdx-dummy.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Content]
2+
WithNetwork=true
3+
BuildScripts=tdx-dummy/mkosi.build
4+
BuildPackages=ca-certificates
5+
golang-go
6+
git
7+
PostInstallationScripts=tdx-dummy/mkosi.postinst

0 commit comments

Comments
 (0)