-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/caddy-* | ||
/v2.*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 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 | ||
* git | ||
|
||
## 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] | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:80 | ||
|
||
route { | ||
teapot | ||
} |