mirror of
https://github.com/linuxserver/docker-mods.git
synced 2026-03-23 00:05:28 +08:00
code-server: php-cli initial release
code-server: php-cli Adding php-cli and composer to code-server container
This commit is contained in:
parent
9d6b690c28
commit
148e54bc13
10
.github/workflows/BuildImage.yml
vendored
10
.github/workflows/BuildImage.yml
vendored
@ -3,11 +3,11 @@ name: Build Image
|
||||
on: [push, pull_request_target, workflow_dispatch]
|
||||
|
||||
env:
|
||||
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
|
||||
ENDPOINT: "linuxserver/mods" #don't modify
|
||||
BASEIMAGE: "replace_baseimage" #replace
|
||||
MODNAME: "replace_modname" #replace
|
||||
MULTI_ARCH: "true" #set to false if not needed
|
||||
GITHUB_REPO: "linuxserver/docker-mods"
|
||||
ENDPOINT: "linuxserver/mods"
|
||||
BASEIMAGE: "code-server"
|
||||
MODNAME: "php-cli"
|
||||
MULTI_ARCH: "false"
|
||||
|
||||
jobs:
|
||||
set-vars:
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
FROM scratch
|
||||
|
||||
LABEL maintainer="username"
|
||||
LABEL maintainer="Saij"
|
||||
|
||||
# copy local files
|
||||
COPY root/ /
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
## Buildstage ##
|
||||
FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage
|
||||
|
||||
RUN \
|
||||
echo "**** install packages ****" && \
|
||||
apk add --no-cache \
|
||||
curl && \
|
||||
echo "**** grab rclone ****" && \
|
||||
mkdir -p /root-layer && \
|
||||
if [ $(uname -m) = "x86_64" ]; then \
|
||||
echo "Downloading x86_64 tarball" && \
|
||||
curl -o \
|
||||
/root-layer/rclone.deb -L \
|
||||
"https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-amd64.deb"; \
|
||||
elif [ $(uname -m) = "aarch64" ]; then \
|
||||
echo "Downloading aarch64 tarball" && \
|
||||
curl -o \
|
||||
/root-layer/rclone.deb -L \
|
||||
"https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-arm64.deb"; \
|
||||
fi && \
|
||||
|
||||
# copy local files
|
||||
COPY root/ /root-layer/
|
||||
|
||||
## Single layer deployed image ##
|
||||
FROM scratch
|
||||
|
||||
LABEL maintainer="username"
|
||||
|
||||
# Add files from buildstage
|
||||
COPY --from=buildstage /root-layer/ /
|
||||
47
README.md
47
README.md
@ -1,25 +1,38 @@
|
||||
# Rsync - Docker mod for openssh-server
|
||||
# PHP-CLI - Docker mod for code-server/openvscode-server
|
||||
|
||||
This mod adds rsync to openssh-server, to be installed/updated during container start.
|
||||
This mod adds php-cli and composer to code-server/openvscode-server, to be installed/updated during container start.
|
||||
|
||||
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
|
||||
In code-server/openvscode-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-php-cli`
|
||||
|
||||
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
|
||||
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:code-server-php-cli|linuxserver/mods:code-server-mod2`
|
||||
|
||||
# Mod creation instructions
|
||||
## Installing specific PHP version
|
||||
|
||||
* Fork the repo, create a new branch based on the branch `template`.
|
||||
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
|
||||
* Inspect the `root` folder contents. Edit, add and remove as necessary.
|
||||
* After all init scripts and services are created, run `find ./ -path "./.git" -prune -o \( -name "run" -o -name "finish" -o -name "check" \) -not -perm -u=x,g=x,o=x -print -exec chmod +x {} +` to fix permissions.
|
||||
* Edit this readme with pertinent info, delete these instructions.
|
||||
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the vars for `BASEIMAGE` and `MODNAME`. Set the versioning logic and `MULTI_ARCH` if needed.
|
||||
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
|
||||
* Submit PR against the branch created by the team.
|
||||
To install a specific PHP version simply define the environment variable `PHP_VERSION` with the version of your choice. As this mod uses the `ondrej/php` repository you can choose from the available versions there.
|
||||
|
||||
As default this mod will install PHP 8.2.
|
||||
|
||||
## Tips and tricks
|
||||
Example: `PHP_VERSION=8.1`
|
||||
|
||||
* Some images have helpers built in, these images are currently:
|
||||
* [Openvscode-server](https://github.com/linuxserver/docker-openvscode-server/pull/10/files)
|
||||
* [Code-server](https://github.com/linuxserver/docker-code-server/pull/95)
|
||||
__WARNING__\
|
||||
Composer requires at least PHP 7.4 to run!
|
||||
|
||||
## Installing PHP extensions
|
||||
|
||||
To install PHP extensions simply define the environment variable `PHP_EXTENSIONS`. If you want to install multiple extensions, seperate them with `|`.
|
||||
|
||||
Example: `PHP_EXTENSIONS=simplexml|gd|zip`
|
||||
|
||||
## Enable Composer binary
|
||||
|
||||
To enable the installation of the `composer` binary, set the environment variable `ENABLE_COMPOSER` to `yes`.
|
||||
|
||||
Example: `ENABLE_COMPOSER=yes`
|
||||
|
||||
__WARNING__\
|
||||
Composer requires at least PHP 7.4 to run!
|
||||
|
||||
## PHP configuration files
|
||||
|
||||
You can find all the PHP configuration files at `/config/.php`.
|
||||
They are symlinked to `/etc/php`
|
||||
76
root/etc/s6-overlay/s6-rc.d/init-mod-code-server-php-cli-add-package/run
Executable file
76
root/etc/s6-overlay/s6-rc.d/init-mod-code-server-php-cli-add-package/run
Executable file
@ -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
|
||||
41
root/etc/s6-overlay/s6-rc.d/init-mod-code-server-php-cli-install/run
Executable file
41
root/etc/s6-overlay/s6-rc.d/init-mod-code-server-php-cli-install/run
Executable file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user