Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
nderjung committed Nov 17, 2023
1 parent da99861 commit 8dd02a3
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 336 deletions.
3 changes: 0 additions & 3 deletions library/caddy/2.7/.gitignore

This file was deleted.

File renamed without changes.
34 changes: 20 additions & 14 deletions library/caddy/2.7/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
FROM --platform=linux/x86_64 golang:1.21.4-bookworm AS build

# Inspired from: https://github.com/caddyserver/caddy-docker/blob/master/2.7/builder/Dockerfile
FROM golang:1.21.4-bookworm AS build

RUN set -xe; \
apt-get update ; \
apt-get install -y --no-install-recommends \
ca-certificates \
git \
libcap2-bin \
;

RUN set -xe; apt-get update ; \
apt-get install -y --no-install-recommends \
ca-certificates \
git \
libcap2-bin \
;
ENV XCADDY_VERSION 0.3.5

ENV XCADDY_VERSION v0.3.5
# Configures xcaddy to build with this version of Caddy
ENV CADDY_VERSION v2.7.5

# Configures xcaddy to not clean up post-build (unnecessary in a container)
ENV XCADDY_SKIP_CLEANUP 1

# Sets capabilities for output caddy binary to be able to bind to privileged ports
ENV XCADDY_SETCAP 1

RUN set -xe; \
wget -O /tmp/xcaddy.tar.gz "https://github.com/caddyserver/xcaddy/releases/download/v0.3.5/xcaddy_0.3.5_linux_amd64.tar.gz"; \
tar x -z -f /tmp/xcaddy.tar.gz -C /usr/bin xcaddy; \
rm -f /tmp/xcaddy.tar.gz; \
chmod +x /usr/bin/xcaddy;
wget -O /tmp/xcaddy.tar.gz "https://github.com/caddyserver/xcaddy/releases/download/v${XCADDY_VERSION}/xcaddy_${XCADDY_VERSION}_linux_amd64.tar.gz"; \
tar x -z -f /tmp/xcaddy.tar.gz -C /usr/bin xcaddy; \
rm -f /tmp/xcaddy.tar.gz; \
chmod +x /usr/bin/xcaddy;

RUN --mount=type=tmpfs,target=/etc set -xe; \
echo "127.0.0.1 localhost" > /etc/hosts

ENV CGO_ENABLED=1
ENV XCADDY_GO_BUILD_FLAGS "-buildmode=pie -ldflags '-linkmode external -extldflags -static-pie'"
Expand All @@ -31,4 +37,4 @@ RUN /usr/bin/xcaddy build
FROM scratch

COPY --from=build /go/caddy /usr/local/bin/caddy
COPY data/Caddyfile /data/Caddyfile
COPY ./Caddyfile /etc/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
spec: v0.6

name: caddy

template:
source: https://github.com/unikraft/app-elfloader.git
version: stable

rootfs: ./Dockerfile

unikraft:
source: https://github.com/unikraft/unikraft
version: testing
Expand Down Expand Up @@ -38,6 +42,7 @@ unikraft:
CONFIG_LIBSYSCALL_SHIM_HANDLER: 'y'
CONFIG_LIBSYSCALL_SHIM_LEGACY_VERBOSE: 'y'
CONFIG_LIBSYSCALL_SHIM: 'y'
CONFIG_LIBUK9P: 'y'
CONFIG_LIBUKALLOCPOOL: 'y'
CONFIG_LIBUKBLKDEV_SYNC_IO_BLOCKED_WAITING: 'y'
CONFIG_LIBUKBLKDEV: 'y'
Expand All @@ -57,7 +62,6 @@ unikraft:
CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS: 'y'
CONFIG_LIBVFSCORE_FSTAB: 'y'
CONFIG_LIBVFSCORE_ROOTFS_EINITRD: 'y'
CONFIG_LIBVFSCORE_ROOTFS_EINITRD_PATH: "__EINITRD_PATH__"
CONFIG_OPTIMIZE_DEADELIM: 'y'
CONFIG_OPTIMIZE_LTO: 'y'
CONFIG_PAGING: 'y'
Expand All @@ -71,3 +75,4 @@ libraries:
targets:
- fc/x86_64
- qemu/x86_64
- qemu/arm64
37 changes: 0 additions & 37 deletions library/caddy/2.7/Makefile

This file was deleted.

50 changes: 13 additions & 37 deletions library/caddy/2.7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,40 @@

This directory contains the definition for building the `unikraft.org/caddy:2.7` image.

## Build

To build this image, first create the root filesystem and the `Kraftfile` from `Kraftfile.template`:
To run this image, [install Unikraft's companion command-line toolchain `kraft`](https://unikraft.org/docs/cli) and then you can run:

```console
make initrd
kraft run -p 2015:2015 unikraft.org/caddy:2.7
```

Then build the images:
To customize the `Caddyfile`, simply provide an alternative path to `/etc/caddy`:

```console
kraft build --no-cache --arch x86_64 --plat fc
kraft build --no-cache --arch x86_64 --plat qemu
kraft run -p 2015:2015 -v $(pwd):/etc/caddy unikraft.org/caddy:2.7
```

## Package
Once executed, it will open port `2015` and wait for connections, and can be queried on:

```console
kraft pkg --name index.unikraft.io/unikraft.org/caddy:2.7 --strategy overwrite --push
curl http://localhost:2015
```

## Run

To run this image, [install Unikraft's companion command-line toolchain `kraft`](https://unikraft.org/docs/cli) and then you can run, for QEMU:

```console
sudo kraft net create -n 172.44.0.1/24 virbr0
sudo kraft run \
-W \
--memory 256M \
--log-level debug --log-type basic \
--network bridge:virbr0 \
--arch x86_64 --plat qemu \
.unikraft/build/2.7_qemu-x86_64 \
-a netdev.ipv4_addr=172.44.0.2 -a netdev.ipv4_gw_addr=172.44.0.1 -a netdev.ipv4_subnet_mask=255.255.255.0 \
-- $cmd
```
## Building and packaging locally

For Firecracker (RD: this doesn't work for me):
To build this image locally:

```
sudo kraft net create -n 172.44.0.1/24 virbr0
sudo kraft run \
--memory 256M \
--log-level debug --log-type basic \
--network bridge:virbr0 \
--arch x86_64 --plat fc \
.unikraft/build/2.7_fc-x86_64 \
-a netdev.ipv4_addr=172.44.0.2 -a netdev.ipv4_gw_addr=172.44.0.1 -a netdev.ipv4_subnet_mask=255.255.255.0 \
-- $cmd
```console
kraft build --no-cache
```

Once executed, it will open port `2015` on IP address `172.44.0.2` and wait for connections, and can be queried on:
Then package:

```console
curl 172.44.0.2:2015
kraft pkg --name unikraft.org/caddy:2.7 --strategy overwrite
```


## See also

- [How to run unikernels locally in Unikraft's Documentation](https://unikraft.org/docs/cli/running).
33 changes: 0 additions & 33 deletions library/caddy/2.7/fc-initrd.json

This file was deleted.

32 changes: 0 additions & 32 deletions library/caddy/2.7/fc.json

This file was deleted.

2 changes: 0 additions & 2 deletions library/caddy/2.7/hosts

This file was deleted.

34 changes: 0 additions & 34 deletions library/caddy/2.7/kraft-run-fc.sh

This file was deleted.

35 changes: 0 additions & 35 deletions library/caddy/2.7/kraft-run-qemu.sh

This file was deleted.

40 changes: 0 additions & 40 deletions library/caddy/2.7/run-fc.sh

This file was deleted.

Loading

0 comments on commit 8dd02a3

Please sign in to comment.