Skip to content

Commit

Permalink
Rewrite cloud-config to run container image
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmab committed Dec 3, 2024
1 parent 2cf49c0 commit f6d75ff
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 67 deletions.
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ COPY pkg pkg
RUN make skyeye
RUN make skyeye-scaler

FROM debian:bookworm-slim AS skyeye

FROM debian:bookworm-slim AS base
RUN apt-get update && apt-get install -y \
libopus0 \
libsoxr0 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

FROM base AS skyeye
RUN apt-get update && apt-get install -y \
libopenblas0-openmp \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /skyeye/skyeye /opt/skyeye/bin/skyeye
ENTRYPOINT ["/opt/skyeye/bin/skyeye"]

FROM debian:bookworm-slim AS skyeye-scaler
RUN apt-get update && apt-get install -y \
libopus0 \
libsoxr0 \
&& rm -rf /var/lib/apt/lists/*
FROM base AS skyeye-scaler
COPY --from=builder /skyeye/skyeye-scaler /opt/skyeye/bin/skyeye-scaler
ENTRYPOINT ["/opt/skyeye/bin/skyeye-scaler"]
ENTRYPOINT ["/opt/skyeye/bin/skyeye-scaler"]
35 changes: 32 additions & 3 deletions docs/ADMIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ Outbound ports typically required by SkyEye:
- `5002/TCP`: SRS Data
- `5002/UDP`: SRS Audio
- `42674/TCP`: TacView Real-Time Telemetry

You may also need `443/TCP` outbound during installation to download from GitHub and Hugging Face. If you use the autoscaler, you'll need to allow outbound connections to your webhook URL.
- `443/TCP`: Discord webhook

SkyEye does not require any inbound ports during runtime.

Expand Down Expand Up @@ -183,7 +182,37 @@ The scaler is also available as a container image at `ghcr.io/dharmab/skyeye-sca

### cloud-init

A sample [cloud-init](https://cloudinit.readthedocs.io/en/latest/) config is provided in `/init/cloud-init` directory in the Git repository. This automates the installation and startup on a new cloud server instance running Debian or Ubuntu. It can also be modified to work on other Linux distros with minor tweaks.
A sample [cloud-init](https://cloudinit.readthedocs.io/en/latest/) config is provided in `/init/cloud-init` directory in the Git repository. This automates the installation and startup on a new cloud server instance. It should be compatible with most Linux distributions including Debian, Ubuntu, Fedora, Arch Linux and OpenSUSE.

See documentation on cloud-init:

- [Official documentation](https://cloudinit.readthedocs.io/en/latest/index.html)
- [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-cloud-init)
- [GCP](https://cloud.google.com/container-optimized-os/docs/how-to/create-configure-instance#using_cloud-init_with_the_cloud_config_format)
- [Hetzer](https://docs.hetzner.cloud/#servers-create-a-server)
- [Linode](https://techdocs.akamai.com/cloud-computing/docs/overview-of-the-metadata-service#add-user-data-when-deploying-a-compute-instance)
- [Vultr](https://docs.vultr.com/how-to-deploy-a-vultr-server-with-cloudinit-userdata)

To customize this cloud-init file:

1. Edit the `content` field of the `/etc/skyeye/config.yaml` file with your desired configuration.
1. If you want to pin to a specific version of SkyEye, replace `ghcr.io/dharmab/skyeye:latest` with the desired version. I strongly recommend you pin the version in case of any breaking changes in the future.

If you wish to change the version of SkyEye in the future:

```sh
# Stop SkyEye
sudo systemctl stop skyeye
# Edit the systemd service to change the image version
sudoedit /etc/systemd/system/skyeye.service
sudo systemctl daemon-reload
# Make any required changes to the configuration
sudoedit /etc/skyeye/config.yaml
# Restart SkyEye
sudo systemctl start skyeye
# Check the logs and check if it seems to be working
journalctl -fu skyeye
```

### Manual Installation

Expand Down
77 changes: 77 additions & 0 deletions init/cloud-init/cloud-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#cloud-config
users:
- name: skyeye
groups: users
packages:
- podman
package_update: true
package_upgrade: true
write_files:
- path: /opt/skyeye/models/whisper.bin
permissions: "0644"
owner: skyeye:users
source:
uri: https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin
defer: true
- path: /etc/skyeye/config.yaml
permissions: "0600"
owner: skyeye:users
content: |
callsign: Focus
telemetry-address: your-tacview-address:42674
telemetry-password: your-telemetry-password
srs-server-address: your-srs-server:5002
srs-eam-password: your-srs-password
srs-frequencies: "132.1,245.6,32.1"
exit-after: "72h"
defer: true
- path: /etc/skyeye/image.env
permissions: "0644"
owner: skyeye:users
content: |
CONTAINER_IMAGE=ghcr.io/dharmab/skyeye:latest
defer: true
- path: /etc/systemd/system/skyeye.service
permissions: "0644"
owner: root:root
content: |
[Unit]
Description=SkyEye GCI Bot
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/var/run/container/storage
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=-/etc/skyeye/image.env
Restart=always
RestartSec=60
ExecStartPre=/bin/rm -f %t/%n-pid %t/%n-cid
ExecStart=/usr/bin/podman run \
--conmon-pidfile %t/%n-pid \
--cidfile %t/%n-cid \
--cgroups=no-conmon \
-d \
--volume /etc/skyeye:/etc/skyeye:ro \
--volume /opt/skyeye/models:/opt/skyeye/models:ro \
--name %n \
${CONTAINER_IMAGE} \
--whisper-model /opt/skyeye/models/whisper.bin
ExecStop=/usr/bin/podman stop \
--ignore \
--cidfile %t/%n-cid -t 10
ExecStopPost=/usr/bin/podman rm \
--ignore \
-f \
--cidfile %t/%n-cid
PIDFile=%t/%n-pid
KillMode=none
Type=forking
[Install]
WantedBy=default.target
runcmd:
- systemctl daemon-reload
- systemctl enable skyeye
- reboot
57 changes: 0 additions & 57 deletions init/cloud-init/ubuntu.yaml

This file was deleted.

0 comments on commit f6d75ff

Please sign in to comment.