From 289420531acf1a4886c06706d79593eb72c3ac52 Mon Sep 17 00:00:00 2001 From: RoboMagus <68224306+RoboMagus@users.noreply.github.com> Date: Sat, 12 Feb 2022 11:20:01 +0100 Subject: [PATCH] + Apt install pacakges provided through 'APT_PACKAGES' +Update readme --- README.md | 30 +++++++++-------------------- root/etc/cont-init.d/95-apt-get | 5 +++++ root/etc/cont-init.d/97-apt-install | 13 +++++++++++++ 3 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 root/etc/cont-init.d/95-apt-get create mode 100644 root/etc/cont-init.d/97-apt-install diff --git a/README.md b/README.md index 761c799..45da1f4 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,13 @@ -# Rsync - Docker mod for openssh-server +# APT Install - Universal Docker mod -This mod adds rsync to openssh-server, to be installed/updated during container start. +Using this mod you can install any package during starup by providing it through the environment variable `APT_PACKAGES`. This is then passed into the installation command as such: `apt install -y --no-install-recommends ${APT_PACKAGES}`. -In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync` +In any docker container arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:universal-apt-install` -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:universal-apt-install|linuxserver/mods:universal-stdout-logs` -# Mod creation instructions - -* 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. -* Edit this readme with pertinent info, delete these instructions. -* Finally edit the `.github/workflows/BuildImage.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`. -* Ask the team to create a new branch named `-`. 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. - - -## Tips and tricks - -* To decrease startup times when multiple mods are used, we have consolidated `apt-get update` down to one file. As seen in the [nodejs mod](https://github.com/linuxserver/docker-mods/tree/code-server-nodejs/root/etc/cont-init.d) -* Some images has 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) +For example, to install `rsync`, `git` and `nginx` add the following lines to your docker compose service: +```yaml +- DOCKER_MODS=linuxserver/mods:universal-apt-install +- APT_PACKAGES=rsync git nginx +``` diff --git a/root/etc/cont-init.d/95-apt-get b/root/etc/cont-init.d/95-apt-get new file mode 100644 index 0000000..8e5fe66 --- /dev/null +++ b/root/etc/cont-init.d/95-apt-get @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bash + +if [ -f /usr/bin/apt ]; then + apt-get update +fi diff --git a/root/etc/cont-init.d/97-apt-install b/root/etc/cont-init.d/97-apt-install new file mode 100644 index 0000000..52272bb --- /dev/null +++ b/root/etc/cont-init.d/97-apt-install @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bash + +# Exit if no installable packages are provided +if [ -z ${APT_PACKAGES+x} ]; then + echo "**** No APT packages to install ****" + exit 0 +fi + +if [ -f /usr/bin/apt ]; then + apt install -y --no-install-recommends ${APT_PACKAGES} +else + echo "!!! apt not found !!!" +fi