improve usability
This commit is contained in:
		@@ -9,23 +9,24 @@ stages:
 | 
			
		||||
before_script:
 | 
			
		||||
  - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
 | 
			
		||||
  - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
 | 
			
		||||
  - export DOCKER_BUILD_ARGS="--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD`"
 | 
			
		||||
 | 
			
		||||
build-amd64:
 | 
			
		||||
  stage: build
 | 
			
		||||
  script:
 | 
			
		||||
    - docker build --build-arg ARCH=amd64 -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 .
 | 
			
		||||
    - docker build --build-arg ARCH=amd64 $DOCKER_BUILD_ARGS -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 .
 | 
			
		||||
    - docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64
 | 
			
		||||
 | 
			
		||||
build-arm32v7:
 | 
			
		||||
  stage: build
 | 
			
		||||
  script:
 | 
			
		||||
    - docker build --build-arg ARCH=arm32v7 -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 .
 | 
			
		||||
    - docker build --build-arg ARCH=arm32v7 $DOCKER_BUILD_ARGS -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 .
 | 
			
		||||
    - docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7
 | 
			
		||||
 | 
			
		||||
build-arm64v8:
 | 
			
		||||
  stage: build
 | 
			
		||||
  script:
 | 
			
		||||
    - docker build --build-arg ARCH=arm64v8 -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 .
 | 
			
		||||
    - docker build --build-arg ARCH=arm64v8 $DOCKER_BUILD_ARGS -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 .
 | 
			
		||||
    - docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8
 | 
			
		||||
 | 
			
		||||
release:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										67
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -1,34 +1,49 @@
 | 
			
		||||
# Base image
 | 
			
		||||
# args
 | 
			
		||||
ARG ARCH=amd64
 | 
			
		||||
ARG VCS_REF
 | 
			
		||||
ARG BUILD_DATE
 | 
			
		||||
 | 
			
		||||
# base image
 | 
			
		||||
FROM $ARCH/debian:buster-slim
 | 
			
		||||
 | 
			
		||||
# Maintainer
 | 
			
		||||
MAINTAINER Florian Schwab <me@ydkn.io>
 | 
			
		||||
# environment
 | 
			
		||||
ENV ADMIN_PASSWORD=admin
 | 
			
		||||
 | 
			
		||||
# labels
 | 
			
		||||
LABEL maintainer="Florian Schwab <me@ydkn.io>" \
 | 
			
		||||
  org.label-schema.schema-version="1.0" \
 | 
			
		||||
  org.label-schema.name="ydkn/cups" \
 | 
			
		||||
  org.label-schema.description="Simple CUPS docker image" \
 | 
			
		||||
  org.label-schema.version="0.1" \
 | 
			
		||||
  org.label-schema.url="https://hub.docker.com/r/ydkn/cups" \
 | 
			
		||||
  org.label-schema.vcs-url="https://gitlab.com/ydkn/docker-cups" \
 | 
			
		||||
  org.label-schema.vcs-ref=$VCS_REF \
 | 
			
		||||
  org.label-schema.build-date=$BUILD_DATE
 | 
			
		||||
 | 
			
		||||
# install packages
 | 
			
		||||
RUN apt-get update \
 | 
			
		||||
  && apt-get install -y \
 | 
			
		||||
    sudo \
 | 
			
		||||
    cups \
 | 
			
		||||
    cups-bsd \
 | 
			
		||||
    cups-filters \
 | 
			
		||||
    foomatic-db-compressed-ppds \
 | 
			
		||||
    printer-driver-all \
 | 
			
		||||
    openprinting-ppds \
 | 
			
		||||
    hpijs-ppds \
 | 
			
		||||
    hp-ppd \
 | 
			
		||||
    hplip \
 | 
			
		||||
  sudo \
 | 
			
		||||
  cups \
 | 
			
		||||
  cups-bsd \
 | 
			
		||||
  cups-filters \
 | 
			
		||||
  foomatic-db-compressed-ppds \
 | 
			
		||||
  printer-driver-all \
 | 
			
		||||
  openprinting-ppds \
 | 
			
		||||
  hpijs-ppds \
 | 
			
		||||
  hp-ppd \
 | 
			
		||||
  hplip \
 | 
			
		||||
  && apt-get clean \
 | 
			
		||||
  && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
