From 933f7c6e5a562c078aa8acc2c5bde778e60e2332 Mon Sep 17 00:00:00 2001 From: shanjiantao Date: Thu, 9 Jan 2025 11:32:52 +0800 Subject: [PATCH] Add phpmyadmin 5.2.1 --- library/phpmyadmin/5.2.1/Makefile | 28 ++ .../phpmyadmin/5.2.1/fpm-alpine/Dockerfile | 133 ++++++++++ .../5.2.1/fpm-alpine/config.inc.php | 246 ++++++++++++++++++ .../5.2.1/fpm-alpine/docker-entrypoint.sh | 57 ++++ .../phpmyadmin/5.2.1/fpm-alpine/helpers.php | 51 ++++ library/phpmyadmin/5.2.1/fpm/Dockerfile | 150 +++++++++++ library/phpmyadmin/5.2.1/fpm/config.inc.php | 246 ++++++++++++++++++ .../phpmyadmin/5.2.1/fpm/docker-entrypoint.sh | 57 ++++ library/phpmyadmin/5.2.1/fpm/helpers.php | 51 ++++ 9 files changed, 1019 insertions(+) create mode 100644 library/phpmyadmin/5.2.1/Makefile create mode 100644 library/phpmyadmin/5.2.1/fpm-alpine/Dockerfile create mode 100644 library/phpmyadmin/5.2.1/fpm-alpine/config.inc.php create mode 100755 library/phpmyadmin/5.2.1/fpm-alpine/docker-entrypoint.sh create mode 100644 library/phpmyadmin/5.2.1/fpm-alpine/helpers.php create mode 100644 library/phpmyadmin/5.2.1/fpm/Dockerfile create mode 100644 library/phpmyadmin/5.2.1/fpm/config.inc.php create mode 100755 library/phpmyadmin/5.2.1/fpm/docker-entrypoint.sh create mode 100644 library/phpmyadmin/5.2.1/fpm/helpers.php diff --git a/library/phpmyadmin/5.2.1/Makefile b/library/phpmyadmin/5.2.1/Makefile new file mode 100644 index 0000000..3114c29 --- /dev/null +++ b/library/phpmyadmin/5.2.1/Makefile @@ -0,0 +1,28 @@ +# This file is generated by the template. + +REGISTRY ?=lcr.loongnix.cn +ORGANIZATION ?=library +REPOSITORY ?=phpmyadmin +TAG ?=5.2.1 +LATEST ?=true + +IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) +LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest + +default: image + +image: + docker build \ + --build-arg http_proxy=$(http_proxy) \ + --build-arg https_proxy=$(https_proxy) \ + -t $(IMAGE) \ + . + +push: + docker push $(IMAGE) + #latest image + @if [ $(LATEST) = "true" ]; \ + then \ + docker tag $(IMAGE) $(LATEST_IMAGE); \ + docker push $(LATEST_IMAGE); \ + fi diff --git a/library/phpmyadmin/5.2.1/fpm-alpine/Dockerfile b/library/phpmyadmin/5.2.1/fpm-alpine/Dockerfile new file mode 100644 index 0000000..10dac73 --- /dev/null +++ b/library/phpmyadmin/5.2.1/fpm-alpine/Dockerfile @@ -0,0 +1,133 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template +FROM php:8.4.0-fpm-alpine + +# docker-entrypoint.sh dependencies +RUN apk add --no-cache \ + bash \ + tzdata + +# Install dependencies +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + bzip2-dev \ + freetype-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + libwebp-dev \ + libxpm-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm; \ + docker-php-ext-install -j "$(nproc)" \ + bz2 \ + gd \ + mysqli \ + opcache \ + zip \ + bcmath \ + ; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --no-network --virtual .phpmyadmin-phpexts-rundeps $runDeps; \ + apk del --no-network .build-deps + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +ENV PMA_SSL_DIR /etc/phpmyadmin/ssl +ENV MAX_EXECUTION_TIME 600 +ENV MEMORY_LIMIT 512M +ENV UPLOAD_LIMIT 2048K +ENV TZ UTC +ENV SESSION_SAVE_PATH /sessions +RUN set -ex; \ + \ + { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ + } > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \ + \ + { \ + echo 'session.cookie_httponly=1'; \ + echo 'session.use_strict_mode=1'; \ + } > $PHP_INI_DIR/conf.d/session-strict.ini; \ + \ + { \ + echo 'allow_url_fopen=Off'; \ + echo 'max_execution_time=${MAX_EXECUTION_TIME}'; \ + echo 'max_input_vars=10000'; \ + echo 'memory_limit=${MEMORY_LIMIT}'; \ + echo 'post_max_size=${UPLOAD_LIMIT}'; \ + echo 'upload_max_filesize=${UPLOAD_LIMIT}'; \ + echo 'date.timezone=${TZ}'; \ + echo 'session.save_path=${SESSION_SAVE_PATH}'; \ + } > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini + +# Calculate download URL +ENV VERSION 5.2.1 +ENV SHA256 373f9599dfbd96d6fe75316d5dad189e68c305f297edf42377db9dd6b41b2557 +ENV URL https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.xz + +LABEL org.opencontainers.image.title="Official phpMyAdmin Docker image" \ + org.opencontainers.image.description="Run phpMyAdmin with Alpine, Apache and PHP FPM." \ + org.opencontainers.image.authors="The phpMyAdmin Team " \ + org.opencontainers.image.vendor="phpMyAdmin" \ + org.opencontainers.image.documentation="https://github.com/phpmyadmin/docker#readme" \ + org.opencontainers.image.licenses="GPL-2.0-only" \ + org.opencontainers.image.version="${VERSION}" \ + org.opencontainers.image.url="https://github.com/phpmyadmin/docker#readme" \ + org.opencontainers.image.source="https://github.com/phpmyadmin/docker.git" + +# Download tarball, verify it using gpg and extract +RUN set -ex; \ + apk add --no-cache --virtual .fetch-deps \ + gnupg \ + ; \ + mkdir $SESSION_SAVE_PATH; \ + mkdir -p $PMA_SSL_DIR; \ + chmod 1777 $SESSION_SAVE_PATH; \ + chmod 755 $PMA_SSL_DIR; \ + chown www-data:www-data $SESSION_SAVE_PATH; \ + chown www-data:www-data $PMA_SSL_DIR; \ + \ + export GNUPGHOME="$(mktemp -d)"; \ + export GPGKEY="3D06A59ECE730EB71B511C17CE752F178259BD92"; \ + curl -fsSL -o phpMyAdmin.tar.xz $URL; \ + curl -fsSL -o phpMyAdmin.tar.xz.asc $URL.asc; \ + echo "$SHA256 *phpMyAdmin.tar.xz" | sha256sum -c -; \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$GPGKEY" \ + || gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \ + || gpg --batch --keyserver keyserver.pgp.com --recv-keys "$GPGKEY" \ + || gpg --batch --keyserver keys.openpgp.org --recv-keys "$GPGKEY"; \ + gpg --batch --verify phpMyAdmin.tar.xz.asc phpMyAdmin.tar.xz; \ + tar -xf phpMyAdmin.tar.xz -C /var/www/html --strip-components=1; \ + mkdir -p /var/www/html/tmp; \ + chown www-data:www-data /var/www/html/tmp; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" phpMyAdmin.tar.xz phpMyAdmin.tar.xz.asc; \ + rm -r -v /var/www/html/setup/ /var/www/html/examples/ /var/www/html/js/src/ /var/www/html/babel.config.json /var/www/html/doc/html/_sources/ /var/www/html/RELEASE-DATE-$VERSION /var/www/html/CONTRIBUTING.md; \ + grep -q -F "'configFile' => ROOT_PATH . 'config.inc.php'," /var/www/html/libraries/vendor_config.php; \ + sed -i "s@'configFile' => .*@'configFile' => '/etc/phpmyadmin/config.inc.php',@" /var/www/html/libraries/vendor_config.php; \ + grep -q -F "'configFile' => '/etc/phpmyadmin/config.inc.php'," /var/www/html/libraries/vendor_config.php; \ + php -l /var/www/html/libraries/vendor_config.php; \ + chown -R www-data:www-data -R /var/www/html/; \ + apk del --no-network .fetch-deps + +# Copy configuration +COPY config.inc.php /etc/phpmyadmin/config.inc.php +RUN chown www-data:www-data -R /etc/phpmyadmin/ + +# Copy main script +COPY docker-entrypoint.sh /docker-entrypoint.sh + +ENTRYPOINT [ "/docker-entrypoint.sh" ] +CMD ["php-fpm"] diff --git a/library/phpmyadmin/5.2.1/fpm-alpine/config.inc.php b/library/phpmyadmin/5.2.1/fpm-alpine/config.inc.php new file mode 100644 index 0000000..b3a310e --- /dev/null +++ b/library/phpmyadmin/5.2.1/fpm-alpine/config.inc.php @@ -0,0 +1,246 @@ + /etc/phpmyadmin/config.secret.inc.php < $PHP_INI_DIR/conf.d/phpmyadmin-hide-php-version.ini +fi + +if [ ! -z "${PMA_CONFIG_BASE64}" ]; then + echo "Adding the custom config.inc.php from base64." + echo "${PMA_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.inc.php +fi + +if [ ! -z "${PMA_USER_CONFIG_BASE64}" ]; then + echo "Adding the custom config.user.inc.php from base64." + echo "${PMA_USER_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.user.inc.php +fi + + +get_docker_secret() { + local env_var="${1}" + local env_var_file="${env_var}_FILE" + + # Check if the variable with name $env_var_file (which is $PMA_PASSWORD_FILE for example) + # is not empty and export $PMA_PASSWORD as the password in the Docker secrets file + + if [[ -n "${!env_var_file}" ]]; then + export "${env_var}"="$(cat "${!env_var_file}")" + fi +} + +get_docker_secret PMA_USER +get_docker_secret PMA_PASSWORD +get_docker_secret MYSQL_ROOT_PASSWORD +get_docker_secret MYSQL_PASSWORD +get_docker_secret PMA_HOSTS +get_docker_secret PMA_HOST +get_docker_secret PMA_CONTROLHOST +get_docker_secret PMA_CONTROLUSER +get_docker_secret PMA_CONTROLPASS +get_docker_secret PMA_SSL +get_docker_secret PMA_SSLS + +exec "$@" diff --git a/library/phpmyadmin/5.2.1/fpm-alpine/helpers.php b/library/phpmyadmin/5.2.1/fpm-alpine/helpers.php new file mode 100644 index 0000000..fd06bcd --- /dev/null +++ b/library/phpmyadmin/5.2.1/fpm-alpine/helpers.php @@ -0,0 +1,51 @@ + /dev/null; \ + apt-mark manual $savedAptMark; \ + extdir="$(php -r 'echo ini_get("extension_dir");')"; \ + ldd "$extdir"/*.so \ + | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + ldd "$extdir"/*.so | grep -qzv "=> not found" || (echo "Sanity check failed: missing libraries:"; ldd "$extdir"/*.so | grep " => not found"; exit 1); \ + ldd "$extdir"/*.so | grep -q "libzip.so.* => .*/libzip.so.*" || (echo "Sanity check failed: libzip.so is not referenced"; ldd "$extdir"/*.so; exit 1); \ + err="$(php --version 3>&1 1>&2 2>&3)"; \ + [ -z "$err" ] || (echo "Sanity check failed: php returned errors; $err"; exit 1;); + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +ENV PMA_SSL_DIR /etc/phpmyadmin/ssl +ENV MAX_EXECUTION_TIME 600 +ENV MEMORY_LIMIT 512M +ENV UPLOAD_LIMIT 2048K +ENV TZ UTC +ENV SESSION_SAVE_PATH /sessions +RUN set -ex; \ + \ + { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ + } > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \ + \ + { \ + echo 'session.cookie_httponly=1'; \ + echo 'session.use_strict_mode=1'; \ + } > $PHP_INI_DIR/conf.d/session-strict.ini; \ + \ + { \ + echo 'allow_url_fopen=Off'; \ + echo 'max_execution_time=${MAX_EXECUTION_TIME}'; \ + echo 'max_input_vars=10000'; \ + echo 'memory_limit=${MEMORY_LIMIT}'; \ + echo 'post_max_size=${UPLOAD_LIMIT}'; \ + echo 'upload_max_filesize=${UPLOAD_LIMIT}'; \ + echo 'date.timezone=${TZ}'; \ + echo 'session.save_path=${SESSION_SAVE_PATH}'; \ + } > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini + +# Calculate download URL +ENV VERSION 5.2.1 +ENV SHA256 373f9599dfbd96d6fe75316d5dad189e68c305f297edf42377db9dd6b41b2557 +ENV URL https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.xz + +LABEL org.opencontainers.image.title="Official phpMyAdmin Docker image" \ + org.opencontainers.image.description="Run phpMyAdmin with Alpine, Apache and PHP FPM." \ + org.opencontainers.image.authors="The phpMyAdmin Team " \ + org.opencontainers.image.vendor="phpMyAdmin" \ + org.opencontainers.image.documentation="https://github.com/phpmyadmin/docker#readme" \ + org.opencontainers.image.licenses="GPL-2.0-only" \ + org.opencontainers.image.version="${VERSION}" \ + org.opencontainers.image.url="https://github.com/phpmyadmin/docker#readme" \ + org.opencontainers.image.source="https://github.com/phpmyadmin/docker.git" + +# Download tarball, verify it using gpg and extract +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + gnupg \ + dirmngr \ + ; \ + mkdir $SESSION_SAVE_PATH; \ + mkdir -p $PMA_SSL_DIR; \ + chmod 1777 $SESSION_SAVE_PATH; \ + chmod 755 $PMA_SSL_DIR; \ + chown www-data:www-data $SESSION_SAVE_PATH; \ + chown www-data:www-data $PMA_SSL_DIR; \ + \ + export GNUPGHOME="$(mktemp -d)"; \ + export GPGKEY="3D06A59ECE730EB71B511C17CE752F178259BD92"; \ + curl -fsSL -o phpMyAdmin.tar.xz $URL; \ + curl -fsSL -o phpMyAdmin.tar.xz.asc $URL.asc; \ + echo "$SHA256 *phpMyAdmin.tar.xz" | sha256sum -c -; \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$GPGKEY" \ + || gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \ + || gpg --batch --keyserver keyserver.pgp.com --recv-keys "$GPGKEY" \ + || gpg --batch --keyserver keys.openpgp.org --recv-keys "$GPGKEY"; \ + gpg --batch --verify phpMyAdmin.tar.xz.asc phpMyAdmin.tar.xz; \ + tar -xf phpMyAdmin.tar.xz -C /var/www/html --strip-components=1; \ + mkdir -p /var/www/html/tmp; \ + chown www-data:www-data /var/www/html/tmp; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" phpMyAdmin.tar.xz phpMyAdmin.tar.xz.asc; \ + rm -r -v /var/www/html/setup/ /var/www/html/examples/ /var/www/html/js/src/ /var/www/html/babel.config.json /var/www/html/doc/html/_sources/ /var/www/html/RELEASE-DATE-$VERSION /var/www/html/CONTRIBUTING.md; \ + grep -q -F "'configFile' => ROOT_PATH . 'config.inc.php'," /var/www/html/libraries/vendor_config.php; \ + sed -i "s@'configFile' => .*@'configFile' => '/etc/phpmyadmin/config.inc.php',@" /var/www/html/libraries/vendor_config.php; \ + grep -q -F "'configFile' => '/etc/phpmyadmin/config.inc.php'," /var/www/html/libraries/vendor_config.php; \ + php -l /var/www/html/libraries/vendor_config.php; \ + chown -R www-data:www-data -R /var/www/html/; \ + \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# Copy configuration +COPY config.inc.php /etc/phpmyadmin/config.inc.php +RUN chown www-data:www-data -R /etc/phpmyadmin/ + +# Copy main script +COPY docker-entrypoint.sh /docker-entrypoint.sh + +ENTRYPOINT [ "/docker-entrypoint.sh" ] +CMD ["php-fpm"] diff --git a/library/phpmyadmin/5.2.1/fpm/config.inc.php b/library/phpmyadmin/5.2.1/fpm/config.inc.php new file mode 100644 index 0000000..b3a310e --- /dev/null +++ b/library/phpmyadmin/5.2.1/fpm/config.inc.php @@ -0,0 +1,246 @@ + /etc/phpmyadmin/config.secret.inc.php < $PHP_INI_DIR/conf.d/phpmyadmin-hide-php-version.ini +fi + +if [ ! -z "${PMA_CONFIG_BASE64}" ]; then + echo "Adding the custom config.inc.php from base64." + echo "${PMA_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.inc.php +fi + +if [ ! -z "${PMA_USER_CONFIG_BASE64}" ]; then + echo "Adding the custom config.user.inc.php from base64." + echo "${PMA_USER_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.user.inc.php +fi + + +get_docker_secret() { + local env_var="${1}" + local env_var_file="${env_var}_FILE" + + # Check if the variable with name $env_var_file (which is $PMA_PASSWORD_FILE for example) + # is not empty and export $PMA_PASSWORD as the password in the Docker secrets file + + if [[ -n "${!env_var_file}" ]]; then + export "${env_var}"="$(cat "${!env_var_file}")" + fi +} + +get_docker_secret PMA_USER +get_docker_secret PMA_PASSWORD +get_docker_secret MYSQL_ROOT_PASSWORD +get_docker_secret MYSQL_PASSWORD +get_docker_secret PMA_HOSTS +get_docker_secret PMA_HOST +get_docker_secret PMA_CONTROLHOST +get_docker_secret PMA_CONTROLUSER +get_docker_secret PMA_CONTROLPASS +get_docker_secret PMA_SSL +get_docker_secret PMA_SSLS + +exec "$@" diff --git a/library/phpmyadmin/5.2.1/fpm/helpers.php b/library/phpmyadmin/5.2.1/fpm/helpers.php new file mode 100644 index 0000000..fd06bcd --- /dev/null +++ b/library/phpmyadmin/5.2.1/fpm/helpers.php @@ -0,0 +1,51 @@ +