From bda9b3a4631413634a703042c0fcf7ad887b2419d532f379bb711e04bfd61ab7 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Wed, 10 Aug 2022 12:05:21 +0000 Subject: [PATCH] Accepting request 994320 from home:kukuk:container OBS-URL: https://build.opensuse.org/request/show/994320 OBS-URL: https://build.opensuse.org/package/show/devel:microos:containers/cups-image?expand=0&rev=1 --- .gitattributes | 23 +++++++++++++++++ .gitignore | 1 + Dockerfile | 60 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 36 ++++++++++++++++++++++++++ _service | 10 ++++++++ cups-image.changes | 4 +++ docker-entrypoint.sh | 12 +++++++++ 7 files changed, 146 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 _service create mode 100644 cups-image.changes create mode 100644 docker-entrypoint.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aac523f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: MIT +#!BuildTag: opensuse/cups:%PKG_VERSION% +#!BuildTag: opensuse/cups:latest +#!BuildTag: opensuse/cups:%PKG_VERSION%-%RELEASE% +FROM opensuse/tumbleweed:latest + +MAINTAINER openSUSE (https://www.opensuse.org/) + +# Define labels according to https://en.opensuse.org/Building_derived_containers +# labelprefix=org.opensuse.application.cups +LABEL org.opencontainers.image.title="openSUSE Tumbleweed Cups Server Container Image" +LABEL org.opencontainers.image.description="Cups Server, based on the SLE Base Container Image." +LABEL org.opencontainers.image.version="%PKG_VERSION%" +LABEL org.opencontainers.image.url="https://www.opensuse.org" +LABEL org.opencontainers.image.created="%BUILDTIME%" +LABEL org.opencontainers.image.vendor="openSUSE Project" +LABEL org.opensuse.reference="registry.opensuse.org/opensuse/cups:%PKG_VERSION%-%RELEASE%" +LABEL org.openbuildservice.disturl="%DISTURL%" + +LABEL com.suse.release-stage="released" +# endlabelprefix + +RUN set -euo pipefail; zypper -n in --no-recommends cups manufacturer-PPDs OpenPrintingPPDs; zypper -n clean; rm -rf /var/log/* + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["/usr/sbin/cupsd", "-f"] + +COPY docker-entrypoint.sh /usr/local/bin/ +RUN set -euo pipefail; chmod 755 /usr/local/bin/docker-entrypoint.sh + +# Add user and disable sudo password checking +RUN useradd \ + --groups=root \ + --create-home \ + --shell=/bin/bash \ + admin + +# log to stderr +RUN set -euo pipefail; \ + sed -i -e "s|^AccessLog .*|AccessLog stderr|g" \ + -e "s|^ErrorLog .*|ErrorLog stderr|g" \ + -e "s|^PageLog .*|PageLog stderr|g" \ + /etc/cups/cups-files.conf + +# enable access to CUPS +RUN set -euo pipefail; /usr/sbin/cupsd \ + && while [ ! -f /var/run/cups/cupsd.pid ]; do sleep 1; done \ + && cupsctl --remote-admin --remote-any --share-printers \ + && kill $(cat /var/run/cups/cupsd.pid) \ + && echo "ServerAlias *" >> /etc/cups/cupsd.conf + +# copy /etc/cups for skeleton usage +RUN set -euo pipefail; cp -rp /etc/cups /etc/cups-skel + +# volumes +VOLUME /etc/cups + +# port +EXPOSE 631 + diff --git a/README.md b/README.md new file mode 100644 index 0000000..bfb4728 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# CUPS Docker Image + +## Description + +This container image contains the latest cups server from openSUSE Tumbleweed. + +## Usage + +### Start the container + +```bash + +podman run -d --rm -p 631:631 --name cups registry.opensuse.org/opensuse/cups:latest + +``` + +### Configuration + +This CUPS container comes with a default cups configuration which allows remote access for adminitration. An own configuration can be provided as volume: `-v /srv/cups:/etc/cups`, where the example assumes you have your cups configuration stored in `/srv/cups`. + +For further configuration, login to the CUPS web interface on port 631 (e.g. +`https://localhost:631`) and configure CUPS to your need. +*IMPORTANT*: you need to use `https://`, else cups will do a wrong redirect! + +The default administration account is: `admin` + +For security reasons there is no default password, it has to be set with +the environment variable _ADMIN_PASSWORD_. + +```bash + +podman run -d --rm -p 631:631 -v /srv/cups:/etc/cups -e ADMIN_PASSWORD=mySecretPassword --name cups registry.opensuse.org/opensuse/cups:latest + +``` + + diff --git a/_service b/_service new file mode 100644 index 0000000..df87053 --- /dev/null +++ b/_service @@ -0,0 +1,10 @@ + + + + + Dockerfile + %PKG_VERSION% + patch + cups + + diff --git a/cups-image.changes b/cups-image.changes new file mode 100644 index 0000000..2e8d94b --- /dev/null +++ b/cups-image.changes @@ -0,0 +1,4 @@ +------------------------------------------------------------------- +Wed Aug 10 08:30:08 UTC 2022 - Thorsten Kukuk + +- Initial version diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..347fd28 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash -e + +if [ -n "${ADMIN_PASSWORD}" ]; then + echo -e "${ADMIN_PASSWORD}\n${ADMIN_PASSWORD}" | passwd admin +fi + +if [ ! -f /etc/cups/cupsd.conf ]; then + cp -rpn /etc/cups-skel/* /etc/cups/ +fi + +exec "$@" +