Skip to content

Commit

Permalink
fix(Makefile): Correct verbosity
Browse files Browse the repository at this point in the history
The PR #1630 accidentally overwrote the changes from #1646.

This commit reverts this mistake.

Signed-off-by: Alexander Jung <[email protected]>
  • Loading branch information
nderjung committed May 13, 2024
1 parent 675ba4c commit 26b457c
Show file tree
Hide file tree
Showing 91 changed files with 48,616 additions and 48,120 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ tools/protoc-gen-go-netconn/protoc-gen-go-netconn
# Go workspace
go.work
go.work.sum

_*
*.mdx
*.patch
*.txt
2 changes: 1 addition & 1 deletion .goreleaser-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ builds:
- #@ arch
ldflags:
- -s -w
- -X {{ .Env.GOMOD }}/internal/version.version={{ .Version }}
- -X {{ .Env.GOMOD }}/internal/version.version=v{{ .Version }}
- -X {{ .Env.GOMOD }}/internal/version.commit={{ .Commit }}
- -X {{ .Env.GOMOD }}/internal/version.buildTime={{ .Date }}
tags:
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ builds:
- #@ arch
ldflags:
- -s -w
- -X {{ .Env.GOMOD }}/internal/version.version={{ .Version }}
- -X {{ .Env.GOMOD }}/internal/version.version=v{{ .Version }}
- -X {{ .Env.GOMOD }}/internal/version.commit={{ .Commit }}
- -X {{ .Env.GOMOD }}/internal/version.buildTime={{ .Date }}
tags:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ $(addprefix $(.PROXY), $(BIN)):
GOOS=$(GOOS) \
GOARCH=$(GOARCH) \
$(GO) build \
-v \
-tags "containers_image_storage_stub,containers_image_openpgp" \
-buildmode=pie \
-gcflags=all='$(GO_GCFLAGS)' \
Expand Down
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ There are many benefits in running your application as a unikernel: for more inf

## Features

