Skip to content

Commit

Permalink
chore: add linux onboarding documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Cezar Rata <[email protected]>
  • Loading branch information
cezar-r committed Sep 16, 2024
1 parent 504dcaf commit f415819
Showing 1 changed file with 39 additions and 47 deletions.
86 changes: 39 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,46 @@ The Finch Daemon project is a container runtime engine that enables users to sea
Please review [CONTRIBUTING.md](./CONTRIBUTING.md) for onboarding as well for an overview of the development cycle for this project. Additionally, check the [Makefile](./Makefile) for additional information on setup & configuration.

## Quickstart
Make sure [NerdCTL](https://github.com/containerd/nerdctl) and [Containerd](https://github.com/containerd/containerd) are installed and set up

### macOS
Note that with macOS, it is not possible to run unit tests with `make run-unit-tests` or do code-gen with `make code-gen` directly as this is a Linux project. It is possible, however, to build the project on macOS with `make` and run the linux-related commands in the finch vm.
### Linux
Getting started with finch-daemon on Linux only requires a few steps:

1. Get finch, `brew install finch`
2. Add the unix socket forwarding to `/Applications/Finch/lima/data/finch/lima.yaml`:
```yaml
portForwards:
- guestSocket: "/run/finch.sock"
hostSocket: "{{.Dir}}/sock/finch.sock"
```
3. Init the vm to apply the changes (or restart if Finch was already running):
```bash
# init
finch vm init

# restart
finch vm stop
finch vm start
```
4. Pull finch-daemon from the GitHub repo to somewhere under your home directory: `git clone https://github.com/runfinch/finch-daemon.git`
5. Check if you have go installed with `go version`, if not, install go with `brew install go`
6. Build finch-daemon with `make`
7. Spin up the finch-daemon server in finch's vm:
```bash
LIMA_HOME=/Applications/Finch/lima/data /Applications/Finch/lima/bin/limactl shell finch
cd <finch-daemon-dir>
1. Clone the finch-daemon Github repository - `git clone https://github.com/runfinch/finch-daemon.git`
2. `cd finch-daemon`
3. Install Go and make sure that `go version` is >= 1.22
4. Build and spin up the finch-daemon server with
```bash
make
sudo bin/finch-daemon --debug --socket-owner $UID
```
8. Test the project and use finch to confirm changes
- Using curl:
```bash
curl -v -X GET --unix-socket /Applications/Finch/lima/data/finch/sock/finch.sock 'http://localhost/version'
```
- Using Docker CLI:
```bash
DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock docker images
```
- Using the Docker python SDK (after installing python3):
```bash
# Install docker python SDK
python3 -m pip install docker
# Start python
DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock python3
```
```python
>>> import docker
>>> client = docker.from_env()
>>> con = client.containers.get("test-container")
>>> con.attach(stream=True, logs=True, demux=True)
```
5. Test any changes with `make run-unit-tests` and `sudo make run-e2e-tests`

## Creating a systemd service
Sometimes, you may wish to have a script be controlled by systemd, or to have the script restart by itself when it gets killed. You can configure such a service using systemd on Linux by following these steps:

1. `cd /etc/systemd/system`
2. Create a `finch.service` file, with the following contents:
```ini
[Unit]
Description=finch daemon %I
Documentation=https://runfinch.com
After=network.target local-fs.target containerd.service
Wants=network.target containerd.service

[Service]
ExecStart=/usr/local/bin/finch-daemon --debug --socket-owner %i

Type=notify
Delegate=yes
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
```
3. Refresh the service files to include the new service - `sudo systemctl daemon-reload`
4. Start the service - `sudo systemctl start finch.service`
5. To check the status of the service - `sudo systemctl status finch.service`
6. To enable the service on every reboot - `sudo systemctl enable finch.service`
7. To disable the service on every reboot - `sudo systemctl disable finch.service`

0 comments on commit f415819

Please sign in to comment.