Skip to content

Commit 368c065

Browse files
att
1 parent 39d80c7 commit 368c065

1 file changed

Lines changed: 39 additions & 36 deletions

File tree

README.md

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
## [Download Link](https://github.com/OUIsolutions/LuaShip/releases/download/0.0.3/LuaShip.lua)
33
LuaShip is a Lua library for managing containerized build environments. It provides a simple interface for creating and managing container images, executing commands, and handling file operations.
44

5+
## Core Features
6+
7+
- Container image management with support for Docker and Podman
8+
- File copying between host and container
9+
- Environment variable configuration
10+
- Build-time command execution
11+
- Flexible container start options
12+
513
### Building from Scratch
614
if you want to build the project from the repo, just install [Darwin](https://github.com/OUIsolutions/Darwin) with:
715
```bash
@@ -11,16 +19,40 @@ and then you can build the **LuaShip.lua** with:
1119
```bash
1220
darwin run_blueprint
1321
```
14-
## Core Features
15-
16-
- Container image management with support for Docker and Podman
17-
- File copying between host and container
18-
- Environment variable configuration
19-
- Build-time command execution
20-
- Flexible container start options
2122

2223
## API Reference
2324

25+
## Example Usage
26+
27+
```lua
28+
local ship = require("LuaShip")
29+
30+
-- Create a new container machine
31+
local image = ship.create_machine("alpine:latest")
32+
33+
-- Configure container runtime
34+
image.provider = "podman"
35+
36+
-- Add build-time commands
37+
image.add_comptime_command("apk update")
38+
image.add_comptime_command("apk add --no-cache gcc musl-dev curl")
39+
40+
-- Copy files
41+
image.copy("source.c", "source.c")
42+
43+
-- Start container with specific configuration
44+
image.start({
45+
flags = {
46+
"--memory=200m",
47+
"--network=host"
48+
},
49+
volumes = {
50+
{ ".", "/output" }
51+
},
52+
command = "gcc --static source.c -o /output/binary"
53+
})
54+
```
55+
2456
### LuaShip Module
2557

2658
#### `create_machine(distro: string): LuaShipMachine`
@@ -78,36 +110,7 @@ Starts the container with the specified configuration.
78110
- `volumes`: Array of volume mappings `[["host_path", "container_path"]]`
79111
- `command`: Command to execute when starting the container
80112

81-
## Example Usage
82113

83-
```lua
84-
local ship = require("LuaShip")
85-
86-
-- Create a new container machine
87-
local image = ship.create_machine("alpine:latest")
88-
89-
-- Configure container runtime
90-
image.provider = "podman"
91-
92-
-- Add build-time commands
93-
image.add_comptime_command("apk update")
94-
image.add_comptime_command("apk add --no-cache gcc musl-dev curl")
95-
96-
-- Copy files
97-
image.copy("source.c", "source.c")
98-
99-
-- Start container with specific configuration
100-
image.start({
101-
flags = {
102-
"--memory=200m",
103-
"--network=host"
104-
},
105-
volumes = {
106-
{ ".", "/output" }
107-
},
108-
command = "gcc --static source.c -o /output/binary"
109-
})
110-
```
111114

112115
## Configuration
113116

0 commit comments

Comments
 (0)