Skip to content
Merged
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
90 changes: 72 additions & 18 deletions .github/workflows/docker-image-latest.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,94 @@
name: Docker Image CI latest
name: Docker Hub Image CI Builder

on:
schedule:
- cron: "00 02 * * *"
push:
# only trigger CI when push on following branches
branches:
- 'V4-stable'
- 'beta'
# this is to manually trigger the worklow
workflow_dispatch:
inputs:
logLevel:
description: 'Reason'
default: 'Manual launch'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
with:
ref: V4-stable
- name: What
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Check Out Repo
# Check out the repo, using current branch
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v3

- name: BRANCH name
# adding infos in the $GITHUB_ENV file and summary
run: |
export DOCKER_HUB_USERNAME=${{ secrets.DOCKER_HUB_USERNAME }}
bash install/OS_specific/Docker/init_workflow.sh

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/marketplace/actions/docker-setup-qemu
# set up more platforms (default = all)
uses: docker/setup-qemu-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
# https://github.com/marketplace/actions/docker-login
# login to DockerHub with secrets login & token
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx
# set up a multi-platform builder for Docker containers
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
# https://github.com/marketplace/actions/cache
# this action allows caching dependancies and build output
uses: actions/cache@v3
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build and push Jeedom on DockerHub
# https://github.com/marketplace/actions/build-and-push-docker-images
uses: docker/build-push-action@v3
# continue-on-error: true
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64,linux/arm64 # ,linux/arm/v7
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: "VERSION=${{ env.GITHUB_BRANCH }}"
tags: |
"${{ env.JEEDOM_TAGS }}"

- name: Build and push Jeedom on Debian:Buster
# https://github.com/marketplace/actions/build-and-push-docker-images
uses: docker/build-push-action@v3
# continue-on-error: true
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64 # ,linux/arm/v7
push: true
tags: jeedom/jeedom:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
"VERSION=${{ env.GITHUB_BRANCH }}"
"DEBIAN=buster"
tags: |
"${{ secrets.DOCKER_HUB_USERNAME }}/jeedom:${{ env.JEEDOM_SHORT_VERSION}}-buster"

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
run: echo ${{ steps.docker_build.outputs.digest }}
33 changes: 0 additions & 33 deletions .github/workflows/docker-image.yml

This file was deleted.

31 changes: 26 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
FROM debian:11
ARG DEBIAN=bullseye
FROM debian:${DEBIAN}
ARG DEBIAN

MAINTAINER info@jeedom.com
# ARG to build Docker images ... ENV to run Docker container
ARG WEBSERVER_HOME=/var/www/html
ENV WEBSERVER_HOME=${WEBSERVER_HOME}
ARG VERSION=V4-stable
ENV VERSION=${VERSION}

COPY install/install.sh /tmp/
RUN sh /tmp/install.sh
# labels follows opencontainers convention
LABEL org.opencontainers.image.title='Jeedom'
LABEL org.opencontainers.image.authors='info@jeedom.com'
LABEL org.opencontainers.image.url='https://www.jeedom.com/'
LABEL org.opencontainers.image.documentation='https://doc.jeedom.com/'
LABEL org.opencontainers.image.source='https://github.com/jeedom/core'
LABEL org.opencontainers.image.vendor='Jeedom SAS'
LABEL org.opencontainers.image.licenses='GNU GENERAL PUBLIC LICENSE'
LABEL org.opencontainers.image.version='${VERSION}-${DEBIAN}'
LABEL org.opencontainers.image.description='Software for home automation'

WORKDIR ${WEBSERVER_HOME}
VOLUME ${WEBSERVER_HOME}
VOLUME /var/lib/mysql

COPY install/install.sh /tmp/
RUN sh /tmp/install.sh -v ${VERSION} -w ${WEBSERVER_HOME}

EXPOSE 80
COPY install/OS_specific/Docker/init.sh /root/
CMD ["sh", "/root/init.sh"]
CMD ["sh", "/root/init.sh"]
62 changes: 43 additions & 19 deletions install/OS_specific/Docker/init.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,58 @@
#!/bin/bash
VERT="\\033[1;32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"

service_mariadb(){
service mysql $1
if [ $? -ne 0 ]; then
service mariadb $1
if [ $? -ne 0 ]; then
echo "${ROUGE}Cannot start mariadb - Cancelling${NORMAL}"
exit 1
fi
fi
return 0
}

echo 'Start init'

if [ -f /var/www/html/core/config/common.config.php ]; then
# $WEBSERVER_HOME and $VERSION env variables comes from Dockerfile

