Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weiwenhao/parker
๐ package the workdir into a lightweight container runtime that can be executed directly.
https://github.com/weiwenhao/parker
build-tool container nature-lang
Last synced: about 2 months ago
JSON representation
๐ package the workdir into a lightweight container runtime that can be executed directly.
- Host: GitHub
- URL: https://github.com/weiwenhao/parker
- Owner: weiwenhao
- License: mit
- Created: 2023-09-15T03:01:18.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-29T11:14:47.000Z (10 months ago)
- Last Synced: 2024-08-02T06:22:10.492Z (5 months ago)
- Topics: build-tool, container, nature-lang
- Language: Go
- Homepage:
- Size: 57.6 KB
- Stars: 81
- Watchers: 7
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ops - weiwenhao/parker - 09-15|2024-02-29 | ไธๆฌพๅบไบ go ่ฏญ่จ็ผๅ็่ฝป้็บงๆๅ ๅทฅๅ ท๏ผ่ฝๅคๅฐๅฏๆง่กๆไปถไธๅ ถไพ่ต็ๅทฅไฝ็ฎๅฝๆๅ ๆไธไธชๅฏๆง่กๆไปถ | (็ป็ซฏๅฝไปค่กๅทฅๅ ท)
README
# Parker
Lightweight packaging tool and container runtime, a single command packages the working directory into an executable file.
![](https://raw.githubusercontent.com/weiwenhao/pictures/main/blogs20230922113619.png)
The example demonstrates a C language-based IP resolution service (`gcc -o ipservice`), dependent on the ipdb resource file.
Use Parker to compress the executable file `ipservice` and its dependent asset into a new executable file named `ipservice-c`.
When `ipservice-c` is run on the target machine, it will create a lightweight container environment to operate the original `ipservice` service.
## โ๏ธ Installation
Download and unpack the Parker installation package from [github releases](https://github.com/weiwenhao/parker/releases). It's recommended to move the unzipped parker folder to `/usr/local/` and add the `/usr/local/parker/bin` directory to your system's environment variables.
```
> parker --version
1.0.1
```## ๐ฆ Usage
`cd` to your working directory and run `parker :target`. This command packages the `:target` along with the current working directory into an executable file named `:target-c`. Once packaged, move this executable file to your target machine and run it.
```
> cd :workdir && parker :target
```#### Example
The above example of packaging the executable file and resource file is a **standard usage** example. However, there are non-standard usage scenarios as well, such as with a server written in python3.11:
```
> tree .
โโโ bar.png
โโโ foo.txt
โโโ python # cp /usr/bin/python3.11 ./
โโโ server.py
```Content of server.py:
```python
from http.server import SimpleHTTPRequestHandler, HTTPServerdef run():
print("listen on http://127.0.0.1:8000")
server_address = ('127.0.0.1', 8000)
httpd = HTTPServer(server_address, SimpleHTTPRequestHandler)
httpd.serve_forever()run()
```When you `cd` to the working directory and run `parker python`, you'll receive a `python-c` file. This is the packaged executable file. Upload it to the target machine and run it.
```
> parker python
python-c
โโโ server.py
โโโ python
โโโ foo.txt
โโโ bar.png
๐ป parker successful------------------------------------------------------------------------ move pyhon-c to target
> tree .
.
โโโ python-c0 directories, 1 file
------------------------------------------------------------------------ run python-c
> ./python-c server.py
listen on http://127.0.0.1:8000
```Here, `python-c` passes arguments to the python process.
> โ๏ธ Parker does not solve python's dynamic compilation issues.
## ๐ข Runtime
`python-c` is a lightweight container runtime created by Parker. It's a statically compiled executable file. When executed, it uses the linux namespace to create an isolated environment and then unpacks the working directory to run the target python.
`python-c` monitors the python main process during its execution. If the python process stops or encounters an error, `python-c` will utilize cgroup to clean up the container environment and kill all of python's child processes.
All arguments and signals passed to `python-c` will be relayed directly to the python process.
## ๐ง Dependencies
The container runtime depends on cgroup and namespace, requiring a linux kernel version higher than 2.6.24. Also, cgroup should be correctly mounted. Check for the existence of either `/sys/fs/cgroup/cgroup.controllers` or `/sys/fs/cgroup/freezer` directories.
Tested environments: ubuntu:22 / ubuntu:20
## ๐ ๏ธ Make build
The source code is developed in the [nature](https://github.com/nature-lang/nature) programming language. The nature compiler version needs to be >= 0.4.0. After installation, execute `make amd64 && make install` in the source code directory to install to the /usr/local/parker directory.
> Nature currently primarily supports amd64 builds. Executables built by nature have a smaller size and higher efficiency. For other architectures, the main repository provides a golang version.
## ๐ Thanks
[nature](https://github.com/nature-lang/nature) is a modern system-level programming language and compiler. It works hand in hand with C for high-performance and efficient development.
The community-available version of nature is about to be released. Early experiences and feedback are welcome. You're also invited to contribute to the standard library; all contributions will be merged into the main repository.
## ๐ชถ License
This project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
Copyright (c) 2020-2023 WEIWENHAO, all rights reserved.