# add print user
 | 
			
		||||
RUN adduser --home /home/print --shell /bin/bash --gecos "print" --disabled-password print \
 | 
			
		||||
  && adduser print sudo \
 | 
			
		||||
  && adduser print lp \
 | 
			
		||||
  && adduser print lpadmin
 | 
			
		||||
RUN adduser --home /home/admin --shell /bin/bash --gecos "admin" --disabled-password admin \
 | 
			
		||||
  && adduser admin sudo \
 | 
			
		||||
  && adduser admin lp \
 | 
			
		||||
  && adduser admin lpadmin
 | 
			
		||||
 | 
			
		||||
# disable sudo password checking
 | 
			
		||||
RUN echo 'print ALL=(ALL:ALL) ALL' >> /etc/sudoers
 | 
			
		||||
RUN echo 'admin ALL=(ALL:ALL) ALL' >> /etc/sudoers
 | 
			
		||||
 | 
			
		||||
# enable access to CUPS
 | 
			
		||||
RUN /usr/sbin/cupsd \
 | 
			
		||||
@@ -37,12 +52,18 @@ RUN /usr/sbin/cupsd \
 | 
			
		||||
  && kill $(cat /var/run/cups/cupsd.pid) \
 | 
			
		||||
  && echo "ServerAlias *" >> /etc/cups/cupsd.conf
 | 
			
		||||
 | 
			
		||||
# copy /etc/cups for skeleton usage
 | 
			
		||||
RUN cp -rp /etc/cups /etc/cups-skel
 | 
			
		||||
 | 
			
		||||
# entrypoint
 | 
			
		||||
ADD docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
 | 
			
		||||
ENTRYPOINT [ "docker-entrypoint.sh" ]
 | 
			
		||||
 | 
			
		||||
# default command
 | 
			
		||||
CMD ["cupsd", "-f"]
 | 
			
		||||
 | 
			
		||||
# volumes
 | 
			
		||||
VOLUME ["/etc/cups/printers.conf"]
 | 
			
		||||
VOLUME ["/etc/cups/ppd"]
 | 
			
		||||
VOLUME ["/etc/cups"]
 | 
			
		||||
 | 
			
		||||
# ports
 | 
			
		||||
EXPOSE 631
 | 
			
		||||
 | 
			
		||||
# default command
 | 
			
		||||
CMD ["/usr/sbin/cupsd", "-f"]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								README.md
									
									
									
									
									
								
							@@ -1,8 +1,26 @@
 | 
			
		||||
# CUPS Docker Image
 | 
			
		||||
 | 
			
		||||
## Start the container
 | 
			
		||||
## Architectures
 | 
			
		||||
 | 
			
		||||
- amd64
 | 
			
		||||
- arm32v7
 | 
			
		||||
- arm64v8
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
### Start the container
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
touch $(pwd)/printers.conf
 | 
			
		||||
docker run -d --restart always -v $(pwd)/printers.conf:/etc/cups/printers.conf -v $(pwd)/ppd:/etc/cups/ppd ydkn/cups:latest
 | 
			
		||||
docker run -d --restart always -p 631:631 -v $(pwd):/etc/cups ydkn/cups:latest
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Configuration
 | 
			
		||||
 | 
			
		||||
Login in to CUPS web interface on port 631 (e.g. https://localhost:631) and configure CUPS to your needs.
 | 
			
		||||
Default credentials: admin / admin
 | 
			
		||||
 | 
			
		||||
To change the admin password set the environment variable _ADMIN_PASSWORD_ to your password.
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
docker run -d --restart always -p 631:631 -v $(pwd):/etc/cups -e ADMIN_PASSWORD=mySecretPassword ydkn/cups:latest
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								docker-entrypoint.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								docker-entrypoint.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
#!/bin/bash -e
 | 
			
		||||
 | 
			
		||||
echo -e "${ADMIN_PASSWORD}\n${ADMIN_PASSWORD}" | passwd admin
 | 
			
		||||
 | 
			
		||||
if [ ! -f /etc/cups/printers.conf ]; then
 | 
			
		||||
  cp -rpn /etc/cups-skel/* /etc/cups/
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
exec "$@"
 | 
			
		||||
		Reference in New Issue
	
	Block a user