From 1e44a2891952a7c8dc8f5b9d5a4d87900e791ebe Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 5 Jan 2022 14:55:46 -0500 Subject: [PATCH] - readme - functional code --- .vscode/settings.json | 3 ++ Dockerfile | 45 +++++++++++++++---- Makefile | 6 +++ README.md | 15 +++++++ docker-compose.yaml | 13 ++++++ run.sh | 5 --- .../config => sample_config}/automations.yaml | 0 7 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 Makefile create mode 100644 README.md create mode 100644 docker-compose.yaml delete mode 100644 run.sh rename {samples/01/config => sample_config}/automations.yaml (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..163c984 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.formatting.provider": "black" +} diff --git a/Dockerfile b/Dockerfile index dc88393..ae0c21c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,44 @@ ARG BUILD_FROM +# ================ +# Python Build Stage +# ================ +FROM python:3.9 as pybuilder + +WORKDIR /python + +COPY api/setup.py /python/setup.py +RUN python -m venv /python/venv +RUN /python/venv/bin/pip install --use-feature=in-tree-build /python/ + +# ================ +# Web Build Stage +# ================ +FROM node:16.13.0-alpine as webbuilder + +WORKDIR /web +COPY webapp/ /web +RUN npm install +RUN yarn build + +# ================ +# Main Image +# ================ FROM $BUILD_FROM ENV LANG C.UTF-8 -# Install requirements for add-on -RUN apk add --no-cache python3 - -# Python 3 HTTP Server serves the current working dir -# So let's set it to our add-on persistent data directory. WORKDIR /data +RUN apk add gcompat python3 +RUN ln -s $(which python3) /usr/local/bin/python -# Copy data for add-on -COPY run.sh / -RUN chmod a+x /run.sh +COPY --from=pybuilder /python/venv /data/venv +COPY --from=webbuilder /web/build /data/web -CMD [ "/run.sh" ] \ No newline at end of file +COPY api/src /data/src + + +ENV HASSIO_TOKEN "" + +EXPOSE 8000 + +CMD [ "/data/venv/bin/python", "-m", "uvicorn", "src.app:app" ] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1c226f1 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +run_locally: + docker-compose build + docker-compose up -d + docker-compose ps + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..285c772 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Shortumation + +A [home-assistent addon](https://www.home-assistant.io/addons/) for a better UI for managing your automations & scripts. We provide a way to visualize and develop your automation using a visual-programming language that draws inspirations from [Node-Red](https://nodered.org/). + +## Features + +- [X] View your automations & scripts in a visual graph +- [X] See all automations in one common view +- [X] Automation Manager +- [ ] Script Manager +- [ ] Use secrets and global parameters +- [ ] Autocomplete fields for entities/devices +- [ ] Autocomplete fields for template editor +- [ ] Autocomplete fields for referencing scripts + diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..c64ad7c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '3' +services: + addon: + image: "shortumation:${BUILD_TAG:-latest}" + build: + context: "./" + dockerfile: "./Dockerfile" + args: + - BUILD_FROM=homeassistant/amd64-base:latest + volumes: + - "./sample_config:/config" + ports: + - "8000:8000" diff --git a/run.sh b/run.sh deleted file mode 100644 index 5146423..0000000 --- a/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/with-contenv bashio - -echo Hello world! - -python3 -m http.server 8000 \ No newline at end of file diff --git a/samples/01/config/automations.yaml b/sample_config/automations.yaml similarity index 100% rename from samples/01/config/automations.yaml rename to sample_config/automations.yaml