commit 883eebe6fbf617a2e7932efe6ea4d1e4a94ffa03 Author: Florian Schwab Date: Sat Jul 6 13:53:30 2019 +0200 initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65fb80f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/qemu-*-static diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..503df05 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,108 @@ +image: docker:stable +services: + - docker:dind + +stages: + - build + - release + +variables: + QEMU_VERSION: v4.0.0-5 + +before_script: + - mkdir -p /root/.docker || true + - echo '{"experimental":"enabled"}' > /root/.docker/config.json + - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} + +build-amd64: + stage: build + script: + - wget https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-x86_64-static -O qemu-x86_64-static + - chmod 554 qemu-*-static + - docker run --rm --privileged multiarch/qemu-user-static:register --reset + - docker build --build-arg ARCH=amd64 -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 . + - docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 + +build-arm32v6: + stage: build + script: + - wget https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-arm-static -O qemu-arm-static + - chmod 554 qemu-*-static + - docker run --rm --privileged multiarch/qemu-user-static:register --reset + - docker build --build-arg ARCH=arm32v6 -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 . + - docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 + +build-arm32v7: + stage: build + script: + - wget https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-arm-static -O qemu-arm-static + - chmod 554 qemu-*-static + - docker run --rm --privileged multiarch/qemu-user-static:register --reset + - docker build --build-arg ARCH=arm32v7 -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 . + - docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 + +build-arm64v8: + stage: build + script: + - wget https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-aarch64-static -O qemu-aarch64-static + - chmod 554 qemu-*-static + - docker run --rm --privileged multiarch/qemu-user-static:register --reset + - docker build --build-arg ARCH=arm64v8 -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 . + - docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 + +release: + stage: release + script: + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 ${CI_REGISTRY_IMAGE}:latest-amd64 + - docker push ${CI_REGISTRY_IMAGE}:latest-amd64 + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 ${CI_REGISTRY_IMAGE}:latest-arm32v6 + - docker push ${CI_REGISTRY_IMAGE}:latest-arm32v6 + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 ${CI_REGISTRY_IMAGE}:latest-arm32v7 + - docker push ${CI_REGISTRY_IMAGE}:latest-arm32v7 + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 ${CI_REGISTRY_IMAGE}:latest-arm64v8 + - docker push ${CI_REGISTRY_IMAGE}:latest-arm64v8 + - docker manifest create ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 + - docker manifest annotate --os linux --arch amd64 ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 + - docker manifest annotate --os linux --arch arm --variant v6 ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 + - docker manifest annotate --os linux --arch arm --variant v7 ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 + - docker manifest annotate --os linux --arch arm64 --variant v8 ${CI_REGISTRY_IMAGE}:latest ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 + - docker manifest push ${CI_REGISTRY_IMAGE}:latest + only: + - master + - tags + - schedules + +dockerhub: + stage: release + before_script: + - mkdir -p /root/.docker || true + - echo '{"experimental":"enabled"}' > /root/.docker/config.json + - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} + - docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD} ${DOCKERHUB_REGISTRY} + script: + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-amd64 ${DOCKERHUB_IMAGE}:latest-amd64 + - docker push ${DOCKERHUB_IMAGE}:latest-amd64 + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v6 ${DOCKERHUB_IMAGE}:latest-arm32v6 + - docker push ${DOCKERHUB_IMAGE}:latest-arm32v6 + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm32v7 ${DOCKERHUB_IMAGE}:latest-arm32v7 + - docker push ${DOCKERHUB_IMAGE}:latest-arm32v7 + - docker pull ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 + - docker tag ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}-arm64v8 ${DOCKERHUB_IMAGE}:latest-arm64v8 + - docker push ${DOCKERHUB_IMAGE}:latest-arm64v8 + - docker manifest create ${DOCKERHUB_IMAGE}:latest ${DOCKERHUB_IMAGE}:latest-amd64 ${DOCKERHUB_IMAGE}:latest-arm32v6 ${DOCKERHUB_IMAGE}:latest-arm32v7 ${DOCKERHUB_IMAGE}:latest-arm64v8 + - docker manifest annotate --os linux --arch amd64 ${DOCKERHUB_IMAGE}:latest ${DOCKERHUB_IMAGE}:latest-amd64 + - docker manifest annotate --os linux --arch arm --variant v6 ${DOCKERHUB_IMAGE}:latest ${DOCKERHUB_IMAGE}:latest-arm32v6 + - docker manifest annotate --os linux --arch arm --variant v7 ${DOCKERHUB_IMAGE}:latest ${DOCKERHUB_IMAGE}:latest-arm32v7 + - docker manifest annotate --os linux --arch arm64 --variant v8 ${DOCKERHUB_IMAGE}:latest ${DOCKERHUB_IMAGE}:latest-arm64v8 + - docker manifest push ${DOCKERHUB_IMAGE}:latest + only: + - master + - tags + - schedules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d48268c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# Base image +ARG ARCH=amd64 +FROM $ARCH/debian:buster-slim + +# Prepare multi arch build +COPY qemu-* /usr/bin/ + +# Maintainer +MAINTAINER Florian Schwab + +# 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 \ + && 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 + +# disable sudo password checking +RUN echo 'print ALL=(ALL:ALL) ALL' >> /etc/sudoers + +# enable access to CUPS +RUN /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) + +# cleanup +RUN rm -f /usr/bin/qemu-*-static /app/qemu-*-static + +# volumes +VOLUME ["/etc/cups/printers.conf"] +VOLUME ["/etc/cups/ppd"] + +# ports +EXPOSE 631 + +# default command +CMD ["/usr/sbin/cupsd", "-f"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9687ead --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Florian Schwab + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..228eaf0 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# CUPS Docker Image + +## 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 +``` diff --git a/qemu-dummy-static b/qemu-dummy-static new file mode 100755 index 0000000..72726f9 --- /dev/null +++ b/qemu-dummy-static @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Dummy QEMU wrapper to allow builds without specifing an architecture."