Sign inSign up

codxio/emoncms_arm64

By codxio

Updated over 4 years ago

Open Energy Monitor

Image
0

112

codxio/emoncms_arm64 repository overview

EmonCMS

The simplified Version of https://github.com/emoncms/emoncms-docker

GitHub will follow soon!

Emoncms is an open-source web application for processing, logging and visualising energy, temperature and other environmental data and is part of the OpenEnergyMonitor project.

Emoncms

  • PHP, Apache and MQTT are already in image Integrity

Requirements

  • MySQL or MariaDB
  • Redis

The file structure should look like:

+-- EmonCMS
    +-- docker-compose.yml
    +-- default.docker-env
    +-- docker.settings.ini
    ¦ 
    +-- bin
    ¦   +-- setup_dev_repositories
    ¦ 
    +-- emoncms
    ¦   +-- <emoncms-core files>
    ¦   +-- e.g index.php
    ¦   +-- Modules
    ¦       +-- <core-modules> e.g. admin, feed, input
    ¦       +-- <optional-modules> e.g dashboard

docker.settings.ini :

; An example file showing how to load settings from environment variables

[sql]
server = {{MYSQL_HOST}}
database = {{MYSQL_DATABASE}}
username = {{MYSQL_USER}}
password = {{MYSQL_PASSWORD}}
port = {{MYSQL_PORT}}

[redis]
enabled = {{REDIS_ENABLED}}
host = {{REDIS_HOST}}
port = {{REDIS_PORT}}
prefix = {{REDIS_PREFIX}}

[mqtt]
enabled = {{MQTT_ENABLED}}
host = {{MQTT_HOST}}
user = {{MQTT_USER}}
password = {{MQTT_PASSWORD}}
basetopic = {{MQTT_BASETOPIC}}

[feed]
phpfina[datadir] = {{PHPFINA_DIR}}
phptimeseries[datadir] = {{PHPTIMESERIES_DIR}}

setup_dev_repositories :

#!/bin/bash
#
# Check out the requisite modules for a working emoncms setup.
#
rm emoncms -rf
git clone https://github.com/emoncms/emoncms.git ./emoncms
git clone https://github.com/emoncms/dashboard.git ./emoncms/Modules/dashboard
git clone https://github.com/emoncms/graph.git ./emoncms/Modules/graph
git clone https://github.com/emoncms/device.git ./emoncms/Modules/device
git clone https://github.com/emoncms/app.git ./emoncms/Modules/app

# Use docker settings
cp  docker.settings.ini ./emoncms/settings.ini
Before running docker-compose Run the following script to clone the emoncms repository along with the dashboard and graph modules:
$ ./bin/setup_dev_repositories

  or

$ bash ./bin/setup_dev_repositories

Running Docker-compose with persistence

Local directories / External Configuration

Alternatively you can use volumes to make the changes persistent and change the configuration.

version: '3'

services:

  web:
    image: codxio/emoncms_arm64:1.0
    container_name: EmonCMS
    env_file:
      - 'default.docker-env'
    volumes:
      - /data/EmonCMS/emoncms:/var/www/emoncms
      - /data/EmonCMS/php-fina:/var/opt/emoncms/phpfina
      - /data/EmonCMS/php-time-series:/var/opt/emoncms/phptimeseries
    links:
      - db
      - redis
    ports:
      - 8093:80
    networks:
      - emoncms     
    restart: always
    
  redis:
    image: redis:5
    container_name: EmonCMS_RD
    logging:
      driver: json-file
      options:
        max-size: "10m"
    env_file:
      - 'default.docker-env'
    volumes:
      - /data/EmonCMS/RS:/data
    networks:
      - emoncms
    restart: always    

  db:
    image: mariadb:latest
    container_name: EmonCMS_DB
    logging:
      driver: json-file
      options:
        max-size: "10m"     
    environment:
      - "MYSQL_HOST=localhost"
    env_file:
      - 'default.docker-env'
    volumes:
      - /data/EmonCMS/DB:/var/lib/mysql
    ports:
        - 3306:3306
    networks:
      - emoncms
    restart: always

  phpmyadmin:
    image: phpmyadmin 
    container_name: EmonCMS_PHP-MA
    environment:
      - PMA_ARBITRARY=1
      - PMA_HOST=db
    depends_on:
      - db
    ports:
      - 8083:80
    networks:
      - emoncms
    restart: always 

networks:
  emoncms:

MYSQL Database Credentials

For development the default settings in default.docker.env are used. For production a .env file should be created with secure database Credentials. See Production setup info below.

default.docker-env :

# Default docker enviroment variables, change in production enviroment

# MySQL database 
MYSQL_HOST=db
MYSQL_PORT=3306
MYSQL_DATABASE=emoncms
MYSQL_USER=emoncms
MYSQL_PASSWORD=YOUR_SECURE_PASSWORD
MYSQL_RANDOM_ROOT_PASSWORD=yes
MYSQL_INITDB_SKIP_TZINFO=true

# Redis
REDIS_ENABLED=true
REDIS_HOST=redis
REDIS_PORT=6379
# At the moment Docker doesn't honour the REDIS_AUTH variable, so it will always be passwordless
# REDIS_AUTH=
REDIS_PREFIX='emoncms'

# MQTT
MQTT_ENABLED=false
MQTT_HOST=localhost
MQTT_USER=YOUR_MQTT_USER
MQTT_PASSWORD=YOUR_MQTT_PASSWORD
MQTT_BASETOPIC=emon

# Feed
PHPFINA_DIR=/var/opt/emoncms/phpfina/
PHPTIMESERIES_DIR=/var/opt/emoncms/phptimeseries/
Start as foreground service:
$ docker-compose up

That's it! Emoncms should now be running in Docker container, browse to http://localhost:8090

Tag summary

Content type

Image

Digest

Size

207.1 MB

Last updated

over 4 years ago

docker pull codxio/emoncms_arm64:1.0