code-server: php-cli initial release

code-server: php-cli
Adding php-cli and composer to code-server container
This commit is contained in:
Christoph Friedrich
2024-03-13 09:01:20 +01:00
committed by Christoph Friedrich
parent 9d6b690c28
commit 148e54bc13
24 changed files with 155 additions and 104 deletions
@@ -0,0 +1,76 @@
#!/usr/bin/with-contenv bash
PHP_VERSION=${PHP_VERSION:=8.2}
HAS_PHP="no"
if command -v php${PHP_VERSION} &> /dev/null; then
HAS_PHP="yes"
fi
if [ "${HAS_PHP}" = "no" ]; then
echo "**** Installing PHP ${PHP_VERSION} ****"
if [ ! -f "/etc/apt/sources.list.d/php8source.list" ]; then
echo "**** Setting up APT repository ****"
source /etc/lsb-release
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c" | gpg --dearmor | tee /usr/share/keyrings/php8.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/php8.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu ${DISTRIB_CODENAME} main" \
> /etc/apt/sources.list.d/php8source.list
apt-get update
fi
if apt-cache show php${PHP_VERSION}-cli &> /dev/null; then
echo "\
php${PHP_VERSION}-cli" >> /mod-repo-packages-to-install.list
HAS_PHP="yes"
else
echo "** PHP ${PHP_VERSION} not found! (please specify minor version too!) **"
fi
else
echo "**** PHP ${PHP_VERSION} already installed, skipping ****"
fi
if [ "${HAS_PHP}" = "yes" ]; then
if [ -z "${PHP_EXTENSIONS+x}" ]; then
echo "**** No PHP extensions to install ****"
exit 0
fi
IFS='|'
PHP_EXTENSIONS=(${PHP_EXTENSIONS})
for EXT in "${PHP_EXTENSIONS[@]}"; do
if apt-cache show php${PHP_VERSION}-${EXT} &> /dev/null; then
echo "**** Installing PHP extension php${PHP_VERSION}-${EXT} ****"
echo "\
php${PHP_VERSION}-${EXT}" >> /mod-repo-packages-to-install.list
else
echo "**** PHP extension php${PHP_VERSION}-${EXT} not found! ****"
fi
done
else
echo "**** PHP ${PHP_VERSION} is not installed! Check log! ****"
fi
if [ "${ENABLE_COMPOSER}" = "yes" ] && [ "${HAS_PHP}" = yes ]; then
echo "**** Installing composer dependencies ****"
if ! command -v unrar &> /dev/null; then
echo "\
unrar" >> /mod-repo-packages-to-install.list
fi
if ! command -v unzip &> /dev/null; then
echo "\
unzip" >> /mod-repo-packages-to-install.list
fi
if ! command -v 7z &> /dev/null; then
echo "\
p7zip-full\
p7zip-rar" >> /mod-repo-packages-to-install.list
fi
fi
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mod-code-server-php-cli-add-package/run
@@ -0,0 +1,41 @@
#!/usr/bin/with-contenv bash
echo "**** Setting up PHP configuration files ****"
if [ ! -d /config/.php ]; then
cp -rf /etc/php /config/.php
chown -R abc:abc /config/.php
fi
rm -rf /etc/php
ln -s /config/.php /etc/php
if ! [ "${ENABLE_COMPOSER}" = "yes" ]; then
echo "**** Composer will not be installed ****"
exit 0
fi
echo "**** Installing Composer ****"
if ! command -v php &> /dev/null; then
echo "** Missing installed PHP! **"
exit 127;
fi
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
echo "** ERROR: Invalid installer checksum **"
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
if [ "${RESULT}" = "0" ]; then
echo "** Installing composer system wide **"
mv composer.phar /usr/local/bin/composer
fi
exit $RESULT
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mod-code-server-php-cli-install/run
@@ -1,30 +0,0 @@
#!/usr/bin/with-contenv bash
# This is the init file used for adding os or pip packages to install lists.
# It takes advantage of the built-in init-mods-package-install init script that comes with the baseimages.
# If using this, we need to make sure we set this init as a dependency of init-mods-package-install so this one runs first
if ! command -v apprise; then
echo "**** Adding apprise and its deps to package install lists ****"
echo "apprise" >> /mod-pip-packages-to-install.list
## Ubuntu
if [ -f /usr/bin/apt ]; then
echo "\
python3 \
python3-pip \
runc" >> /mod-repo-packages-to-install.list
fi
# Alpine
if [ -f /sbin/apk ]; then
echo "\
cargo \
libffi-dev \
openssl-dev \
python3 \
python3-dev \
python3 \
py3-pip" >> /mod-repo-packages-to-install.list
fi
else
echo "**** apprise already installed, skipping ****"
fi
@@ -1 +0,0 @@
/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/run
@@ -1,8 +0,0 @@
#!/usr/bin/with-contenv bash
# This is an install script that is designed to run after init-mods-package-install
# so it can take advantage of packages installed
# init-mods-end depends on this script so that later init and services wait until this script exits
echo "**** Setting up apprise ****"
apprise blah blah
@@ -1 +0,0 @@
/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/run
@@ -1,7 +0,0 @@
#!/usr/bin/with-contenv bash
# This is an example service that would run for the mod
# It depends on init-services, the baseimage hook for start of all longrun services
exec \
s6-setuidgid abc run my app
@@ -1 +0,0 @@
longrun