Skip to content

Commit

Permalink
feat: master_phpx.x branch name from any repo
Browse files Browse the repository at this point in the history
fix: xdebug step condition
fix: init sequence and mysql permission
feat: master_phpx.x branch name from pifou25/jeedom-core
  • Loading branch information
pifou25 committed May 12, 2024
1 parent b64cd0b commit 2849a0c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 49 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/buildx-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- 'master'
- 'develop'
- 'feature/php_versions'

# no concurrency, cancel previous running workflow
concurrency:
Expand Down Expand Up @@ -68,8 +69,8 @@ jobs:

env:
REGISTRY_IMAGE: pifou25/jeedom
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'light' && '-light' || '' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }}${{ github.ref_name != 'master' && '-dev' || '' }}
TAG_LATEST_ENABLED: ${{ (matrix.debian == 'bullseye' && matrix.target == 'full' && matrix.jeedom == 'V4-stable' && matrix.target == 'full' && matrix.xdebug == 'false' && github.ref_name == 'master') }}
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'light' && '-light' || '' }}${{ matrix.xdebug && '-debug' || '' }}${{ github.ref_name != 'master' && '-dev' || '' }}
TAG_LATEST_ENABLED: ${{ (matrix.debian == 'bullseye' && matrix.target == 'full' && matrix.target == 'full' && matrix.xdebug == 'false' && github.ref_name == 'master') }}
steps:
-
name: Prepare ${{ env.TAG_NAME }}:${{ matrix.platform }}
Expand Down Expand Up @@ -149,7 +150,7 @@ jobs:
DEBIAN=${{ matrix.debian }}
PHP=${{ matrix.php }}
JEEDOM_REPO=${{ env.JEEDOM_REPO }}
JEEDOM_VERSION=${{ matrix.jeedom }}
JEEDOM_VERSION=master_php${{ matrix.php }}
XDEBUG=${{ matrix.xdebug }}
platforms: linux/${{ matrix.platform }}
cache-from: type=local,src=/tmp/.buildx-cache
Expand All @@ -161,7 +162,7 @@ jobs:
if: steps.buildJeedom.outcome != 'success'
# some debug information in case of error
run: |
echo "${{ matrix.debian }} PHP${{ matrix.php }} ${{ matrix.target }} branch ${{ matrix.jeedom }} debug ${{ matrix.xdebug }} has Errors! 🚀" >> $GITHUB_STEP_SUMMARY
echo "${{ matrix.debian }} PHP${{ matrix.php }} ${{ matrix.target }} branch master_php${{ matrix.php }} 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
Expand Down Expand Up @@ -221,9 +222,9 @@ jobs:

env:
REGISTRY_IMAGE: pifou25/jeedom
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'light' && '-light' || '' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }}${{ github.ref_name != 'master' && '-dev' || '' }}
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'light' && '-light' || '' }}${{ matrix.xdebug && '-debug' || '' }}${{ github.ref_name != 'master' && '-dev' || '' }}
GHCR_NAME: ghcr.io/${{ secrets.DOCKER_USER }}/jeedom
TAG_LATEST_ENABLED: ${{ (matrix.debian == 'bullseye' && matrix.target == 'full' && matrix.jeedom == 'V4-stable' && matrix.target == 'full' && matrix.xdebug == 'false' && github.ref_name == 'master') }}
TAG_LATEST_ENABLED: ${{ (matrix.debian == 'bullseye' && matrix.target == 'full' && matrix.target == 'full' && matrix.xdebug == 'false' && github.ref_name == 'master') }}

steps:
-
Expand Down
64 changes: 24 additions & 40 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,16 @@
ARG DEBIAN=bullseye
ARG PHP=7.3
ARG JEEDOM_REPO=jeedom/core

# prepare PHP source with dependencies
FROM composer:2.7 as vendor

ARG JEEDOM_REPO
ARG JEEDOM_VERSION=V4-stable
ENV JEEDOM_VERSION=${JEEDOM_VERSION}

WORKDIR /app
# Download and extract PHP sources
ADD https://github.com/${JEEDOM_REPO}/archive/${JEEDOM_VERSION}.zip /tmp/jeedom.zip
RUN unzip -q /tmp/jeedom.zip -d /tmp/source/ && \
find /tmp/source/ -maxdepth 1 -type d -name '*core*' -exec sh -c 'mv -T {} /app' {} \; && \
rm /tmp/jeedom.zip && \
rm -rf /app/vendor /app/install/.htaccess
COPY install.htaccess ./install/.htaccess

