Skip to content

Latest commit

 

History

History
110 lines (79 loc) · 4.46 KB

README.md

File metadata and controls

110 lines (79 loc) · 4.46 KB

redbean-container  redbean in a container

This project uses Docker Bake.

How to build

Prerequisites:

  • Recent version of Docker installed
  • Docker BuildKit installed (this can be a plugin on your system)

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

The result

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.

How to use

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/

Customize the build

You can override variable defaults set in the Bake file using environment variables.

Different modes

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.

Previous versions

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.

Motivation

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 mean time really cool features were added to the source of redbean.
But to use these features, redbean must be build 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.

Acknowledgements

jart, The creator of the Cosmopolitan project which includes the redbean source code.
redbean-docker, The repository that containerize pre-build redbean binaries.

License

See LICENSE

Licenses of included or used software

See https://redbean.dev/#legal
See Cosmopolitan/LICENSE

Please adhere to the licenses of the other included or used software.