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

Add caddy server static PIE build #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions caddy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/caddy-*
/v2.*.tar.gz
31 changes: 31 additions & 0 deletions caddy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Build caddy server as static PIE

Build the [caddy server](https://caddyserver.com/) web server as a static PIE ELF running on Linux.

## Requirements

Make sure the following packages are installed:
* go >= 1.17

## Build

The `caddy` static PIE ELF is located in the current folder.
If you want to rebuild it, run:

```
$ ./build.sh
```

## Run

You can run the executable natively on Linux:

```
$ ./caddy-2.6.2/cmd/caddy/caddy respond --debug --access-log --listen :8089 "Hello world\!"
```

Or with [run-elfloader](https://github.com/unikraft/run-app-elfloader) on Unikraft:
```
$ ./run_elfloader ../static-pie-apps/caddy/caddy-2.6.2/cmd/caddy/caddy [args]
```

16 changes: 16 additions & 0 deletions caddy/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# Clean up
rm -rf caddy-*
rm -f v2.*

echo "Downloading caddy source code... "
wget -q https://github.com/caddyserver/caddy/archive/refs/tags/v2.6.2.tar.gz

echo "Unpacking caddy source code..."
tar xzf v2.6.2.tar.gz

echo "Building caddy... "
cd caddy-2.6.2/cmd/caddy
CGO_ENABLED=1 go build -buildmode=pie -ldflags "-linkmode external -extldflags "-static-pie""
echo ""
5 changes: 5 additions & 0 deletions caddy/rootfs/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:80

route {
teapot
}