展示 HN:一种 Lisp,其中每个函数调用都会运行一个 Docker 容器
Show HN: A Lisp where each function call runs a Docker container

原始链接: https://github.com/a11ce/docker-lisp

## Docker-Lisp 概要 Docker-Lisp 允许你在 Docker 容器内运行 Lisp 代码。过程从使用 `./scripts/build-base` 和 `./scripts/build-builtins` 构建必要的基础镜像和内置函数开始。 然后,你可以使用 `./scripts/run eval "(expression)"` 直接评估 Lisp 表达式,可以选择使用 `--trace` 进行详细的调用跟踪。可以使用 `docker stats` 和 `docker events` 监控容器活动。 对于更复杂的程序,在 Dockerfile 中定义 Lisp 代码,并使用 `./scripts/build [name]` 构建它。使用 `./scripts/run [args]` 运行这些构建的镜像。 关键脚本包括:`build` (Dockerfile 到镜像), `build-base` (基础镜像), `build-builtins`, `run` (执行镜像), `run-tests` (运行测试,必要时重建基础镜像), 和 `clean` (移除容器和镜像)。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN:一种 Lisp,每次函数调用都会运行一个 Docker 容器 (github.com/a11ce) 7 分,a11ce 发表于 1 小时前 | 隐藏 | 过去 | 收藏 | 2 条评论 帮助 piloto_ciego 发表于 7 分钟前 | 下一个 [–] 这是我见过的最荒谬的事情,我喜欢它。回复 teaearlgraycold 发表于 1 小时前 | 上一个 [–] 我印象深刻的是 GitHub 能够处理这个庞然大物:https://github.com/a11ce/docker-lisp/actions/runs/2216831271... 500 多个容器调用来计算阶乘(3) 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

A Docker image is a piece of executable code that produces some output given some input.

Screenshot of a program trace, docker events, and docker stats..

First, build the base images and builtins.

./scripts/build-base
./scripts/build-builtins

Then, run the tests. Be patient.

Run eval to evaluate expressions.

./scripts/run eval "(cons 1 2)"

Pass --trace to run to see all calls.

./scripts/run --trace eval "(car (cdr (cons 1 (cons 2 (list)))))"

You can also use docker stats and docker events to watch evaluation.

You can write programs:

FROM docker-lisp/eval
CMD ["(define fact (lambda (n) (if (number-equals n 0) 1 (multiply n (fact (subtract n 1))))))", "(fact 3)"]

Build them with

./scripts/build <program path> [name]

or

./scripts/build <program path> # Uses the filename if no name is specified

Then run with

Script Purpose
build <file> [name] Build a Dockerfile into docker-lisp/<name>. Defaults to basename.
build-base Build base images (docker-lisp/base-racket, docker-lisp/base-call)
build-builtins Build all builtin images
run [--trace] [--no-cleanup] <image> [args] Run a docker-lisp/<image> container
run-tests [--no-trace] [--rebuild-base] [prefix filter] Run the tests (with traces by default)
clean Kill all docker-lisp/* containers and remove all built docker-lisp/* images
联系我们 contact @ memedata.com