forked from OpenPrinting/cups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
41 lines (35 loc) · 1.22 KB
/
docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
services:
cups:
build:
context: .
dockerfile: Dockerfile
container_name: cups
# Command to be executed when the container starts
command:
- /bin/bash
- -c
- |
# Add a new user 'admin' with password 'admin'
useradd -m --create-home --password $(echo 'admin' | openssl passwd -1 -stdin) -f 0 admin
# Create a new group 'lpadmin'
groupadd lpadmin
# Add the user 'admin' to the 'lpadmin' group
usermod -aG lpadmin admin
# Grant sudo privileges to the user 'admin'
echo 'admin ALL=(ALL:ALL) ALL' >> /etc/sudoers
# Start the CUPS daemon for remote access
/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 \
&& service cups start \
&& /usr/sbin/cupsd -f
# Expose port 631 for CUPS web interface
ports:
- "631:631"
# Bind mount for cups config files and logs
volumes:
- .:/workspaces/cups
- ./container-config:/etc/cups
- ./container-config/logs:/var/log/cups