This project uses Docker Bake.
Prerequisites:
Docker Bake can use a remote Bake file definition to locally build an image.
Build an image with the following command:
docker buildx bake https://github.com/w13b3/redbean-container.git
Once the build is completed, the tag redbean:optlinux
is given to the image.
The scratch based image contains the redbean binary, build with the optlinux
mode, using the latest commit to Cosmopolitan default branch.
Start the image with the following command:
docker run -it -p 9090:8080 redbean:optlinux
The redbean process in the container is now serving the default website.
Using a browser the website can be visited at http://127.0.0.1:9090/
You can override variable defaults set in the Bake file using environment variables.
Cosmopolitan provides a variety of build modes which result in different binaries.
This project uses optlinux
as the default mode to build the redbean binary.
There are other modes, including but not limited to: tinylinux
, asan
or rel
.
The following example sets the MODE
variable to opt
, overriding the default MODE
variable.
MODE=opt docker buildx bake https://github.com/w13b3/redbean-container.git
Using MODE=opt
an image with the tag redbean:opt
is created after a successful build.
It is possible to build an image that includes a previous version of redbean.
To do this, a full SHA of the Cosmopolitan commit is needed.
The following command overrides the REPO_SHA
variable with a full SHA to build an image containing redbean v2.0.1.
REPO_SHA="42b34c26f8099658386fc867c49b0b8e59993415" docker buildx bake https://github.com/w13b3/redbean-container.git
When the build is successful an image with the tag redbean:optlinux-42b34c
is available.
The Cosmopolitan repository offers other tools that can be built.
Using this project, another binary can be built by setting the TARGET_PATH
variable.
TARGET_PATH=/tool/hello/hello docker buildx bake https://github.com/w13b3/redbean-container.git
With a successful build the image with the tag hello:optlinux
is created.
The filename of the path given to TARGET_PATH
becomes the name of the image.
Build other tools by setting the TARGET_PATH
paths with:
tl;dr: To learn how to containerize software
Cosmopolitan is an awesome project and redbean is a very capable web server.
While writing this, the latest version of redbean (v2.2) was released on 02-Nov-2022.
In the meantime really cool features were added to the source of redbean.
But to use these features, redbean must be built from source.
Instead of using containerized software I wanted to learn how to containerize software.
I wanted to know the best practices regarding containerization and apply them.
I wanted to distribute images.
And I also wanted to use the newest available features in redbean.
So I decided to combine the learning goals into this project.
jart, The creator of the Cosmopolitan project which includes the redbean source code.
redbean-docker, The repository that containerize pre-build redbean binaries.
See LICENSE
See https://redbean.dev/#legal
See Cosmopolitan/LICENSE
Please adhere to the licenses of the other included or used software.