mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-24 03:12:33 +10:00
Shrink Docker Image, bump version, docker run as non-root
This commit is contained in:
+9
-3
@@ -1,4 +1,6 @@
|
|||||||
FROM python:3
|
FROM python:3-slim
|
||||||
|
|
||||||
|
RUN useradd sungather
|
||||||
|
|
||||||
WORKDIR /usr/src/sungather
|
WORKDIR /usr/src/sungather
|
||||||
|
|
||||||
@@ -6,6 +8,10 @@ COPY requirements.txt ./
|
|||||||
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
||||||
|
|
||||||
COPY SunGather/ .
|
COPY SunGather/ .
|
||||||
RUN touch /config/config.yaml
|
|
||||||
|
|
||||||
CMD [ "python", "sungather.py -c /config/config.yaml" ]
|
VOLUME /config
|
||||||
|
COPY SunGather/config-example.yaml /config/config.yaml
|
||||||
|
|
||||||
|
USER sungather
|
||||||
|
|
||||||
|
CMD [ "python", "sungather.py", "-c", "/config/config.yaml" ]
|
||||||
@@ -80,6 +80,10 @@ python3 sungather.py
|
|||||||
docker pull bohdans/sungather
|
docker pull bohdans/sungather
|
||||||
docker run -v {path to}/config.yaml:/config/config.yaml -e TZ=Australia/Sydney --name sungather bohdans/sungather
|
docker run -v {path to}/config.yaml:/config/config.yaml -e TZ=Australia/Sydney --name sungather bohdans/sungather
|
||||||
```
|
```
|
||||||
|
or if using the http export
|
||||||
|
```sh
|
||||||
|
docker run -v {path to}/config.yaml:/config/config.yaml -e TZ=Australia/Sydney -p 8080:8080 --name sungather bohdans/sungather
|
||||||
|
```
|
||||||
Note: replace Australia/Sydney with relevant timezone
|
Note: replace Australia/Sydney with relevant timezone
|
||||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||||
|
|
||||||
@@ -92,6 +96,19 @@ See config-example.py it contains default options and comments.
|
|||||||
If you want to use the new Energy section in Home Assistant, follow the Home Assistant setup below.
|
If you want to use the new Energy section in Home Assistant, follow the Home Assistant setup below.
|
||||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||||
|
|
||||||
|
### Commandline Arguments
|
||||||
|
usage: python3 sungather.py [options]
|
||||||
|
|
||||||
|
Commandline arguments override any config file settings
|
||||||
|
**-c config.yaml** - Specify config file.
|
||||||
|
**-v 30** - Logging Level, 10 = Debug, 20 = Info, 30 = Warning (default), 40 = Error
|
||||||
|
**--runonce** - Run once then exit
|
||||||
|
**-h** - print this help message and exit (also --help)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```sh
|
||||||
|
python3 sungather.py -c /full/path/config.yaml
|
||||||
|
```
|
||||||
|
|
||||||
## Exports
|
## Exports
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class export_http(object):
|
|||||||
|
|
||||||
# Configure HTTP
|
# Configure HTTP
|
||||||
def configure(self, config):
|
def configure(self, config):
|
||||||
self.webServer = HTTPServer(('localhost', config.get('port',8080)), MyServer)
|
self.webServer = HTTPServer(('', config.get('port',8080)), MyServer)
|
||||||
t = Thread(target=self.webServer.serve_forever)
|
t = Thread(target=self.webServer.serve_forever)
|
||||||
t.start()
|
t.start()
|
||||||
logging.info("Configured Simple HTTP Server")
|
logging.info("Configured Simple HTTP Server")
|
||||||
|
|||||||
Reference in New Issue
Block a user