Skip to content
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
21 changes: 21 additions & 0 deletions netutils/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM alpine:latest
WORKDIR /

RUN set -xe; \
apk update; \
apk add --no-cache \
socat \
dropbear \
tcpdump \
iputils \
traceroute \
bind-tools \
socat

RUN echo "root:unikraft" | chpasswd

COPY ./motd /etc/motd
COPY ./profile /etc/profile

RUN mkdir -p /opt/unikraft
COPY ./dropbeard.sh /opt/unikraft/dropbeard.sh
12 changes: 12 additions & 0 deletions netutils/Kraftfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
spec: v0.6

runtime: base-compat:latest

labels:
cloud.unikraft.v1.instances/scale_to_zero.policy: "off"
cloud.unikraft.v1.instances/scale_to_zero.stateful: "false"
cloud.unikraft.v1.instances/scale_to_zero.cooldown_time_ms: 1000

rootfs: ./Dockerfile

cmd: ["/opt/unikraft/dropbeard.sh"]
37 changes: 37 additions & 0 deletions netutils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Netutils Example image

This image contains a minimal user space environment based on Alpine Linux.
A SSH server is launched and a couple of essential networking tools such as
`nslookup`, `ping`, `traceroute`, `ip`, `socat`, and `tcpdump` are preloaded.

To run this example on Unikraft Cloud, first [install the `kraft` CLI tool](https://unikraft.org/docs/cli).
Then clone this examples repository and `cd` into this directory, and invoke:

```console
kraft cloud deploy
```

Alternatively, you can deploy the image accepting your public key by handing it over the `PUBKEY`
environment variable, for example:

```console
kraft cloud deploy -e PUBKEY="$( cat $HOME/.ssh/id_rsa.pub )"
```

After deploying, you can connect to the console via SSH through a tunnel.
Run the command below:

```console
kraft cloud tunnel 2222:<instance-name>:22
```

Then connect to the instance via SSH using (default password is `unikraft`):

```console
ssh root@localhost -p 2222
```

## Learn more

- [Unikraft Cloud's Documentation](https://unikraft.cloud/docs/)
- [Building `Dockerfile` Images with `Buildkit`](https://unikraft.org/guides/building-dockerfile-images-with-buildkit)
18 changes: 18 additions & 0 deletions netutils/dropbeard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh -e
export HOME=/root

mkdir -p "${HOME}"
chmod 700 "${HOME}"
cd "${HOME}"

# Install public key if given by user
if test -n "${PUBKEY}"; then
mkdir -p "${HOME}/.ssh"
chmod 700 "${HOME}/.ssh"
echo "${PUBKEY}" >> "${HOME}/.ssh/authorized_keys"
chmod 600 "${HOME}/.ssh/authorized_keys"
unset PUBKEY
fi

# Launch dropbear SSH server
exec /usr/sbin/dropbear -ERF
20 changes: 20 additions & 0 deletions netutils/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
_ :=:
| |:=:
| |__:=: UNIKRAFT
\_____/ CLOUD

Welcome to Unikraft Cloud!

This is the netutils example image, its user space
is built on Alpine Linux: <https://wiki.alpinelinux.org/>.
For details about this image, visit:
<https://github.com/unikraft-cloud/examples/netutils>.

This image comes preloaded with essential networking
tools such as nslookup, ping, traceroute, ip, socat,
and tcpdump. Need more? Just install additional
packages using apk. But keep an eye on your free
RAM.

Enjoy!

1 change: 1 addition & 0 deletions netutils/profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PS1='# '
Loading