80 lines
3.0 KiB
Docker
80 lines
3.0 KiB
Docker
# Containerfile for a CUPS print server sharing a Brother HL-4150CDN over
|
|
# IPP/AirPrint. Build with Podman:
|
|
#
|
|
# podman build -t printserver:latest .
|
|
#
|
|
# Run with host networking so mDNS (Avahi) can advertise the printer. The
|
|
# printer is described by environment variables:
|
|
#
|
|
# podman run --rm --network host \
|
|
# -e PRINTER_IP=192.168.100.7 \
|
|
# -e PRINTER_NAME=HL-4150CDN \
|
|
# --name printserver printserver:latest
|
|
#
|
|
# PRINTER_URI can be used instead of PRINTER_IP for full control:
|
|
#
|
|
# -e PRINTER_URI=lpd://192.168.100.7/binary_p1
|
|
#
|
|
# The HL-4150CDN emulates BR-Script3 (PostScript 3). Jobs are converted to
|
|
# PostScript inside CUPS and forwarded to the printer unchanged; the official
|
|
# BR-Script3 PPD turns the queue's options (tray, duplex, colour, ...) into
|
|
# PostScript "setpagedevice" instructions. No Brother vendor binaries or 32-bit
|
|
# libraries are involved.
|
|
FROM debian:bookworm-slim
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# --- Task 3.1: base system, CUPS, Avahi, DBus and conversion filters -------
|
|
# cups-filters provides the PDF/PWG/URF -> PostScript filters used for
|
|
# driverless clients (AirPrint/IPP Everywhere). Ghostscript and Poppler supply
|
|
# the underlying converters, openssl is used by the entrypoint to generate the
|
|
# IPPS certificate that AirPrint clients (macOS/iOS) validate.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
cups \
|
|
cups-client \
|
|
cups-filters \
|
|
avahi-daemon \
|
|
avahi-utils \
|
|
libnss-mdns \
|
|
dbus \
|
|
procps \
|
|
curl \
|
|
ghostscript \
|
|
poppler-utils \
|
|
ca-certificates \
|
|
openssl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# --- Task 3.2: install the BR-Script3 PostScript PPD -----------------------
|
|
# The PPD encodes every device option (paper source, duplex, colour/mono,
|
|
# media type, toner save, resolution, secure print) as PostScript
|
|
# "setpagedevice". CUPS's pstops filter injects the selected option code and
|
|
# the PPD's JCL entries wrap the job in PJL for the printer.
|
|
# The whole assets tree is copied because the directory name contains a space,
|
|
# which some COPY implementations cannot quote.
|
|
COPY assets /tmp/assets
|
|
RUN install -m 0644 \
|
|
"/tmp/assets/Brother HL-4150CDN/ppd/BR4150_2.PPD" \
|
|
/usr/share/cups/model/BR4150_2.PPD \
|
|
&& test -s /usr/share/cups/model/BR4150_2.PPD \
|
|
&& rm -rf /tmp/assets \
|
|
&& rm -f /etc/cups/printers.conf /etc/cups/printers.conf.O
|
|
|
|
COPY cupsd.conf /etc/cups/cupsd.conf
|
|
|
|
# CUPS needs the runtime directories to exist in the image.
|
|
RUN mkdir -p /run/cups /run/dbus /run/avahi-daemon /var/spool/cups /var/log/cups
|
|
|
|
# --- Task 3.5: startup script ----------------------------------------------
|
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
RUN chmod 0755 /usr/local/bin/entrypoint.sh
|
|
|
|
# --- Task 3.6: exposed ports -----------------------------------------------
|
|
# 631/tcp CUPS administration and IPP
|
|
# 5353/udp mDNS / DNS-SD for AirPrint discovery
|
|
EXPOSE 631/tcp
|
|
EXPOSE 5353/udp
|
|
|
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|