Skip to content

Commit 02502b2

Browse files
authored
Containerize server builds (#24)
1 parent 5c71470 commit 02502b2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ You can build and run the Dockerfile directly as a Docker container.
4646

4747
```sh
4848
cd images/chromium-headful
49-
../../shared/build-server.sh bin
5049
IMAGE=kernel-docker ./build-docker.sh
5150
IMAGE=kernel-docker ENABLE_WEBRTC=true ./run-docker.sh
5251
```
@@ -163,4 +162,4 @@ For issues, questions, or feedback, please [open an issue](https://github.com/on
163162
- Thank you to [xonkernel](https://github.com/xonkernel) for leading the development of our WebRTC live view.
164163
- Thank you to the [Unikraft Cloud](https://unikraft.cloud/) team for your help with unikernels.
165164

166-
Made with ❤️ by the [Kernel team](https://www.onkernel.com).
165+
Made with ❤️ by the [Kernel team](https://www.onkernel.com).

shared/build-server.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2525
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
2626

2727
# 1. Build the binary in the server module
28-
pushd "$REPO_ROOT/server" >/dev/null
29-
GOOS="$TARGET_OS" GOARCH="$TARGET_ARCH" CGO_ENABLED=0 make build
30-
popd >/dev/null
28+
GO_REQUIRED=$(grep -E "^go [0-9]+\.[0-9]+" "$REPO_ROOT/server/go.mod" | head -n1 | awk '{print $2}')
29+
echo "🔨 Building kernel-images-api binary using go ${GO_REQUIRED}"
30+
docker run --rm \
31+
-e GOOS="$TARGET_OS" \
32+
-e GOARCH="$TARGET_ARCH" \
33+
-e CGO_ENABLED=0 \
34+
-e GOFLAGS="-buildvcs=false" \
35+
-v "$REPO_ROOT":/workspace \
36+
-w /workspace/server \
37+
"golang:${GO_REQUIRED}" \
38+
make build
3139

3240
# 2. Copy to destination
3341
mkdir -p "$DEST_DIR"

0 commit comments

Comments
 (0)