- 🔥 Native [Firecracker MicroVM](https://firecracker-microvm.github.io/) support;
- 🔥 Native QEMU & [Firecracker](https://firecracker-microvm.github.io/) microVM support;
- 📚 Pre-built unikernel app catalog;
- 🤹‍♀️ Daemonless unikernel VM instance manager;
- 📦 OCI packaging and distribution support;
- 🚜 ELF binary / POSIX-compatibility support;
- 🚜 Fully Linux & POSIX-compatible;
- 🧰 Go SDK for building unikernels programmatically; and
- 🚀 _much more!_

Expand Down Expand Up @@ -57,19 +57,44 @@ docker run -it --rm -v $(pwd):/workspace --entrypoint bash kraftkit.sh/base:late
```

The above command will drop you into a container shell.
Simply type `exit` or Ctrl+D to quit.
Type `exit` or <kbd>Ctrl</kbd>+<kbd>D</kbd> to quit.


## Quickstart

### Test your installation

Running unikernels with `kraft` is designed to be simple and familiar.
To test your installation of `kraft`, you can run the following:

```
kraft run unikraft.org/helloworld:latest
```

Building unikernels is also designed to be simple.
### Build your first unikernel

Building unikernels is also designed to be simple. Build your first unikernel
by simply placing a `Kraftfile` into your repo and pointing it to your existing
`Dockerfile`:

```yaml
spec: v0.6

runtime: base:latest

rootfs: ./Dockerfile

cmd: ["/path/to/my-server-app"]
```
Once done, invoke:
```
kraft run .
```

### Examples and pre-built images

You can find some common project examples below:

| | Example |
Expand Down
26 changes: 13 additions & 13 deletions api/machine/v1alpha1/machine.zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ type MachinePort struct {

// Number of port to expose on the host. If specified, this must be a valid
// port number, 0 < x < 65536.
HostPort int32 `json:"hostPort,omitempty"`
HostPort int32 `json:"host_port,omitempty"`

// Number of port to expose on the machine's IP address. This must be a valid
// port number, 0 < x < 65536.
MachinePort int32 `json:"machinePort"`
MachinePort int32 `json:"machine_port"`

// Protocol for port. Must be UDP or TCP. Defaults to "TCP".
Protocol corev1.Protocol `json:"protocol,omitempty"`

// What host IP to bind the external port to.
HostIP string `json:"hostIP,omitempty"`
HostIP string `json:"host_ip,omitempty"`

// MAC address of the port.
MacAddress string `json:"macAddress,omitempty"`
MacAddress string `json:"mac_address,omitempty"`
}

// MachinePorts is a slice of MachinePort
Expand Down Expand Up @@ -69,7 +69,7 @@ type MachineSpec struct {

// Kernel arguments are runtime arguments which are provided directly to the
// kernel and not for the application.
KernelArgs []string `json:"kernelArgs,omitempty"`
KernelArgs []string `json:"kernel_args,omitempty"`

// Application arguments are runtime arguments provided to the application and
// not the kernel.
Expand Down Expand Up @@ -124,29 +124,29 @@ type MachineStatus struct {
Pid int32 `json:"pid,omitempty"`

// The fully-qualified path to the kernel image of the machine instance.
KernelPath string `json:"kernelPath,omitempty"`
KernelPath string `json:"kernel_path,omitempty"`

// The fully-qualified path to the initramfs file of the machine instance.
InitrdPath string `json:"initrdPath,omitempty"`
InitrdPath string `json:"initrd_path,omitempty"`

// ExitCode is the ...
ExitCode int `json:"exitCode,omitempty"`
ExitCode int `json:"exit_code,omitempty"`

// StartedAt represents when the machine was started.
StartedAt time.Time `json:"startedAt,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"`

// ExitedAt represents when the machine fully shutdown
ExitedAt time.Time `json:"exitedAt,omitempty"`
ExitedAt time.Time `json:"exited_at,omitempty"`

// StateDir contains the path of the state of the machine.
StateDir string `json:"stateDir,omitempty"`
StateDir string `json:"state_dir,omitempty"`

// LogFile is the in-host path to the log file of the machine.
LogFile string `json:"logFile,omitempty"`
LogFile string `json:"log_file,omitempty"`

// PlatformConfig is platform-specific attributes which are populated by the
// underlying machine service implementation.
PlatformConfig interface{} `json:"platformConfig,omitempty"`
PlatformConfig interface{} `json:"platform_config,omitempty"`
}

// MachineService is the interface of available methods which can be performed
Expand Down
5 changes: 5 additions & 0 deletions buildenvs/myself.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ RUN set -xe; \
mv cosign-linux-amd64 /usr/local/bin/cosign; \
chmod +x /usr/local/bin/cosign;

# Install buf
RUN set -xe; \
curl -s -L https://github.com/bufbuild/buf/releases/download/v1.20.0/buf-Linux-x86_64 > /usr/local/bin/buf; \
chmod +x /usr/local/bin/buf

WORKDIR /go/src/kraftkit.sh

COPY --from=ghcr.io/goreleaser/goreleaser-cross:v1.22.0 /usr/bin/goreleaser /usr/bin/
Expand Down
37 changes: 18 additions & 19 deletions buildenvs/qemu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Licensed under the BSD-3-Clause License (the "License").
# You may not use this file except in compliance with the License.

ARG DEBIAN_VERSION=bookworm-20230725
ARG ALPINE_VERSION=3.19.0

FROM debian:${DEBIAN_VERSION} AS qemu-build
FROM alpine:${ALPINE_VERSION} AS qemu-build

ARG QEMU_VERSION=8.2.0
ARG WITH_XEN=disable
Expand All @@ -21,35 +21,34 @@ WORKDIR /out

# Install dependencies
RUN set -ex; \
apt-get -y update; \
apt-get install -y \
apk --no-cache add \
alpine-sdk \
attr-dev \
bash \
bison \
build-essential \
curl \
flex \
libaio-dev \
libattr1-dev \
libattr \
libcap-dev \
libcap-ng \
libcap-ng-dev \
libglib2.0-dev \
liblzo2-dev \
libcap-ng-static \
libcap-ng-utils \
libslirp-dev \
libslirp0 \
ninja-build \
pkg-config \
python3 \
python3-pip \
lzo-dev \
musl-dev \
ninja-is-really-ninja \
pixman-dev \
texinfo \
vde2 \
xz-utils \
zlib1g-dev; \
apt-get clean;
vde2-dev \
xz-dev \
zlib-dev;

# Download and extract QEMU
RUN set -ex; \
curl -O https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz; \
tar xf qemu-${QEMU_VERSION}.tar.xz; \
apt-get install -y;
tar xf qemu-${QEMU_VERSION}.tar.xz;

# Configure and build QEMU
RUN set -ex; \
Expand Down
15 changes: 15 additions & 0 deletions cmdfactory/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,18 @@ func MaxDirArgs(n int) cobra.PositionalArgs {
return nil
}
}

// func ExactDirArgs(n int) cobra.PositionalArgs {
// return func(_ *cobra.Command, args []string) error {
// if len(args) != n {
// return FlagErrorf("expected no more than %d paths received %d", n, len(args))
// }

// f, err := os.Stat(args[0])
// if err != nil || !f.IsDir() {
// return FlagErrorf("path is not a valid directory: %s", args[0])
// }

// return nil
// }
// }
5 changes: 5 additions & 0 deletions cmdfactory/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ import (
var (
caseRegexp = regexp.MustCompile("([a-z])([A-Z])")
flagOverrides = make(map[string][]*pflag.Flag)
aliases = make(map[string]string)
)

func RegisterFlag(cmdline string, flag *pflag.Flag) {
flagOverrides[cmdline] = append(flagOverrides[cmdline], flag)
}

func RegisterAlias(cmdline, alias string) {
aliases[alias] = cmdline
}

type PersistentPreRunnable interface {
PersistentPre(cmd *cobra.Command, args []string) error
}
Expand Down
11 changes: 9 additions & 2 deletions cmdfactory/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ import (
"kraftkit.sh/internal/text"
)

// AnnotationHelpGroup is used to indicate in which help group a command belongs.
const (
AnnotationHelpGroup = "help:group"
// AnnotationHelpGroup is used to indicate in which help group a command
// belongs.
AnnotationHelpGroup = "help:group"

// AnnotationHelpHidden is used to indicate that a command should be hidden
// from the main menu. This annotation is used instead of cobra's default
// Hidden attribute since this utility file is used to print the help menu.
// Cobra uses the Hidden attribute internally to determine if a command
// should be available in the completions command.
AnnotationHelpHidden = "help:hidden"
)

Expand Down
8 changes: 6 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ type KraftKit struct {
NoWarnSudo bool `yaml:"no_warn_sudo" env:"KRAFTKIT_NO_WARN_SUDO" long:"no-warn-sudo" usage:"Do not warn on running via sudo" default:"false"`
Editor string `yaml:"editor" env:"KRAFTKIT_EDITOR" long:"editor" usage:"Set the text editor to open when prompt to edit a file"`
GitProtocol string `yaml:"git_protocol" env:"KRAFTKIT_GIT_PROTOCOL" long:"git-protocol" usage:"Preferred Git protocol to use" default:"https"`
Pager string `yaml:"pager,omitempty" env:"KRAFTKIT_PAGER" long:"pager" usage:"System pager to pipe output to" default:"cat"`
Pager string `yaml:"pager,omitempty" env:"KRAFTKIT_PAGER" long:"pager" usage:"System pager to pipe output to" default:""`
Qemu string `yaml:"qemu,omitempty" env:"KRAFTKIT_QEMU" long:"qemu" usage:"Path to QEMU executable" default:""`
HTTPUnixSocket string `yaml:"http_unix_socket,omitempty" env:"KRAFTKIT_HTTP_UNIX_SOCKET" long:"http-unix-sock" usage:"When making HTTP(S) connections, pipe requests via this shared socket"`
RuntimeDir string `yaml:"runtime_dir" env:"KRAFTKIT_RUNTIME_DIR" long:"runtime-dir" usage:"Directory for placing runtime files (e.g. pidfiles)"`
DefaultPlat string `yaml:"default_plat" env:"KRAFTKIT_DEFAULT_PLAT" usage:"The default platform to use when invoking platform-specific code" noattribute:"true"`
DefaultArch string `yaml:"default_arch" env:"KRAFTKIT_DEFAULT_ARCH" usage:"The default architecture to use when invoking architecture-specific code" noattribute:"true"`
ContainerdAddr string `yaml:"containerd_addr,omitempty" env:"KRAFTKIT_CONTAINERD_ADDR" long:"containerd-addr" usage:"Address of containerd daemon socket" default:""`
EventsPidFile string `yaml:"events_pidfile" env:"KRAFTKIT_EVENTS_PIDFILE" long:"events-pid-file" usage:"Events process ID used when running multiple unikernels"`
BuildKitHost string `yaml:"buildkit_host" env:"KRAFTKIT_BUILDKIT_HOST" long:"buildkit-host" usage:"Path to the buildkit host" default:""`

BuildKitHost string `yaml:"buildkit_host" env:"KRAFTKIT_BUILDKIT_HOST" long:"buildkit-host" usage:"Path to the buildkit host" default:""`
BuildKitTLSCACert string `yaml:"buildkit_tls_cacert" env:"KRAFTKIT_BUILDKIT_TLS_CA_CERT" long:"buildkit-tls-cacert" usage:""`
BuildKitTLSCert string `yaml:"buildkit_tls_cert" env:"KRAFTKIT_BUILDKIT_TLS_CERT" long:"buildkit-tls-cert" usage:""`
BuildKitTLSKey string `yaml:"buildkit_tls_key" env:"KRAFTKIT_BUILDKIT_TLS_KEY" long:"buildkit-tls-key" usage:""`

Paths struct {
Plugins string `yaml:"plugins,omitempty" env:"KRAFTKIT_PATHS_PLUGINS" long:"plugins-dir" usage:"Path to KraftKit plugin directory"`
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewDefaultKraftKitConfig() (*KraftKit, error) {

// ..for runtime files..
if len(c.RuntimeDir) == 0 {
c.RuntimeDir = filepath.Join(DataDir(), "runtime")
c.RuntimeDir = StateDir()
}

// ..for events files..
Expand Down
8 changes: 8 additions & 0 deletions exec/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ExecOptions struct {
env []string
callbacks []func(int)
detach bool
workdir string
}

type ExecOption func(eo *ExecOptions) error
Expand Down Expand Up @@ -118,3 +119,10 @@ func WithDetach(detach bool) ExecOption {
return nil
}
}

func WithWorkdir(workdir string) ExecOption {
return func(eo *ExecOptions) error {
eo.workdir = workdir
return nil
}
}
4 changes: 4 additions & 0 deletions exec/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func (e *Process) Start(ctx context.Context) error {
e.executable.Args()...,
)

if len(e.opts.workdir) > 0 {
e.cmd.Dir = e.opts.workdir
}

// Set the stdout
if e.opts.stdout != nil && len(e.opts.stdoutcbs) == 0 {
e.cmd.Stdout = e.opts.stdout
Expand Down
Loading

0 comments on commit 26b457c

Please sign in to comment.