Skip to content

Commit 49188be

Browse files
authored
add rook reverse-connect sandbox agent for k8s provider (#15)
* add rook reverse-connect sandbox agent for k8s provider * fix clippy warnings in rook
1 parent b0dce36 commit 49188be

16 files changed

Lines changed: 960 additions & 319 deletions

File tree

.github/workflows/release.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
env:
99
REGISTRY: ghcr.io
1010
IMAGE: ghcr.io/${{ github.repository }}
11+
ROOK_IMAGE: ghcr.io/${{ github.repository }}-rook
1112

1213
jobs:
1314
build:
@@ -59,6 +60,103 @@ jobs:
5960
if-no-files-found: error
6061
retention-days: 1
6162

63+
build-rook:
64+
name: Build rook (${{ matrix.platform }})
65+
runs-on: ${{ matrix.runner }}
66+
permissions:
67+
packages: write
68+
strategy:
69+
matrix:
70+
include:
71+
- platform: linux/amd64
72+
runner: ubuntu-latest
73+
- platform: linux/arm64
74+
runner: ubuntu-24.04-arm
75+
76+
steps:
77+
- uses: actions/checkout@v4
78+
79+
- name: Log in to GHCR
80+
uses: docker/login-action@v3
81+
with:
82+
registry: ${{ env.REGISTRY }}
83+
username: ${{ github.actor }}
84+
password: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Set up Docker Buildx
87+
uses: docker/setup-buildx-action@v3
88+
89+
- name: Build and push by digest
90+
id: build
91+
uses: docker/build-push-action@v5
92+
with:
93+
context: .
94+
file: deploy/rook.Dockerfile
95+
platforms: ${{ matrix.platform }}
96+
outputs: type=image,name=${{ env.ROOK_IMAGE }},push-by-digest=true,name-canonical=true,push=true
97+
98+
- name: Export digest
99+
run: |
100+
mkdir -p /tmp/rook-digests
101+
digest="${{ steps.build.outputs.digest }}"
102+
touch "/tmp/rook-digests/${digest#sha256:}"
103+
104+
- name: Upload digest
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: rook-digest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
108+
path: /tmp/rook-digests/*
109+
if-no-files-found: error
110+
retention-days: 1
111+
112+
merge-rook:
113+
name: Merge and push rook manifest
114+
needs: build-rook
115+
runs-on: ubuntu-latest
116+
permissions:
117+
contents: write
118+
packages: write
119+
120+
steps:
121+
- uses: actions/checkout@v4
122+
with:
123+
fetch-depth: 0
124+
125+
- name: Download digests
126+
uses: actions/download-artifact@v4
127+
with:
128+
path: /tmp/rook-digests
129+
pattern: rook-digest-*
130+
merge-multiple: true
131+
132+
- name: Log in to GHCR
133+
uses: docker/login-action@v3
134+
with:
135+
registry: ${{ env.REGISTRY }}
136+
username: ${{ github.actor }}
137+
password: ${{ secrets.GITHUB_TOKEN }}
138+
139+
- name: Set up Docker Buildx
140+
uses: docker/setup-buildx-action@v3
141+
142+
- name: Compute tags
143+
id: meta
144+
uses: docker/metadata-action@v5
145+
with:
146+
images: ${{ env.ROOK_IMAGE }}
147+
tags: |
148+
type=sha,prefix=,format=short,enable=${{ github.ref_type == 'branch' }}
149+
type=raw,value=nightly,enable=${{ github.ref_type == 'branch' }}
150+
type=semver,pattern={{version}}
151+
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
152+
153+
- name: Create and push manifest
154+
working-directory: /tmp/rook-digests
155+
run: |
156+
docker buildx imagetools create \
157+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
158+
$(printf '${{ env.ROOK_IMAGE }}@sha256:%s ' *)
159+
62160
merge:
63161
name: Merge and push manifest
64162
needs: build

Cargo.lock

Lines changed: 60 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ members = [
2121
"crates/secrets_memory",
2222
"crates/secrets_gcp",
2323
"crates/secrets_k8s",
24+
"crates/rook_proto",
25+
"crates/rook",
2426
]
2527
resolver = "3"
2628

@@ -46,11 +48,13 @@ sandcastle-sandbox-provider-local = { path = "crates/sandbox_provider_local" }
4648
sandcastle-sandbox-provider-docker = { path = "crates/sandbox_provider_docker" }
4749
sandcastle-sandbox-provider-daytona = { path = "crates/sandbox_provider_daytona" }
4850
sandcastle-sandbox-provider-k8s = { path = "crates/sandbox_provider_k8s" }
51+
sandcastle-rook-proto = { path = "crates/rook_proto" }
4952

5053
# External dependencies
5154
anyhow = "1"
5255
async-trait = "0.1"
53-
axum = "0.8"
56+
axum = { version = "0.8", features = ["ws"] }
57+
tokio-tungstenite = { version = "0.26", features = ["native-tls"] }
5458
base64 = "0.22"
5559
bollard = "0.18"
5660
daytona-client = "0.5.0"

crates/rook/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "rook"
3+
version = "0.1.0"
4+
edition = "2024"
5+
license = "MIT"
6+
7+
[[bin]]
8+
name = "rook"
9+
path = "src/main.rs"
10+
11+
[dependencies]
12+
sandcastle-rook-proto = { workspace = true }
13+
futures-util = { workspace = true }
14+
serde_json = { workspace = true }
15+
tokio = { workspace = true }
16+
tokio-tungstenite = { workspace = true }
17+
tracing = { workspace = true }
18+
tracing-subscriber = { workspace = true }

0 commit comments

Comments
 (0)