From 604d691cc7a3b19f139840f2f2c5a819fe2e0dd7 Mon Sep 17 00:00:00 2001 From: pifou25 Date: Sat, 11 May 2024 13:21:44 +0200 Subject: [PATCH] fix: remove php8. report previous various fixes from feature mysql.sock file chown for www-data healthcheck for supervisor starting mariadb from supervisor init db for both localhost and remote --- .github/workflows/buildx-platform.yml | 32 ++++++++++++--------------- build/Dockerfile | 31 ++++++++++++-------------- build/php.ini | 2 +- build/standalone/healthcheck.sh | 5 +++-- build/standalone/init.sh | 26 +++++++++++++--------- build/standalone/supervisord.conf | 2 +- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/.github/workflows/buildx-platform.yml b/.github/workflows/buildx-platform.yml index fb56e90..f6e3027 100644 --- a/.github/workflows/buildx-platform.yml +++ b/.github/workflows/buildx-platform.yml @@ -10,7 +10,12 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - + +env: + # used to download jeedom source + JEEDOM_REPO: "pifou25/jeedom-core" + + jobs: initStep: runs-on: ubuntu-latest @@ -41,10 +46,11 @@ jobs: fail-fast: false matrix: debian: [buster, bullseye, bookworm] - php: [7.3, 8.0, 8.2] + php: [7.3, 8.2] # linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 platform: [amd64, arm64, arm/v6, arm/v7] - jeedom: ["V4-stable", "beta"] + # no beta version for now + jeedom: ["V4-stable"] target: ["light", "full"] xdebug: [true, false] exclude: @@ -55,16 +61,10 @@ jobs: - debian: "buster" xdebug: false # exclude php version for each debian - - debian: buster - php: 8.0 - debian: buster php: 8.2 - - debian: bullseye - php: 8.2 - debian: bookworm php: 7.3 - - debian: bookworm - php: 8.0 env: REGISTRY_IMAGE: pifou25/jeedom @@ -148,7 +148,7 @@ jobs: build-args: | DEBIAN=${{ matrix.debian }} PHP=${{ matrix.php }} - JEEDOM_REPO=pifou25/jeedom-core + JEEDOM_REPO=${{ env.JEEDOM_REPO }} JEEDOM_VERSION=${{ matrix.jeedom }} XDEBUG=${{ matrix.xdebug }} platforms: linux/${{ matrix.platform }} @@ -164,6 +164,7 @@ jobs: echo "${{ matrix.debian }} PHP${{ matrix.php }} ${{ matrix.target }} branch ${{ matrix.jeedom }} debug ${{ matrix.xdebug }} has Errors! 🚀" >> $GITHUB_STEP_SUMMARY echo "Cache: buildx-${{ runner.os }}-${{ matrix.platform }}-${{ matrix.debian }} hit? ${{ steps.cache.outputs.cache-hit }}" echo "Labels: ${{ steps.meta.outputs.labels }}" >> $GITHUB_STEP_SUMMARY + exit 1 - name: Export digest ${{ env.TAG_NAME }}:${{ matrix.platform }} @@ -200,8 +201,9 @@ jobs: max-parallel: 2 matrix: debian: [buster, bullseye, bookworm] - php: [7.3, 8.0, 8.2] - jeedom: ["V4-stable", "beta"] + php: [7.3, 8.2] + # no beta version for now + jeedom: ["V4-stable"] target: ["light", "full"] xdebug: [true, false] exclude: @@ -212,16 +214,10 @@ jobs: - debian: "buster" xdebug: false # exclude php version for each debian - - debian: buster - php: 8.0 - debian: buster php: 8.2 - - debian: bullseye - php: 8.2 - debian: bookworm php: 7.3 - - debian: bookworm - php: 8.0 env: REGISTRY_IMAGE: pifou25/jeedom diff --git a/build/Dockerfile b/build/Dockerfile index 7ca1f3f..88786e1 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -50,8 +50,6 @@ LABEL org.opencontainers.image.authors pifou25 ARG JEEDOM_VERSION=V4-stable ENV JEEDOM_VERSION=${JEEDOM_VERSION} -ARG WEBSERVER_HOME=/var/www/html -ENV WEBSERVER_HOME=${WEBSERVER_HOME} ENV MYSQL_JEEDOM_DATABASE=jeedom ENV MYSQL_JEEDOM_USER=jeedom # ENV MYSQL_JEEDOM_PASSWD @@ -66,7 +64,7 @@ LABEL org.opencontainers.image.description "Jeedom Home Automation in Docker. ${ COPY motd /etc/jmotd ADD https://raw.githubusercontent.com/${JEEDOM_REPO}/${JEEDOM_VERSION}/install/bashrc /root/.bashrc # Use bash as the default shell - replace ln -sf /bin/bash /bin/sh && \ -SHELL ["/bin/bash", "-c"] +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # shellcheck disable=SC2016 RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/issue && cat /etc/motd && cat /etc/jmotd' \ >> /etc/bash.bashrc && \ @@ -116,14 +114,10 @@ RUN install-php-extensions\ mbstring mysqli pcntl pdo_mysql \ soap sockets xmlrpc zip gd opcache ssh2 -# change doc root apache configuration -RUN sed -ri -e "s!/var/www/html!${WEBSERVER_HOME}!g" /etc/apache2/sites-available/*.conf && \ - sed -ri -e "s!/var/www/!${WEBSERVER_HOME}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf - -WORKDIR ${WEBSERVER_HOME} -VOLUME ${WEBSERVER_HOME} +WORKDIR /var/www/html +VOLUME /var/www/html # copy PHP sources from previous stage -COPY --from=vendor app/ ${WEBSERVER_HOME} +COPY --from=vendor app/ . # Change uid and gid of apache to docker user uid/gid - create /tmp/jeedom RUN usermod -u 1000 www-data \ @@ -132,8 +126,8 @@ RUN usermod -u 1000 www-data \ && chmod 777 -R /tmp/jeedom \ && chown www-data:www-data -R /tmp/jeedom -VOLUME ${WEBSERVER_HOME}/backup -VOLUME ${WEBSERVER_HOME}/log +VOLUME /var/www/html/backup +VOLUME /var/www/html/log # install xdebug : check compatibility https://xdebug.org/docs/compat COPY xdebug.ini /tmp/xdebug.ini @@ -144,8 +138,12 @@ RUN if [[ ${XDEBUG} == "true" ]] ; then \ && mv /tmp/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini ; \ fi + +# # First final image: light Jeedom with /without xdebug +# FROM base as light_jeedom +# the mysql hostname is another environment variable ENV MYSQL_HOST=db # Healthcheck for the 'light' image, just check if apache is running @@ -155,7 +153,9 @@ COPY --chmod=0775 init.sh /root/init.sh CMD ["/root/init.sh"] +# # Second final image: full standalone +# FROM base as full_jeedom ARG JEEDOM_REPO # localhost didn't work for mysql, should try 127.0.0.1 @@ -165,7 +165,7 @@ ENV MYSQL_HOST=localhost RUN groupadd -r mysql && useradd -r -g mysql mysql RUN mkdir -p '/var/run/mysqld' && \ - chown root:mysql '/var/run/mysqld' && \ + chown www-data:mysql '/var/run/mysqld' && \ chmod 774 '/var/run/mysqld' RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -q -y \ @@ -184,12 +184,9 @@ ADD https://raw.githubusercontent.com/${JEEDOM_REPO}/${JEEDOM_VERSION}/install/ ADD https://raw.githubusercontent.com/${JEEDOM_REPO}/${JEEDOM_VERSION}/install/fail2ban.jeedom.conf /etc/fail2ban/jail.d/jeedom.conf COPY php.ini /usr/local/etc/php/php.ini -RUN sed -i -e "s%WEBSERVER_HOME%${WEBSERVER_HOME}%g" /etc/apache2/conf-available/security.conf && \ - sed -i -e "s%WEBSERVER_HOME%${WEBSERVER_HOME}%g" /etc/apache2/conf-available/remoteip.conf && \ - rm /etc/apache2/conf-enabled/security.conf > /dev/null 2>&1 && \ +RUN rm /etc/apache2/conf-enabled/security.conf > /dev/null 2>&1 && \ ln -s /etc/apache2/conf-available/security.conf /etc/apache2/conf-enabled/ && \ ln -s /etc/apache2/conf-available/remoteip.conf /etc/apache2/conf-enabled/ && \ - sed -i -e "s%WEBSERVER_HOME%${WEBSERVER_HOME}%g" /etc/apache2/sites-available/000-default.conf && \ rm /etc/apache2/sites-enabled/000-default.conf > /dev/null 2>&1 && \ ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/ && \ rm /etc/apache2/conf-available/other-vhosts-access-log.conf > /dev/null 2>&1 && \ diff --git a/build/php.ini b/build/php.ini index 33b29c7..5250d4c 100644 --- a/build/php.ini +++ b/build/php.ini @@ -1045,7 +1045,7 @@ cli_server.color = On [Pdo_mysql] ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. -pdo_mysql.default_socket= +pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock [Phar] ; http://php.net/phar.readonly diff --git a/build/standalone/healthcheck.sh b/build/standalone/healthcheck.sh index 0c66262..ccbcdb1 100644 --- a/build/standalone/healthcheck.sh +++ b/build/standalone/healthcheck.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e @@ -8,7 +8,8 @@ healthcheck() { return 1 fi # check that all managed process are running - if ! supervisorctl status | grep RUNNING; then + RUNNING=$(supervisorctl status | grep RUNNING | wc -l) + if [[ $RUNNING -ne 5 ]] ; then return 1 fi return 0 diff --git a/build/standalone/init.sh b/build/standalone/init.sh index 90ca2ad..02c5a04 100644 --- a/build/standalone/init.sh +++ b/build/standalone/init.sh @@ -66,22 +66,22 @@ if [ ! -f "${WEBSERVER_HOME}/core/config/common.config.php" ]; then log_info "first run of jeedom container : configuration" cp ${WEBSERVER_HOME}/core/config/common.config.sample.php ${WEBSERVER_HOME}/core/config/common.config.php - sed -i "s/'host'/'unix_socket'/g" ${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#/${MYSQL_JEEDOM_DATABASE}/g" ${WEBSERVER_HOME}/core/config/common.config.php sed -i "s/#USERNAME#/${MYSQL_JEEDOM_USER}/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#/\/run\/mysqld\/mysqld.sock/g" ${WEBSERVER_HOME}/core/config/common.config.php - + sed -i "s/#HOST#/${MYSQL_HOST}/g" ${WEBSERVER_HOME}/core/config/common.config.php + # changes for mysql socket instead of tcp for local use + # sed -i "s/'host'/'unix_socket'/g" ${WEBSERVER_HOME}/core/config/common.config.php + # sed -i "s/#HOST#/\/run\/mysqld\/mysqld.sock/g" ${WEBSERVER_HOME}/core/config/common.config.php + + chmod 770 -R ${WEBSERVER_HOME} chown -R www-data:www-data ${WEBSERVER_HOME} mkdir -p /tmp/jeedom chmod 770 -R /tmp/jeedom chown www-data:www-data -R /tmp/jeedom - # start database - supervisorctl start mysql - # wait until db is up and running while ! mysqladmin ping -h"$MYSQL_HOST" --silent; do log_warn "Wait 2 seconds for MariaDB to start..." @@ -89,11 +89,16 @@ if [ ! -f "${WEBSERVER_HOME}/core/config/common.config.php" ]; then done log_info " ___ Création de la database SQL ${MYSQL_JEEDOM_DATABASE} pour '${MYSQL_JEEDOM_USER}'@'${MYSQL_HOST}' ... ___" - mysql_sql "DROP USER IF EXISTS '${MYSQL_JEEDOM_USER}'@'${MYSQL_HOST}';" - mysql_sql "CREATE USER '${MYSQL_JEEDOM_USER}'@'${MYSQL_HOST}' IDENTIFIED BY '${MYSQL_JEEDOM_PASSWD}';" mysql_sql "DROP DATABASE IF EXISTS ${MYSQL_JEEDOM_DATABASE};" mysql_sql "CREATE DATABASE ${MYSQL_JEEDOM_DATABASE};" - mysql_sql "GRANT ALL PRIVILEGES ON ${MYSQL_JEEDOM_DATABASE}.* TO '${MYSQL_JEEDOM_USER}'@'${MYSQL_HOST}';" + mysql_sql "DROP USER IF EXISTS '${MYSQL_JEEDOM_USER}'@'*';" + mysql_sql "CREATE USER '${MYSQL_JEEDOM_USER}'@'*' IDENTIFIED BY '${MYSQL_JEEDOM_PASSWD}';" + mysql_sql "GRANT ALL PRIVILEGES ON ${MYSQL_JEEDOM_DATABASE}.* TO '${MYSQL_JEEDOM_USER}'@'*';" + # user for @localhost + mysql_sql "DROP USER IF EXISTS '${MYSQL_JEEDOM_USER}'@'localhost';" + mysql_sql "CREATE USER '${MYSQL_JEEDOM_USER}'@'localhost' IDENTIFIED BY '${MYSQL_JEEDOM_PASSWD}';" + mysql_sql "GRANT ALL PRIVILEGES ON ${MYSQL_JEEDOM_DATABASE}.* TO '${MYSQL_JEEDOM_USER}'@'localhost';" + log_info "jeedom clean install" php ${WEBSERVER_HOME}/install/install.php mode=force @@ -134,7 +139,8 @@ if [ ! -f "${WEBSERVER_HOME}/core/config/common.config.php" ]; then fi -sysctl vm.swappiness=10 +# does NOT work inside docker container! +# sysctl vm.swappiness=10 a2dismod status a2enmod headers diff --git a/build/standalone/supervisord.conf b/build/standalone/supervisord.conf index 0683ad9..1919417 100644 --- a/build/standalone/supervisord.conf +++ b/build/standalone/supervisord.conf @@ -69,7 +69,7 @@ stderr_logfile_maxbytes=0 [program:mysql] command=mysqld_safe user=mysql -autostart=false +autostart=true autorestart=true startsecs=5 killasgroup=true