fix: web access over FQDN instead localhost

This commit is contained in:
Markus Pesch 2019-05-27 20:47:15 +02:00
parent 15a90b1324
commit 68fe1931db
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
6 changed files with 38 additions and 22 deletions

View File

@ -4,11 +4,6 @@ FROM ubuntu:18.04
# Environment
ENV CUPS_ADMIN_USER=print
ENV CUPS_ADMIN_PASSWD=print
# Labels
LABEL maintainer="Markus Pesch"
# Non-Interactive
ENV DEBIAN_FRONTEND="noninteractive"
# Software installation
@ -28,7 +23,12 @@ RUN apt-get update && \
hplip && \
rm -rf /var/lib/apt/lists/*
COPY install-scripts /tmp/install-scripts
RUN for i in /tmp/install-scripts/*; do sh $i; done
# https://www.cups.org/doc/firewalls.html
EXPOSE 631
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh"]

View File

@ -13,4 +13,4 @@ build:
push: build
docker login --username ${DOCKER_USER} --password ${DOCKER_PASSWORD}
docker push ${DOCKER_USER}/cupsd:${VERSION}
docker push ${DOCKER_USER}/cupsd:${VERSION}

View File

@ -13,11 +13,12 @@ docker run \
--detach \
--env CUPS_ADMIN_USER=print \
--env CUPS_ADMIN_PASSWD=print \
--network=host \
--volume /var/run/dbus:/var/run/dbus \
--name cupsd \
--publish 631:631 \
--volume /var/run/dbus:/var/run/dbus \
volkerraschek/cupsd
```
--network=host \
or if you want to use a `docker-compose.yml`
@ -29,10 +30,12 @@ services:
environment:
- CUPS_ADMIN_USER=print
- CUPS_ADMIN_PASSWD=print
network_mode: host
image: volkerraschek/cupsd
ports:
- 631:631
restart: always
volumes:
- /var/run/dbus:/var/run/dbus
```
After starting the container, cups is available over http://localhost:631
After starting the container, cups is available over http://localhost:631 or over your FQDN.

11
entrypoint.sh Normal file → Executable file
View File

@ -1,14 +1,3 @@
#!/bin/bash
useradd \
--groups=sudo,lp,lpadmin \
--create-home \
--home-dir=/home/${CUPS_ADMIN_USER} \
--shell=/bin/bash \
${CUPS_ADMIN_USER}
echo "${CUPS_ADMIN_USER}:${CUPS_ADMIN_PASSWD}" | chpasswd
sed --in-place '/%sudo[[:space:]]/ s/ALL[[:space:]]*$/NOPASSWD:ALL/' /etc/sudoers
/usr/sbin/cupsd -f

View File

@ -0,0 +1,10 @@
#/bin/bash
/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

View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
useradd \
--groups=sudo,lp,lpadmin \
--create-home \
--home-dir=/home/${CUPS_ADMIN_USER} \
--shell=/bin/bash \
${CUPS_ADMIN_USER}
echo "${CUPS_ADMIN_USER}:${CUPS_ADMIN_PASSWD}" | chpasswd
sed --in-place '/%sudo[[:space:]]/ s/ALL[[:space:]]*$/NOPASSWD:ALL/' /etc/sudoers