Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Update docs from github.com/stealthrocket/timecraft@76eba4c35a5b38e60…
Browse files Browse the repository at this point in the history
…3b85e135f5c788851265fcb
  • Loading branch information
stealthrocket-bot committed Jul 26, 2023
1 parent 0139432 commit a765fcf
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ sidebar_position: 1
slug: /
---

# Timecraft Docs
# Timecraft

Timecraft is an application runtime providing a Time Machine and a Task Orchestration capability.
Built on top of Wazero, Timecraft leverage the WebAssembly sandbox.
Timecraft is an application runtime designed to build and run production grade distributed systems.

## Getting Started

Expand All @@ -17,11 +16,12 @@ First step, install and configure Timecraft:

You will then have to compile your application to WebAssembly:

- [Compiling your Go application to WebAssembly](/getting-started/prep-application/compiling-go)
- [Compiling your Python application to WebAssembly](/getting-started/prep-application/compiling-python)
- [Compiling your Go application to WebAssembly](/getting-started/applications/go)
- [Compiling your Python application to WebAssembly](/getting-started/applications/python)


## Community

- [Discord](https://stealthrocket.tech/discord)
- [Twitter](https://twitter.com/_stealthrocket)
- [steathrocket.tech](https://twitter.com/_stealthrocket)
- [steathrocket.tech](https://stealthrocket.tech)
5 changes: 5 additions & 0 deletions docs/getting-started/applications/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
label: "Applications"
position: 1
link:
type: generated-index
title: "Applications"
55 changes: 55 additions & 0 deletions docs/getting-started/applications/go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Go

## Preparing Go

Go 1.21, due to be released in August 2023, will be able to natively compile Go applications to WebAssembly.

```console
$ GOOS=wasip1 GOARCH=wasm go build ...
```

Since Go 1.21 has not been released yet, you can use [`gotip`](https://pkg.go.dev/golang.org/dl/gotip) to test these features before release:

```console
$ go install golang.org/dl/gotip@latest
$ gotip download
```

```console
$ GOOS=wasip1 GOARCH=wasm gotip build ...
```

## Compiling your application

Instead of using `go build`, use:

```console
$ GOOS=wasip1 GOARCH=wasm gotip build -o app.wasm <path/to/main/pkg>
```

This will build a WebAssembly module that can be run with Timecraft.

## Running your application with Timecraft

To run your application:

```console
$ timecraft run app.wasm
```

Command-line arguments can be specified after the WebAssembly module. To prevent
Timecraft from interpreting command-line options for the application, use:

```console
$ timecraft run -- app.wasm arg1 arg2 ...
```

Note that environment variables passed to Timecraft are automatically passed to the
WebAssembly module.

## Networking applications

You may quickly find that the networking capabilities of `GOOS=wasip1` are limited.

We have created a library to help with common use cases, such as creating HTTP servers
and connecting to databases. See https://github.com/stealthrocket/net for usage details.
52 changes: 52 additions & 0 deletions docs/getting-started/applications/python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Python

Python applications aren't compiled to WebAssembly. Rather, a Python interpreter (CPython)
is compiled to WebAssembly and interprets your Python application as it would normally.

Minor patches have been made to both the CPython interpreter and standard library to ensure
that applications are able to create POSIX style sockets. This enables Python applications to
create servers and connect to databases. We intend to upstream our patches at some stage.

## Preparing Python

We provide a pre-compiled Python interpreter and patched standard library. You can download them by running

```
curl -fsSL https://timecraft.s3.amazonaws.com/python/main/python.wasm -o python.wasm
curl -fsSL https://timecraft.s3.amazonaws.com/python/main/python311.zip -o python311.zip
```

To build Python from scratch, see the instructions in the
[`./python`](https://github.com/stealthrocket/timecraft/tree/main/python) dir.

## Running your application with Timecraft

### Preparing dependencies

It's recommended that you install your Python dependencies in a virtualenv:

```console
$ python3 -m venv env
$ source ./env/bin/activate
(env) $ pip install -r /path/to/requirements.txt
```

### Running Timecraft

The Python interpreter needs to know where dependencies are installed
and where the standard library ZIP is located.

Assuming both the interpreter (`python.wasm`) and standard library (`python311.zip`)
are located in the current directory, you can pass this information to the
interpreter like so:

```
$ export PYTHONHOME=env
$ export PYTHONPATH=python311.zip:$PYTHONHOME
```

You can now run your application:

```
$ timecraft run python.wasm main.py
```

0 comments on commit a765fcf

Please sign in to comment.