Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 49 additions & 14 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Build and Push emoncms legacy Docker Image
name: Build and Push emoncms Docker Image

on:
pull_request:
workflow_dispatch:
inputs:
php_version:
description: 'php_version'
required: true
type: string
default: '8.2.27'
default: '8.4'
emoncms_src:
description: 'emoncms_src'
required: true
Expand All @@ -19,38 +20,72 @@ on:
type: string
default: 'stable'

env:
PHP_VERSION: ${{ inputs.php_version || '8.4' }}
EMONCMS_SRC: ${{ inputs.emoncms_src || 'emoncms/emoncms' }}
EMONCMS_BRANCH: ${{ inputs.branch || 'stable' }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
# Checkout the repository code
- name: Checkout code
uses: actions/checkout@v4

# Log in to Docker Hub
- name: Check for Docker Hub credentials
id: check_dockerhub
run: |
if [ -n "${{ secrets.DOCKER_USERNAME }}" ] && [ -n "${{ secrets.DOCKER_PASSWORD }}" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi

- name: Log in to Docker Hub
if: steps.check_dockerhub.outputs.available == 'true' && github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- id: emoncms_version
name: get emoncms version

- name: Log in to GitHub Container Registry
if: steps.check_dockerhub.outputs.available != 'true' || github.event_name == 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get emoncms version
id: emoncms_version
run: |
wget https://raw.githubusercontent.com/${{ inputs.emoncms_src }}/${{ inputs.branch }}/version.json
wget https://raw.githubusercontent.com/${{ env.EMONCMS_SRC }}/${{ env.EMONCMS_BRANCH }}/version.json
version=$(cat version.json | jq --raw-output '.version')
echo $version
echo "version=$version" >> "$GITHUB_OUTPUT"

# Build and push Docker image
- name: Set image tags
id: tags
run: |
VERSION="${{ steps.emoncms_version.outputs.version }}"
if [ "${{ github.event_name }}" = "pull_request" ]; then
TAGS="ghcr.io/${{ github.repository_owner }}/emoncms:pr-${{ github.event.number }}"
elif [ "${{ steps.check_dockerhub.outputs.available }}" = "true" ]; then
TAGS="openenergymonitor/emoncms:latest,openenergymonitor/emoncms:${VERSION}"
else
TAGS="ghcr.io/${{ github.repository_owner }}/emoncms:latest,ghcr.io/${{ github.repository_owner }}/emoncms:${VERSION}"
fi
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./web
build-args: |
"BUILD_FROM=php:${{ inputs.php_version }}-apache"
"EMONCMS_SRC=https://github.com/${{ inputs.emoncms_src }}"
"BRANCH=${{ inputs.branch }}"
"BUILD_FROM=php:${{ env.PHP_VERSION }}-apache"
"EMONCMS_SRC=https://github.com/${{ env.EMONCMS_SRC }}"
"BRANCH=${{ env.EMONCMS_BRANCH }}"
push: true
tags: |
openenergymonitor/emoncms:latest
openenergymonitor/emoncms:${{ steps.emoncms_version.outputs.version }}
tags: ${{ steps.tags.outputs.tags }}
12 changes: 8 additions & 4 deletions default.docker-env
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Default docker enviroment variables, change in production enviroment

# MySQL database
# General
TZ=Europe/London
EMONCMS_DATADIR=/var/opt/emoncms
EMONCMS_LOG_LEVEL=2

# MySQL database
MYSQL_HOST=db
MYSQL_PORT=3306
MYSQL_DATABASE=emoncms
Expand All @@ -13,11 +18,10 @@ MYSQL_INITDB_SKIP_TZINFO=true
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'
REDIS_BUFFER=1

# MQTT (needs to be running elsewhere)
# MQTT
MQTT_ENABLED=true
MQTT_HOST=mqtt
MQTT_CLIENTID=emoncmsmqtt
Expand Down
1 change: 0 additions & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# dev enviroment setup

version: '2'
services:

web:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# production / deployment / clean testing enviroment setup

version: '2'
services:

web:
Expand Down
31 changes: 22 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Base docker compose, added to by docker-compose.override or docker-compose.prod. See Readme.md

version: '2'

services:
# PHP & apache container using offical Docker PHP iamge
# PHP & apache container with s6-overlay managing web server and background workers
web:
# If pre-built image from docker hub exists then use that (docker pull openenergymonitor/emoncms:latest) if not build container see web/Dockerflile
image: openenergymonitor/emoncms:latest
build: web/.
volumes:
# mount docker volumes persistant inside docker container
- emon-phpfina:/var/opt/emoncms/phpfina
- emon-phptimeseries:/var/opt/emoncms/phptimeseries
links:
- db
- redis
- mqtt
depends_on:
redis:
condition: service_healthy

db:
image: mariadb:11.0
Expand All @@ -34,23 +33,37 @@ services:
image: redis:7.0
volumes:
- emon-redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s
timeout: 3s
retries: 15
start_period: 5s
logging:
driver: json-file
options:
max-size: "10m"


# No local image build: extra layers on eclipse-mosquitto can hit BuildKit "max depth exceeded"
# on some Docker Desktop setups. Config + passwd are applied at container start (see mqtt/setup.sh).
mqtt:
image: eclipse-mosquitto:2.0
build: mqtt/.
volumes:
- ./mqtt/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
command:
- /bin/sh
- -c
- |
touch /mosquitto/config/passwd
/usr/bin/mosquitto_passwd -b /mosquitto/config/passwd emonpi emonpimqtt2016
exec /usr/sbin/mosquitto -c /mosquitto/config/mosquitto.conf
restart: always
logging:
driver: json-file
options:
max-size: "10m"

volumes:
emon-phpfiwa:
driver: local
emon-phpfina:
driver: local
emon-phptimeseries:
Expand Down
5 changes: 0 additions & 5 deletions mqtt/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions mqtt/setup.sh

This file was deleted.

Loading