Skip to content

Commit 70b8c9b

Browse files
committed
itworks
0 parents  commit 70b8c9b

8 files changed

Lines changed: 766 additions & 0 deletions

File tree

README.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Sysbox Installer for dstack
2+
3+
A complete Docker-based installer for [Sysbox](https://github.com/nestybox/sysbox) on read-only dstack systems.
4+
5+
## Features
6+
7+
- 🚀 **Single-command installation** - One Docker run command installs everything
8+
- 🔒 **Source-built** - Builds Sysbox from verified Git source (v0.6.7)
9+
-**SHA256 verified** - All downloads verified with checksums
10+
- 🔄 **Smart overlay handling** - Preserves existing /etc configurations
11+
- 📋 **Systemd integration** - Installs proper systemd services for Sysbox daemons
12+
- 🔍 **Installation detection** - Checks for existing installations
13+
- 🧪 **Built-in testing** - Verifies installation with basic and Docker-in-Docker tests
14+
15+
## Quick Start
16+
17+
### Build the Installer
18+
19+
```bash
20+
cd installer
21+
chmod +x build.sh
22+
./build.sh sysbox-installer latest
23+
```
24+
25+
### Install Sysbox
26+
27+
**Single command installation:**
28+
```bash
29+
docker run --rm --privileged --pid=host --net=host -v /:/host \
30+
sysbox-installer:latest
31+
```
32+
33+
That's it! The installer will:
34+
- Check for existing installations
35+
- Build and install Sysbox from source
36+
- Handle /etc overlay mount complexities
37+
- Configure Docker runtime
38+
- Create and start systemd services
39+
- Test the installation
40+
- Show final status
41+
42+
## Manual Steps (if needed)
43+
44+
### Interactive Installation
45+
46+
```bash
47+
docker run -it --rm --privileged --pid=host --net=host -v /:/host \
48+
sysbox-installer:latest bash
49+
```
50+
51+
Then run: `/usr/local/bin/install-sysbox-complete.sh`
52+
53+
### Check Build Information
54+
55+
```bash
56+
docker run --rm sysbox-installer:latest cat /usr/local/share/BUILD_INFO
57+
```
58+
59+
## Usage After Installation
60+
61+
### Run Containers with Sysbox
62+
63+
```bash
64+
# Basic system container
65+
docker run --runtime=sysbox-runc -it ubuntu bash
66+
67+
# Docker-in-Docker
68+
docker run --runtime=sysbox-runc -d --name docker-container docker:dind
69+
70+
# Kubernetes-in-Docker
71+
docker run --runtime=sysbox-runc -d --name k8s-node kindest/node:latest
72+
```
73+
74+
### Manage Sysbox Services
75+
76+
```bash
77+
# Check status
78+
systemctl status sysbox-mgr sysbox-fs
79+
80+
# Restart services
81+
systemctl restart sysbox-mgr sysbox-fs
82+
83+
# View logs
84+
journalctl -u sysbox-mgr -u sysbox-fs
85+
```
86+
87+
## File Structure
88+
89+
```
90+
installer/
91+
├── build.sh # Build script
92+
├── README.md # This file
93+
├── docker/
94+
│ └── Dockerfile # Multi-stage build with source compilation
95+
└── scripts/
96+
├── install-sysbox-complete.sh # Main installation script
97+
├── verify-downloads.sh # SHA256 verification for downloads
98+
├── sysbox-mgr.service # systemd service for sysbox-mgr
99+
└── sysbox-fs.service # systemd service for sysbox-fs
100+
```
101+
102+
## Technical Details
103+
104+
### What the Installer Does
105+
106+
1. **Checks existing installation** - Prompts before overwriting
107+
2. **Copies binaries** - Places Sysbox binaries in `/tmp/` (writable location)
108+
3. **Sets up /etc overlay** - Creates persistent overlay preserving existing configs
109+
4. **Creates symlinks** - Links rsync, modprobe, iptables for Sysbox requirements
110+
5. **Configures Docker** - Adds sysbox-runc runtime to Docker daemon
111+
6. **Creates systemd services** - Installs proper service files with dependencies
112+
7. **Starts services** - Enables and starts Sysbox daemons
113+
8. **Tests installation** - Verifies basic and Docker-in-Docker functionality
114+
115+
### Data Locations
116+
117+
- **Sysbox data**: `/dstack/persistent/sysbox-data`
118+
- **Overlay data**: `/dstack/persistent/sysbox-etc-overlay`
119+
- **Binaries**: `/tmp/sysbox-*` and `/tmp/rsync-static`
120+
121+
### Security
122+
123+
- All downloads verified with SHA256 checksums
124+
- Sysbox built from official Git repository (recursive clone)
125+
- Uses specific version tags (v0.6.7)
126+
- Proper systemd service isolation
127+
128+
## Troubleshooting
129+
130+
### Check Service Status
131+
```bash
132+
systemctl status sysbox-mgr sysbox-fs
133+
journalctl -u sysbox-mgr -u sysbox-fs
134+
```
135+
136+
### Verify Docker Runtime
137+
```bash
138+
docker info | grep -A5 Runtimes
139+
```
140+
141+
### Test Basic Functionality
142+
```bash
143+
docker run --runtime=sysbox-runc --rm alpine echo "Test successful"
144+
```
145+
146+
### Clean Installation
147+
```bash
148+
systemctl stop sysbox-mgr sysbox-fs
149+
systemctl disable sysbox-mgr sysbox-fs
150+
rm -f /etc/systemd/system/sysbox-*.service
151+
umount /etc # If overlay mounted
152+
rm -rf /dstack/persistent/sysbox-*
153+
```
154+
155+
## Requirements
156+
157+
- Docker installed and running
158+
- Privileged container execution
159+
- dstack system with ZFS persistent storage
160+
- systemd for service management
161+
162+
## Support
163+
164+
For issues with the installer, check:
165+
1. Docker daemon is running
166+
2. Container has privileged access
167+
3. `/dstack/persistent/` is available and writable
168+
4. systemd is available on the host
169+
170+
For Sysbox issues, see: https://github.com/nestybox/sysbox

build.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
IMAGE_NAME="${1:-kvin/dstack-sysbox-installer}"
6+
IMAGE_TAG="${2:-latest}"
7+
8+
echo "=========================================="
9+
echo "🔨 Building Sysbox Installer"
10+
echo "=========================================="
11+
12+
# Change to installer directory
13+
cd "$(dirname "$0")"
14+
15+
echo "📁 Build context: $(pwd)"
16+
echo "🏷️ Image: ${IMAGE_NAME}:${IMAGE_TAG}"
17+
18+
# Verify required files exist
19+
echo "✅ Checking required files..."
20+
for file in scripts/install-sysbox-complete.sh scripts/verify-downloads.sh scripts/sysbox-mgr.service scripts/sysbox-fs.service docker/Dockerfile; do
21+
if [ ! -f "$file" ]; then
22+
echo "❌ Missing required file: $file"
23+
exit 1
24+
fi
25+
done
26+
27+
# Build the image
28+
echo "🚀 Building Docker image..."
29+
docker build -f docker/Dockerfile -t "${IMAGE_NAME}:${IMAGE_TAG}" .
30+
31+
echo
32+
echo "=========================================="
33+
echo "✅ Build Complete!"
34+
echo "=========================================="
35+
echo
36+
echo "📦 Image: ${IMAGE_NAME}:${IMAGE_TAG}"
37+
echo
38+
echo "🚀 Usage:"
39+
echo
40+
echo "Single-command installation:"
41+
echo " docker run --rm --privileged --pid=host --net=host -v /:/host \\"
42+
echo " ${IMAGE_NAME}:${IMAGE_TAG}"
43+
echo
44+
echo "Interactive installation:"
45+
echo " docker run -it --rm --privileged --pid=host --net=host -v /:/host \\"
46+
echo " ${IMAGE_NAME}:${IMAGE_TAG} bash"
47+
echo
48+
echo "Check build info:"
49+
echo " docker run --rm ${IMAGE_NAME}:${IMAGE_TAG} cat /usr/local/share/BUILD_INFO"
50+
echo

docker/Dockerfile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Multi-stage build for Sysbox installer
2+
# Stage 1: Build dependencies (rsync and Sysbox)
3+
FROM ubuntu:24.04 AS builder
4+
5+
# Install build dependencies
6+
RUN apt-get update && apt-get install -y \
7+
wget \
8+
git \
9+
build-essential \
10+
autoconf \
11+
automake \
12+
libbtrfs-dev \
13+
libseccomp-dev \
14+
libseccomp2 \
15+
pkg-config \
16+
protobuf-compiler \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
# Install Go for Sysbox build
20+
RUN wget -O- https://golang.org/dl/go1.21.5.linux-amd64.tar.gz | tar -C /usr/local -xzf -
21+
ENV PATH="/usr/local/go/bin:${PATH}"
22+
23+
# Install Go protobuf plugins
24+
RUN go install github.com/golang/protobuf/protoc-gen-go@latest
25+
ENV PATH="${PATH}:/root/go/bin"
26+
27+
WORKDIR /build
28+
29+
# Copy verification script
30+
COPY scripts/verify-downloads.sh /usr/local/bin/verify-downloads.sh
31+
RUN chmod +x /usr/local/bin/verify-downloads.sh
32+
33+
# Download and verify rsync
34+
RUN /usr/local/bin/verify-downloads.sh rsync /build && \
35+
cd /build && \
36+
tar xzf rsync-3.2.7.tar.gz && \
37+
cd rsync-3.2.7 && \
38+
CFLAGS="-static" ./configure \
39+
--disable-openssl \
40+
--disable-xxhash \
41+
--disable-zstd \
42+
--disable-lz4 && \
43+
make LDFLAGS="-static" -j$(nproc) && \
44+
strip rsync
45+
46+
# Clone and build Sysbox from source
47+
RUN /usr/local/bin/verify-downloads.sh sysbox /build && \
48+
cd /build/sysbox && \
49+
make sysbox-static-local && \
50+
make install DESTDIR=/build/sysbox-install
51+
52+
# Stage 2: Final runtime image
53+
FROM alpine:latest
54+
55+
# Install runtime dependencies
56+
RUN apk add --no-cache \
57+
bash \
58+
docker \
59+
iptables \
60+
util-linux \
61+
coreutils \
62+
findutils
63+
64+
# Copy built binaries from builder stage
65+
COPY --from=builder /build/rsync-3.2.7/rsync /usr/local/bin/rsync
66+
COPY --from=builder /build/sysbox-install/sysbox-runc /usr/local/bin/sysbox-runc
67+
COPY --from=builder /build/sysbox-install/sysbox-mgr /usr/local/bin/sysbox-mgr
68+
COPY --from=builder /build/sysbox-install/sysbox-fs /usr/local/bin/sysbox-fs
69+
70+
# Copy scripts and service files
71+
COPY scripts/install-sysbox-complete.sh /usr/local/bin/install-sysbox-complete.sh
72+
COPY scripts/verify-downloads.sh /usr/local/bin/verify-downloads.sh
73+
COPY scripts/sysbox-etc-overlay.service /usr/local/share/sysbox-etc-overlay.service
74+
COPY scripts/sysbox-mgr.service /usr/local/share/sysbox-mgr.service
75+
COPY scripts/sysbox-fs.service /usr/local/share/sysbox-fs.service
76+
77+
# Make everything executable
78+
RUN chmod +x /usr/local/bin/*
79+
80+
# Create build info
81+
RUN echo "Sysbox Installer Image" > /usr/local/share/BUILD_INFO && \
82+
echo "Built: $(date)" >> /usr/local/share/BUILD_INFO && \
83+
echo "Sysbox: $(/usr/local/bin/sysbox-mgr --version | head -1)" >> /usr/local/share/BUILD_INFO && \
84+
echo "rsync: $(/usr/local/bin/rsync --version | head -1)" >> /usr/local/share/BUILD_INFO
85+
86+
WORKDIR /workspace
87+
88+
# Default command runs the complete installer
89+
CMD ["/usr/local/bin/install-sysbox-complete.sh"]

0 commit comments

Comments
 (0)