if [ -f ${WEBSERVER_HOME}/core/config/common.config.php ]; then
echo 'Jeedom is already install'
JEEDOM_INSTALL=1
else
echo 'Start jeedom installation'
JEEDOM_INSTALL=0
rm -rf /root/install.sh
wget https://raw.githubusercontent.com/jeedom/core/alpha/install/install.sh -O /root/install.sh
wget https://raw.githubusercontent.com/jeedom/core/${VERSION}/install/install.sh -O /root/install.sh
chmod +x /root/install.sh
/root/install.sh -s 6
/root/install.sh -s 6 -v ${VERSION} -w ${WEBSERVER_HOME}
if [ $(which mysqld | wc -l) -ne 0 ]; then
chown -R mysql:mysql /var/lib/mysql
mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/
service mariadb restart
service_mariadb restart
MYSQL_JEEDOM_PASSWD=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 15)
echo "DROP USER 'jeedom'@'localhost';" | mysql > /dev/null 2>&1
echo "CREATE USER 'jeedom'@'localhost' IDENTIFIED BY '${MYSQL_JEEDOM_PASSWD}';" | mysql
echo "DROP DATABASE IF EXISTS jeedom;" | mysql
echo "CREATE DATABASE jeedom;" | mysql
echo "GRANT ALL PRIVILEGES ON jeedom.* TO 'jeedom'@'localhost';" | mysql
cp /var/www/html/core/config/common.config.sample.php /var/www/html/core/config/common.config.php
sed -i "s/#PASSWORD#/${MYSQL_JEEDOM_PASSWD}/g" /var/www/html/core/config/common.config.php
sed -i "s/#DBNAME#/jeedom/g" /var/www/html/core/config/common.config.php
sed -i "s/#USERNAME#/jeedom/g" /var/www/html/core/config/common.config.php
sed -i "s/#PORT#/3306/g" /var/www/html/core/config/common.config.php
sed -i "s/#HOST#/localhost/g" /var/www/html/core/config/common.config.php
/root/install.sh -s 10
/root/install.sh -s 11
cp ${WEBSERVER_HOME}/core/config/common.config.sample.php ${WEBSERVER_HOME}/core/config/common.config.php
sed -i "s/#PASSWORD#/${MYSQL_JEEDOM_PASSWD}/g" ${WEBSERVER_HOME}/core/config/common.config.php
sed -i "s/#DBNAME#/jeedom/g" ${WEBSERVER_HOME}/core/config/common.config.php
sed -i "s/#USERNAME#/jeedom/g" ${WEBSERVER_HOME}/core/config/common.config.php
sed -i "s/#PORT#/3306/g" ${WEBSERVER_HOME}/core/config/common.config.php
sed -i "s/#HOST#/localhost/g" ${WEBSERVER_HOME}/core/config/common.config.php
/root/install.sh -s 10 -v ${VERSION} -w ${WEBSERVER_HOME}
/root/install.sh -s 11 -v ${VERSION} -w ${WEBSERVER_HOME}
fi
fi

Expand All @@ -38,31 +62,31 @@ service atd restart
if [ $(which mysqld | wc -l) -ne 0 ]; then
echo 'Starting mariadb'
chown -R mysql:mysql /var/lib/mysql /var/run/mysqld
service mariadb restart
service_mariadb restart
if [ $? -ne 0 ]; then
rm /var/lib/mysql/ib_logfile*
service mariadb restart
service_mariadb restart
fi
fi

if [ ${JEEDOM_INSTALL} -eq 0 ] && [ ! -z "${RESTOREBACKUP}" ] && [ "${RESTOREBACKUP}" != 'NO' ]; then
echo 'Need restore backup '${RESTOREBACKUP}
wget ${RESTOREBACKUP} -O /tmp/backup.tar.gz
php /var/www/html/install/restore.php backup=/tmp/backup.tar.gz
php ${WEBSERVER_HOME}/install/restore.php backup=/tmp/backup.tar.gz
rm /tmp/backup.tar.gz
if [ ! -z "${UPDATEJEEDOM}" ] && [ "${UPDATEJEEDOM}" != 'NO' ]; then
echo 'Need update jeedom'
php /var/www/html/install/update.php
php ${WEBSERVER_HOME}/install/update.php
fi
fi

echo 'All init complete'
chmod 777 /dev/tty*
chmod 777 -R /tmp
chmod 755 -R /var/www/html
chown -R www-data:www-data /var/www/html
chmod 755 -R ${WEBSERVER_HOME}
chown -R www-data:www-data ${WEBSERVER_HOME}

echo 'Start apache2'
service apache2 start

cron -f
cron -f
30 changes: 30 additions & 0 deletions install/OS_specific/Docker/init_workflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# this script is used by CI/CD Github Workflow
JEEDOM_VERSION=$(cat core/config/version)
JEEDOM_SHORT_VERSION="$(echo "$JEEDOM_VERSION" | awk -F. '{print $1"."$2}')"

if [[ "${GITHUB_REF_NAME}" == "V4-Stable" ]]; then
JEEDOM_TAGS="${DOCKER_HUB_USERNAME}/jeedom:latest,${DOCKER_HUB_USERNAME}/jeedom:$JEEDOM_SHORT_VERSION";
GITHUB_BRANCH=${GITHUB_REF_NAME};
elif [[ "${GITHUB_REF_NAME}" == "beta" ]]; then
JEEDOM_TAGS="${DOCKER_HUB_USERNAME}/jeedom:beta,${DOCKER_HUB_USERNAME}/jeedom:$JEEDOM_SHORT_VERSION";
GITHUB_BRANCH=${GITHUB_REF_NAME};
else
JEEDOM_TAGS="${DOCKER_HUB_USERNAME}/jeedom:$JEEDOM_SHORT_VERSION";
GITHUB_BRANCH=alpha;
fi

# GITHUB_ENV is the environment variables filename
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
echo "JEEDOM_VERSION=$JEEDOM_VERSION" >> $GITHUB_ENV
echo "JEEDOM_SHORT_VERSION=$JEEDOM_SHORT_VERSION" >> $GITHUB_ENV
echo "JEEDOM_TAGS=$JEEDOM_TAGS" >> $GITHUB_ENV
echo "GITHUB_BRANCH=$GITHUB_BRANCH" >> $GITHUB_ENV

# GITHUB_STEP_SUMMARY is the workflow summary
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
echo "### The Current Branch is: ${GITHUB_REF_NAME} :rocket:" >> $GITHUB_STEP_SUMMARY
echo "# Jeedom Version is: $JEEDOM_VERSION" >> $GITHUB_STEP_SUMMARY
echo "# Short Version is: $JEEDOM_SHORT_VERSION" >> $GITHUB_STEP_SUMMARY
echo "# Jeedom Tags: $JEEDOM_TAGS" >> $GITHUB_STEP_SUMMARY