Add Dockerfile and README.md

This commit is contained in:
Moritz Ruth 2023-04-11 00:47:47 +02:00
parent 00a7c52d07
commit e1969303ad
Signed by: moritzruth
GPG key ID: C9BBAB79405EE56D
3 changed files with 67 additions and 1 deletions

11
Dockerfile Normal file
View file

@ -0,0 +1,11 @@
FROM clux/muslrust:stable as builder
WORKDIR /volume
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./src ./src
RUN cargo build --release
FROM alpine:latest
COPY --from=builder /volume/target/x86_64-unknown-linux-musl/release/hass-wol /app/hass-wol
VOLUME /data
CMD ["/app/hass-wol", "/config.toml", "/data"]

55
README.md Normal file
View file

@ -0,0 +1,55 @@
# hass-wol
> Wake-on-LAN (WoL) for your Home Assistant
## Usage
This tool is intended to be used as a companion container to the Home Assistant container.
Your `docker-compose.yml` may look like this:
```yaml
version: "3.9"
services:
homeassistant:
image: "homeassistant/home-assistant"
# ...
hass-wol:
image: "git.moritzruth.de/moritzruth/hass-wol:1.0.0"
restart: unless-stopped
network_mode: host # this is required because WoL uses UDP broadcast packets
volumes:
- "./hass-wol.toml:/config.toml:ro"
- "./data:/data" # persistent data
```
And your `hass-wol.toml` like this:
```toml
broadcast_address = "255.255.255.255" # dont change this if you dont need to
[mqtt]
host = "MQTT_BROKER_IP_ADDRESS"
port = 1883
client_id = "hass-wol"
credentials = { user = "USER", password = "PASSWORD" }
[[host]]
display_name = "my_pc"
mac_address = "04:1B:BF:2D:C7:70"
[[host]]
display_name = "my_server"
mac_address = "20:5D:48:98:94:C0"
# These options are optional.
# hass_identifiers = [] # see https://www.home-assistant.io/integrations/button.mqtt/#identifiers
# packet_count = 6
# ms_between_packets = 500
```
## License
hass-wol is licensed under the [Blue Oak Model License 1.0.0](./LICENSE.md).

View file

@ -1,6 +1,6 @@
use std::collections::{HashMap, HashSet};
use std::env;
use std::net::{IpAddr, SocketAddr};
use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::process::exit;
use std::str::FromStr;