diff --git a/.dockerignore b/.dockerignore index 40d3113..227d259 100644 --- a/.dockerignore +++ b/.dockerignore @@ -12,7 +12,4 @@ docker-compose* .gitignore # TOML files -autarco.toml* - -# Documentation -*.md +Rocket.toml diff --git a/Dockerfile b/Dockerfile index 71a0a05..609acbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ FROM docker.io/rust:1 as builder # Build the dependencies first RUN USER=root cargo new --bin autarco-scraper -WORKDIR ./autarco-scraper +WORKDIR /usr/src/autarco-scraper COPY ./Cargo.* ./ RUN cargo build --release RUN rm src/*.rs diff --git a/README.md b/README.md index 4845186..27177da 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,36 @@ Autarco site/API to get statistical data of your solar panels. ## Building & running -First you need to provide your My Autarco credentials in the file -`autarco.toml` by setting the username and password. You can copy and modify `autarco.toml.example` for this: +First, you need to provide your My Autarco credentials in the file +`Rocket.toml` by setting the username, password and site ID. +You can copy and modify `Rocket.toml.example` for this: ```toml -# Put your My Autarco credentials below +[default] +# ... + +# Put your My Autarco credentials below and uncomment them username = "foo@domain.tld" password = "secret" +site_id = "abc123de" ``` -Then, using Cargo, it is easy to build and run Autarco Scraper, just run: +You can also change this configuration to use a different address and/or port. +(Note that Rocket listens on `127.0.0.1:8000` by default for debug builds, i.e. +builds when you don't add `--release`.) + +```toml +[default] +address = "0.0.0.0" +port = 8080 + +# ... +``` + +This will work independent of the type of build. For more about Rocket's +configuration, see: . + +Finally, using Cargo, it is easy to build and run Autarco Scraper, just run: ```shell $ cargo run --release @@ -24,21 +44,6 @@ $ cargo run --release Running `/path/to/autarco-scraper/target/release/autarco-scraper` ``` -(Note that Rocket listens on `127.0.0.1:8000` by default for debug builds, i.e. -builds when you don't add `--release`.) - -You can provide Rocket with configuration to use a different address and/or port. -Just create a `Rocket.toml` file that contains (or copy `Rocket.toml.example`): - -```toml -[default] -address = "0.0.0.0" -port = 8080 -``` - -This will work independent of the type of build. For more about Rocket's -configuration, see: . - ## API endpoint The `/` API endpoint provides the current statistical data of your solar panels @@ -54,7 +59,7 @@ GET / A response uses the JSON format and typically looks like this: ```json -{"current_w":23, "total_kwh":6159, "last_updated":1661194620} +{"current_w":23,"total_kwh":6159,"last_updated":1661194620} ``` This contains the current production power (`current_w`) in Watt, diff --git a/docker-compose.yml b/docker-compose.yml index 69f201d..87edeea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,10 +6,14 @@ services: build: . restart: unless-stopped ports: - - 8066:8000 + - 2356:8000 + # Use a `Rocket.toml` or configure the credentials using environment variables below volumes: - - ./autarco.toml:/autarco-scraper/autarco.toml + - ./Rocket.toml:/autarco-scraper/Rocket.toml environment: - ROCKET_ADDRESS: 0.0.0.0 ROCKET_LOG_LEVEL: normal # Available levels are: off, debug, normal, critical + # Put your My Autarco credentials below and uncomment them + # ROCKET_USERNAME: foo@domain.tld + # ROCKET_PASSWORD: secret + # ROCKET_SITE_ID: abc123de shm_size: '2gb'