-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
154 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters