You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+68-5
Original file line number
Diff line number
Diff line change
@@ -17,8 +17,12 @@ hbox offers the following features:
17
17
-**Support for Pipes**: Supports the use of pipes in `hbox run`, enabling efficient command chaining.
18
18
-**Convenient Shims**: Creates `shims` (alias shortcuts) for all installed packages, simplifying command entry from `hbox run <package alias> <commands>` to `<package alias> <commands>`.
19
19
-**Accessible Internal Binaries**: Provides direct access to internal binaries within images. Users can override the default entrypoint to access essential tools and utilities within containers directly.
20
-
-**Customizable Environment Variables**: Allows setting environment variables for each package, enabling finer control over runtime configurations.]()
20
+
-**Customizable Environment Variables**: Allows setting environment variables for each package, enabling finer control over runtime configurations.
21
21
-**Support for Docker and Podman**: Provides seamless support for both Docker and Podman container engines, offering flexibility in container runtime choices.
22
+
-**Custom Images**:
23
+
-**Building Custom Images**: Allows users to build custom images on demand, either replacing existing packages or introducing new ones. Users can define build contexts, Dockerfiles, and build arguments within the configuration file.
24
+
-**Dynamic Build Arguments**: Supports dynamic and user-defined build arguments, using internal variables like **hbox_package_name** and **hbox_package_version** to tailor the build process to specific needs.
25
+
-**Registry and Local Images**: Manages images pulled from registries and locally built images, providing flexibility in how images are sourced and utilized within the hbox environment.
22
26
23
27
## Installation
24
28
@@ -250,7 +254,7 @@ The configuration below is for index (`$HBOX_DIR/index/<shard>/<package>.json`)
|`image`|`string`| The Docker image to be used for the package. Example: `"docker.io/busybox"`|
257
+
|`image`|`object`| The image configuration, which can include build instructions. Example: `{ "name": "hbox.${hbox_package_name}", "build": { "context": "/path/to/context", "dockerfile": "Dockerfile", "args": { "VERSION": "${hbox_package_version}" }}}`|
254
258
|`ports`|`array`| An array of port mappings for the container. Each port mapping has a `host` and `container`. Example: `[{"host": 8090, "container": 8091}, {"host": 8091, "container": 8092}]`|
255
259
|`volumes`|`array`| An array of volume mappings for the container. Each volume mapping has a `source` and `target`. Example: `[{"source": ".", "target": "/app"}]`|
256
260
|`current_directory`|`string`| The working directory inside the container. Example: `"/app"`|
@@ -260,7 +264,7 @@ The configuration below is for index (`$HBOX_DIR/index/<shard>/<package>.json`)
260
264
261
265
#### Property Details
262
266
263
-
-**image**: Specifies the Docker image to be used. This is a required property for defining the container image from which the package will be run.
267
+
-**image**: Specifies the image configuration, which can include build instructions. This allows for dynamic and user-defined build arguments, using internal variables like **hbox_package_name** and **hbox_package_version**.
264
268
265
269
-**ports**: Defines the port mappings between the host and the container. Each port mapping includes:
266
270
-`host`: The port on the host machine.
@@ -292,7 +296,9 @@ Example of a `$HBOX_DIR/index/g/golang.json`:
292
296
293
297
```json
294
298
{
295
-
"image": "docker.io/golang",
299
+
"image": {
300
+
"name": "docker.io/golang"
301
+
},
296
302
"volumes": [
297
303
{
298
304
"source": ".",
@@ -326,7 +332,9 @@ Example of a `$HBOX_DIR/overrides/busybox.json`:
326
332
327
333
```json
328
334
{
329
-
"image": "docker.io/busybox",
335
+
"image": {
336
+
"name": "docker.io/busybox"
337
+
},
330
338
"ports": [
331
339
{
332
340
"host": 8090,
@@ -432,6 +440,61 @@ If you enable logs in your `$HBOX_DIR/config.json` file, they will appear in the
432
440
433
441
**Note**: Be careful when sharing your logs, as they may contain sensitive information such as API keys and environment variables.
434
442
443
+
## How To
444
+
445
+
### Creating packages from custom images
446
+
447
+
To build custom images, you need to have a Dockerfile and a `.json` hbox config.
448
+
449
+
Let's take the [pkl](https://pkl-lang.org/) as an example and create a `Dockerfile` for it:
450
+
451
+
```Dockerfile
452
+
FROM alpine:latest
453
+
454
+
ARG VERSION=0.25.3
455
+
456
+
RUN apk add --no-cache curl
457
+
458
+
WORKDIR /usr/local/bin
459
+
460
+
RUN curl -L -o pkl https://github.com/apple/pkl/releases/download/${VERSION}/pkl-alpine-linux-amd64 && \
461
+
chmod +x pkl
462
+
463
+
ENTRYPOINT ["pkl"]
464
+
```
465
+
466
+
Since this is a custom package, we need to make it visible to hbox, so we will add it into the `$HBOX_DIR/overrides` folder as `pkl.json`.
467
+
Let's also make use of hbox internal variables to pass values to the Dockerfile and tag the image accordingly:
0 commit comments