# run composer for dependancies
RUN composer install \
--no-interaction \
--no-plugins \
--no-scripts \
--no-dev \
--prefer-dist


# Build with 3 stages, 2 targets :
# Build with 3 stages, 2 targets :
# first stage 'base' is common to 2 following targets
# 'light_jeedom': no daemon, only apache+php
# 'full_jeedom': standalone with all required daemons
#
# Debian version: buster / bullseye / bookworm
ARG DEBIAN
# PHP version required for bookworm is 8 minimum
ARG PHP
ARG DEBIAN=bullseye
# PHP version required for bookworm is 8.2
# bullseye and buster : 7.3
ARG PHP=7.3
FROM php:${PHP}-apache-${DEBIAN} as base
ARG DEBIAN
ARG PHP
ARG JEEDOM_REPO
# optional XDEBUG arg to add xdebug packages and configuration
ARG XDEBUG

Expand All @@ -48,6 +19,10 @@ LABEL org.opencontainers.image.source https://github.com/pifou25/docker-jeedom
LABEL org.opencontainers.artifact.description "Jeedom Home Automation in Docker"
LABEL org.opencontainers.image.authors pifou25

# repo: jeedom/core or pifou25/jeedom-core
ARG JEEDOM_REPO=jeedom/core
# branch name: V4-stable or beta
# or master_php7.3 master_php8.2
ARG JEEDOM_VERSION=V4-stable
ENV JEEDOM_VERSION=${JEEDOM_VERSION}
ENV MYSQL_JEEDOM_DATABASE=jeedom
Expand Down Expand Up @@ -116,8 +91,18 @@ RUN install-php-extensions\

WORKDIR /var/www/html
VOLUME /var/www/html
# copy PHP sources from previous stage
COPY --from=vendor app/ .

# Download and extract PHP sources from $repo:$branch
ADD https://github.com/${JEEDOM_REPO}/archive/${JEEDOM_VERSION}.zip /tmp/jeedom.zip
RUN unzip -q /tmp/jeedom.zip -d /tmp/source/ && \

Check failure on line 97 in build/Dockerfile

View workflow job for this annotation

GitHub Actions / initStep

SC2156 warning: Injecting filenames is fragile and insecure. Use parameters.
find /tmp/source/ -maxdepth 1 -type d -name '*core*' -exec sh -c 'mv -T {} /var/www/html' {} \; && \
rm /tmp/jeedom.zip && \
rm -rf /app/vendor /app/install/.htaccess
COPY install.htaccess ./install/.htaccess

# download & run composer for dependancies
COPY --from=composer/composer:latest-bin /composer /usr/bin/composer
RUN composer install --no-progress --no-interaction --no-dev

# Change uid and gid of apache to docker user uid/gid - create /tmp/jeedom
RUN usermod -u 1000 www-data \
Expand All @@ -129,7 +114,8 @@ RUN usermod -u 1000 www-data \
VOLUME /var/www/html/backup
VOLUME /var/www/html/log

# install xdebug : check compatibility https://xdebug.org/docs/compat
# install xdebug-3.0.4 for php7.3 and 3.3.2 for php8.2
# check https://xdebug.org/docs/compat
COPY xdebug.ini /tmp/xdebug.ini
RUN if [[ ${XDEBUG} == "true" ]] ; then \
pecl install redis-5.3.4 \
Expand All @@ -138,8 +124,6 @@ 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
Expand Down Expand Up @@ -175,7 +159,7 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
supervisor \
&& rm -rf /var/lib/apt/lists/*

# customization from official ${JEEDOM_REPO} repo
# customization from ${JEEDOM_REPO} repo
COPY standalone/supervisord.conf /etc/supervisor/supervisord.conf
COPY standalone/jeedom_my.cnf /etc/mysql/conf.d/jeedom_my.cnf
ADD https://raw.githubusercontent.com/${JEEDOM_REPO}/${JEEDOM_VERSION}/install/apache_security /etc/apache2/conf-available/security.conf
Expand Down
4 changes: 1 addition & 3 deletions build/standalone/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ if [ ! -f "${WEBSERVER_HOME}/core/config/common.config.php" ]; then
# 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
Expand All @@ -99,7 +98,6 @@ if [ ! -f "${WEBSERVER_HOME}/core/config/common.config.php" ]; then
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
if [ $? -ne 0 ]; then
Expand Down

0 comments on commit 2849a0c

Please sign in to comment.