diff --git a/.env.example b/.env.example index a135014..255acc9 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,3 @@ -DOCKER_INFLUXDB_INIT_MODE= DOCKER_INFLUXDB_INIT_USERNAME= DOCKER_INFLUXDB_INIT_PASSWORD= DOCKER_INFLUXDB_INIT_ORG= diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 6115156..2f811f4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,14 +7,13 @@ on: branches: [ "master" ] jobs: - build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: Init submodules run: git submodule update --init --recursive - - name: Build the Docker image + - name: Build the Enohub Docker image + run: docker build . --file Dockerfile --tag enohub:$(date +%s) + - name: Build the Enohub Proxy image run: docker build . --file Dockerfile --tag enohub:$(date +%s) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 6f0b43e..3577032 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -22,3 +22,5 @@ jobs: run: docker buildx create --use - name: Build enohub Docker image run: docker buildx build --platform linux/amd64,linux/arm64 --file Dockerfile --tag ghcr.io/yusufcanb/enohub:${{ env.RELEASE_VERSION }} --push . + - name: Build Nginx Proxy Image + run: docker buildx build --platform linux/amd64,linux/arm64 --file Dockerfile.nginx --tag ghcr.io/yusufcanb/enohub-proxy:${{ env.RELEASE_VERSION }} --push . diff --git a/Dockerfile b/Dockerfile index 505fc39..5e51e57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,24 @@ -FROM python:3.8 - -LABEL org.opencontainers.image.source=https://github.com/yusufcanb/enohub -LABEL org.opencontainers.image.description="EnOcean Sensor Hub. Listens ESP3 packets from EnOcean USB 3000 usb stick and pipes into InfluxDB time-series database." +FROM python:3.11-buster as builder WORKDIR /opt/enocean/enohub +RUN pip install poetry==1.7.1 + +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 COPY . . +RUN poetry install --without dev --no-root + +FROM python:3.11-slim-buster as runtime -RUN apt-get install gcc +LABEL org.opencontainers.image.source=https://github.com/yusufcanb/enohub +LABEL org.opencontainers.image.description="EnOcean Sensor Hub. Listens ESP3 packets from EnOcean USB 3000 usb stick and pipes into InfluxDB time-series database." + +WORKDIR /opt/enocean/enohub -RUN pip install --upgrade pip -RUN pip3 install poetry +ENV PATH="/opt/enocean/enohub/.venv/bin:$PATH" -RUN poetry config virtualenvs.create false -RUN poetry install --no-dev +COPY --from=builder /opt/enocean/enohub /opt/enocean/enohub -CMD ["python3", "-W", "ignore", "-m", "enohub", "-c", "config.yaml"] \ No newline at end of file +CMD ["python3", "-W", "ignore", "-m", "enohub", "-c", "config.yaml"] diff --git a/README.md b/README.md index 42d2ec6..e388cea 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,9 @@ # EnOcean Hub -This project aims to act as an device hub which collects sensor data and puts it into InfluxDB Time-Series database for quick visualization. +This project aims to act as an device hub which collects sensor data and puts it into InfluxDB Time-Series database and have for quick visualization with Grafana. ![dashboard](https://yusufcanb.github.io/enohub/images/dashboard.png) -## Docs - -For more detailed documentation please navigate to the link below; -[https://yusufcanb.github.io/enohub/](https://yusufcanb.github.io/enohub/) - ## Hardware Requirements - EnOcean STM 550 Multisensor @@ -17,19 +12,19 @@ For more detailed documentation please navigate to the link below; ## Software Requirements -On Raspberry Pi you need them to be installed; +On Raspberry Pi you need to have below installed; - Docker -- Docker Compose -## External Requirements +## Quick Start -- InfluxDB -- Grafana (Optional for Visualization) +First, clone the project, -## Quick Start +``` +git clone https://github.com/yusufcanb/enohub +``` -First, create the config file, +Then, create the config file with the sensor ids you have , ```shell cat << EOF > config.yaml @@ -38,17 +33,9 @@ port: /dev/ttyUSB0 devices: - id: 04211ABE - name: desk + name: stm-550 eep: d2-14-41 - - - id: 04211945 - name: table - eep: d2-14-41 - - - id: 051B0025 - name: co2-meter - eep: a5-09-09 - + database: url: https://your-influxdb-host:port org: your-org @@ -57,8 +44,21 @@ database: EOF ``` -Then, execute docker command below to start EnOcean Hub +Finally, deploy it using Docker Compose, ``` -docker run --device=/dev/ttyUSB0 -v "$PWD/config.yaml:/opt/enocean/enohub/config.yaml" ghcr.io/yusufcanb/enohub:latest +docker compose up -d ``` + + +Alternatively, if you already have InfluxDB on somewhere else and you just want pipe the data you may you the command below; + +``` +docker run --rm --device=/dev/ttyUSB0 -v "$PWD/config.yaml:/opt/enocean/enohub/config.yaml" ghcr.io/yusufcanb/enohub:latest +``` + + +## Docs + +For more detailed documentation please navigate to the link below; +[https://yusufcanb.github.io/enohub/](https://yusufcanb.github.io/enohub/) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a78a81a..bcb6b60 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: influxdb: image: influxdb:2.6-alpine environment: - - DOCKER_INFLUXDB_INIT_MODE=${DOCKER_INFLUXDB_INIT_MODE} + - DOCKER_INFLUXDB_INIT_MODE=setup - DOCKER_INFLUXDB_INIT_USERNAME=${DOCKER_INFLUXDB_INIT_USERNAME} - DOCKER_INFLUXDB_INIT_PASSWORD=${DOCKER_INFLUXDB_INIT_PASSWORD} - DOCKER_INFLUXDB_INIT_ORG=${DOCKER_INFLUXDB_INIT_ORG} @@ -27,10 +27,17 @@ services: - GF_PANELS_DISABLE_SANITIZE_HTML=true restart: on-failure + enohub: + image: ghcr.io/yusufcanb/enohub:0.3.0 + ports: + - '80:80' + - '443:443' + restart: on-failure + depends_on: + - influxdb + nginx: - build: - context: . - dockerfile: Dockerfile.nginx + image: ghcr.io/yusufcanb/enohub-proxy:0.3.0 ports: - '80:80' - '443:443'