diff --git a/apps/aria2/docker-compose.yml b/apps/aria2/docker-compose.yml index 6ee3bb962..7a2993ae5 100644 --- a/apps/aria2/docker-compose.yml +++ b/apps/aria2/docker-compose.yml @@ -16,7 +16,7 @@ services: - PUID=65534 - PGID=65534 - UMASK_SET=022 - - RPC_SECRET=$W9_POWER_PASSWORD + - RPC_SECRET=$W9_RCODE - RPC_PORT=6800 - LISTEN_PORT=6888 - DISK_CACHE=64M diff --git a/apps/ckan/src/README.md b/apps/ckan/src/README.md new file mode 100644 index 000000000..cdbd7a0b9 --- /dev/null +++ b/apps/ckan/src/README.md @@ -0,0 +1,3 @@ +# About + +This folder includes files mount to container and used by Websoft9 diff --git a/apps/php/Dockerfile b/apps/php/Dockerfile new file mode 100644 index 000000000..98bc3e527 --- /dev/null +++ b/apps/php/Dockerfile @@ -0,0 +1,34 @@ +# 使用 ARG 来读取环境变量 +ARG PHP_VERSION=${W9_VERSION} + +FROM php:${PHP_VERSION} + +LABEL org.opencontainers.image.authors="https://www.websoft9.com" \ + org.opencontainers.image.description="PHP runtime by Websoft9" \ + org.opencontainers.image.source="https://github.com/Websoft9/docker-library/tree/main/apps/php" \ + org.opencontainers.image.title="php" \ + org.opencontainers.image.vendor="Websoft9 Inc." \ + org.opencontainers.image.version="${PHP_VERSION}" + +# 设置环境变量以避免交互式配置 +ENV DEBIAN_FRONTEND=noninteractive + +# 安装必要的工具,包括 crudini 和 bash +RUN apt-get update && \ + apt-get install -y \ + crudini \ + bash \ + && apt-get clean + +# 复制脚本和配置文件到容器中 +COPY src/extensions.ini /usr/local/bin/extensions.ini +COPY src/apt_install.sh /usr/local/bin/apt_install.sh +COPY src/apt_install.sh /usr/local/bin/php_install.sh + +# 给予脚本执行权限 +RUN chmod +x /usr/local/bin/apt_install.sh +RUN chmod +x /usr/local/bin/php_install.sh + +# 运行脚本 +RUN /usr/local/bin/apt_install.sh +RUN /usr/local/bin/php_install.sh \ No newline at end of file diff --git a/apps/php/Notes.md b/apps/php/Notes.md index a6a1a6276..1af9f4094 100644 --- a/apps/php/Notes.md +++ b/apps/php/Notes.md @@ -1 +1,46 @@ -# PHP \ No newline at end of file +# PHP + +## How to + +- install target apt packages by src/apt_install.sh +- install target php packages by src/php_install.sh +- upload and migration php application to container by src/cmd.sh + +## Default php modules installed of PHP image + +``` +Core +ctype +curl +date +dom +fileinfo +filter +hash +iconv +json +libxml +mbstring +mysqli +mysqlnd +openssl +pcre +PDO +pdo_sqlite +Phar +posix +random +readline +Reflection +session +SimpleXML +sodium +SPL +sqlite3 +standard +tokenizer +xml +xmlreader +xmlwriter +zlib +``` \ No newline at end of file diff --git a/apps/php/docker-compose.yml b/apps/php/docker-compose.yml index b98b0dea6..0032df506 100644 --- a/apps/php/docker-compose.yml +++ b/apps/php/docker-compose.yml @@ -5,14 +5,15 @@ services: php: container_name: ${W9_ID} image: $W9_REPO:$W9_VERSION + build: + context: . + dockerfile: DOCKERFILE restart: unless-stopped env_file: .env - command: /bin/bash -c "bash /usr/local/bin/cmd.sh && apache2-foreground" ports: - $W9_HTTP_PORT_SET:80 volumes: - source:/var/www/html - - ./src/cmd.sh:/usr/local/bin/cmd.sh #for CI - ./src/php_extra.ini:/usr/local/etc/php/conf.d/php_extra.ini #for custom php.ini - ./src/opcache_recommended.ini:/usr/local/etc/php/conf.d/opcache_recommended.ini # for custom opcache diff --git a/apps/php/src/apt_install.sh b/apps/php/src/apt_install.sh new file mode 100644 index 000000000..deef65a8b --- /dev/null +++ b/apps/php/src/apt_install.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Define the ini file +INI_FILE="/usr/local/bin/config.ini" + +# Get the packages from the ini file using crudini +packages=$(crudini --get "$INI_FILE" apt packages) + +# Convert comma-separated values to space-separated +packages=$(echo "$packages" | tr ',' ' ') + +# Install packages one by one +for package in $packages; do + echo "Start to install $package" + if apt-get install -y $package; then + echo "$package installed successfully" + else + echo "$package failed to install" + fi +done \ No newline at end of file diff --git a/apps/php/src/cmd.sh b/apps/php/src/cmd.sh index 8f9b866db..6f85f5702 100644 --- a/apps/php/src/cmd.sh +++ b/apps/php/src/cmd.sh @@ -1,25 +1,21 @@ -## This file is for your CI +## This script is always excused after PHP container running +## If you upload your PHP application source code to container, you should consider migration exist data +## Sample for you -## Install Linux packages, e.g unzip git -apt update -y && apt install unzip git -y +if [ -z "$(ls -A /var/www/html)" ]; then + echo "" > /var/www/html/index.php + chown -R www-data:www-data /var/www/html + echo "Commands executed: index.php created and ownership changed." +else + echo "/var/www/html is not empty. No actions taken." +fi -## Install install-php-extensions cli -curl -o /usr/local/bin/install-php-extensions -L https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -chmod 0755 /usr/local/bin/install-php-extensions -## Install php extension, e.g Composer, mysqli,gd,imagick -install-php-extensions @composer -install-php-extensions mysqli - -## create php sample by default -echo "" > /var/www/html/index.php - -## Install WordPress for your reference +## Install WordPress for your reference, you should improve it for migration exist data # cd /var/www/html # curl -O https://wordpress.org/latest.zip # unzip latest.zip # mv wordpress/* ./ -# chown -R www-data:www-data /var/www/html - +# chown -R www-data:www-data /var/www/html \ No newline at end of file diff --git a/apps/php/src/extensions.ini b/apps/php/src/extensions.ini new file mode 100644 index 000000000..341216f7a --- /dev/null +++ b/apps/php/src/extensions.ini @@ -0,0 +1,15 @@ +[apt] +packages=git,wget,unzip,vim + +[php-extension] + +# Install PHP extension by install-php-extensions cli: https://github.com/mlocati/docker-php-extension-installer?tab=readme-ov-file#supported-php-extensions +# It is the community CLI +install-php-extensions=@composer,mysqli + +# Config, Compile and Install PHP extension by docker-php-ext-install cli: +# It is the PHP image official cli +docker-php-ext-install=redis + +# Install PHP extension by php official pecl cli: +pecl=redis \ No newline at end of file diff --git a/apps/php/src/opcache_recommended.ini b/apps/php/src/opcache_recommended.ini deleted file mode 100644 index 8c09c2a9c..000000000 --- a/apps/php/src/opcache_recommended.ini +++ /dev/null @@ -1,8 +0,0 @@ -#/usr/local/etc/php/conf.d -# See https://secure.php.net/manual/en/opcache.installation.php - -opcache.memory_consumption=128 -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=4000 -opcache.revalidate_freq=60 -opcache.fast_shutdown=1 \ No newline at end of file diff --git a/apps/php/src/os_packages.sh b/apps/php/src/os_packages.sh deleted file mode 100644 index cf2d6aa61..000000000 --- a/apps/php/src/os_packages.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -####################---------- Description ----------- ################### -# php image is based on debian, so we can use apt-get to install packages -# this package is os level packages, which is required by php or php extension -# We should continue when install a package failed, so we use || to continue - -# You can delete any package you don't need -tools_apt="git acl mosh wget gnupg2 ca-certificates unzip bzip2 at tree vim screen pwgen htop imagemagick goaccess jq net-tools mlocate chrony gnupg dirmngr ghostscript unixodbc-dev libfreetype6-dev libjpeg-dev libpng-dev libpq-dev libwebp-dev libzip-dev libcurl4-openssl-dev libicu-dev libldap2-dev libmemcached-dev libsnmp-dev libtidy-dev libmcrypt-dev libgmp-dev libmagickwand-dev libmagickcore-dev libc-client-dev libkrb5-dev libc-client-dev libbz2-dev libxml2-dev" - -apt-get update -y 1>/dev/null 2>&1 -for package in $tools_apt; do - echo "Start to install $package" - apt-get install $package -y > /dev/null || echo "$package failed to install" -done diff --git a/apps/php/src/php_extra.ini b/apps/php/src/php_extra.ini index b6815aea4..a1f73398e 100644 --- a/apps/php/src/php_extra.ini +++ b/apps/php/src/php_extra.ini @@ -7,4 +7,12 @@ memory_limit = 600M upload_max_filesize = 900M post_max_size = 900M max_file_uploads = 200 -error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT \ No newline at end of file +error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT + + +# See https://secure.php.net/manual/en/opcache.installation.php +opcache.memory_consumption=128 +opcache.interned_strings_buffer=8 +opcache.max_accelerated_files=4000 +opcache.revalidate_freq=60 +opcache.fast_shutdown=1 \ No newline at end of file diff --git a/apps/php/src/php_extension.sh b/apps/php/src/php_install.sh similarity index 84% rename from apps/php/src/php_extension.sh rename to apps/php/src/php_install.sh index 5299b645c..3af70d935 100644 --- a/apps/php/src/php_extension.sh +++ b/apps/php/src/php_install.sh @@ -12,6 +12,17 @@ export PATH # You must confige PHP GD before other PHP extensions which is dependent on GD docker-php-ext-configure gd --with-freetype --with-jpeg=/usr --with-webp || true + +## Install install-php-extensions cli +curl -o /usr/local/bin/install-php-extensions -L https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions +chmod 0755 /usr/local/bin/install-php-extensions + +## Install php extension, e.g Composer, mysqli,gd,imagick +install-php-extensions @composer +install-php-extensions mysqli + + + # Install PHP extensions extensions=( bcmath