Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaofeng1227 committed Oct 25, 2024
2 parents ea73c29 + 0abb30b commit ec283ee
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 47 deletions.
2 changes: 1 addition & 1 deletion apps/aria2/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions apps/ckan/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# About

This folder includes files mount to container and used by Websoft9
34 changes: 34 additions & 0 deletions apps/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
47 changes: 46 additions & 1 deletion apps/php/Notes.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
# PHP
# 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
```
5 changes: 3 additions & 2 deletions apps/php/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions apps/php/src/apt_install.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 12 additions & 16 deletions apps/php/src/cmd.sh
Original file line number Diff line number Diff line change
@@ -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 "<?php phpinfo(); ?>" > /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 "<?php phpinfo(); ?>" > /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
15 changes: 15 additions & 0 deletions apps/php/src/extensions.ini
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions apps/php/src/opcache_recommended.ini

This file was deleted.

18 changes: 0 additions & 18 deletions apps/php/src/os_packages.sh

This file was deleted.

10 changes: 9 additions & 1 deletion apps/php/src/php_extra.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
11 changes: 11 additions & 0 deletions apps/php/src/php_extension.sh → apps/php/src/php_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec283ee

Please sign in to comment.