Giter Club home page Giter Club logo

Comments (7)

Zen3515 avatar Zen3515 commented on August 28, 2024 2

I've included multiple architecture support in the PR, it should be ready now.

from cups-docker.

anujdatar avatar anujdatar commented on August 28, 2024 1

Thanks for all the work. I'll test it out over the weekend and merge the request. Unfortunately I will not be able to get to this till Friday.

from cups-docker.

Zen3515 avatar Zen3515 commented on August 28, 2024

Essentially, you need to create three services.

  • avahi-daemon in /etc/services.d/avahi-daemon/run
#!/usr/bin/execlineb -P
/usr/sbin/avahi-daemon -s
  • cups in /etc/services.d/cups/run
#!/usr/bin/execlineb -P
/usr/sbin/cupsd -l
  • cups-browsed in /etc/services.d/cups-browsed/run
#!/usr/bin/execlineb -P
/usr/sbin/cups-browsed

And modify your Dockerfile accordingly.

FROM debian:stable-slim

# ENV variables
ENV DEBIAN_FRONTEND noninteractive
ENV TZ "America/New_York"
ENV CUPSADMIN admin
ENV CUPSPASSWORD password


LABEL org.opencontainers.image.source="https://github.com/anujdatar/cups-docker"
LABEL org.opencontainers.image.description="CUPS Printer Server"
LABEL org.opencontainers.image.author="Anuj Datar <[email protected]>"
LABEL org.opencontainers.image.url="https://github.com/anujdatar/cups-docker/blob/main/README.md"
LABEL org.opencontainers.image.licenses=MIT

# Install s6-overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-amd64.tar.gz /tmp/

# Install dependencies
RUN apt-get update -qq  && apt-get upgrade -qqy \
    && apt-get install -qqy \
    apt-utils \
    usbutils \
    cups \
    cups-filters \
    printer-driver-all \
    printer-driver-cups-pdf \
    printer-driver-foo2zjs \
    foomatic-db-compressed-ppds \
    openprinting-ppds \
    hpijs-ppds \
    hp-ppd \
    hplip \
    avahi-daemon \
    && tar xzf /tmp/s6-overlay-amd64.tar.gz -C / \
    && rm /tmp/s6-overlay-amd64.tar.gz \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

EXPOSE 631
EXPOSE 5353/udp

# Baked-in config file changes
RUN sed -i 's/Listen localhost:631/Listen 0.0.0.0:631/' /etc/cups/cupsd.conf && \
    sed -i 's/Browsing Off/Browsing On/' /etc/cups/cupsd.conf && \
    sed -i 's/<Location \/>/<Location \/>\n  Allow All/' /etc/cups/cupsd.conf && \
    sed -i 's/<Location \/admin>/<Location \/admin>\n  Allow All\n  Require user @SYSTEM/' /etc/cups/cupsd.conf && \
    sed -i 's/<Location \/admin\/conf>/<Location \/admin\/conf>\n  Allow All/' /etc/cups/cupsd.conf && \
    echo "ServerAlias *" >> /etc/cups/cupsd.conf && \
    echo "DefaultEncryption Never" >> /etc/cups/cupsd.conf

# back up cups configs in case used does not add their own
RUN cp -rp /etc/cups /etc/cups-bak
VOLUME [ "/etc/cups" ]

# Add s6 service definitions
COPY ./services /etc/services.d

# Command to start s6-init
CMD ["/init"]

Something along these lines

from cups-docker.

anujdatar avatar anujdatar commented on August 28, 2024

aah, okay thanks.. I do not have a lot of experience with s6, or managing multiple services inside containers. Thanks for the examples. I honestly did not get a lot of time to experiment over the holidays. I literally only got a couple of hours to work on it, I know it doesn't work yet. I'll hopefully get to work on it again in a few weeks. Work's too busy at the moment.

Anuj

from cups-docker.

Zen3515 avatar Zen3515 commented on August 28, 2024

I could help you create this PR, but I have to think about how to incorporate the existing entrypoint script for adding user based on the env variable first.

from cups-docker.

Zen3515 avatar Zen3515 commented on August 28, 2024

I've created a PR for this, the only thing left to think about is how to build s6-overlay supporting multiple architecture.

I think you could add a script file which will be executed as one of the Dockerfile steps.

Something like this.

if [[ "${TARGETARCH}" == "amd64" ]]; then
    S6_OVERLAY_ARCH="x86_64"
elif [[ "${TARGETARCH}" == "arm64" ]]; then
    S6_OVERLAY_ARCH="aarch64"
fi

wget -qO- "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz" |
    tar -C / -Jxpf -

But I'm not sure how we could know the TARGETARCH via github action, based on the quick search, it should be something like this.

...
      - name: Build and push images
        uses: docker/build-push-action@v4
        build-args: |
            TARGETARCH=${{ matrix.arch }}
...

Updated

I found it mentioned here and here, TARGETARCH will be passed automatically with BuildKit.

Which architecture to use depending on your TARGETARCH

The ${arch} part in the s6-overlay-${arch}.tar.xz tarball uses
the naming conventions of gcc, which are not the ones that Docker
uses. (Everyone does something different in this field depending on
their needs, and no solution is better than any other, but the Docker
one is worse than others because its naming is inconsistent. The gcc
convention is better for us because it simplifies our builds greatly and
makes them more maintainable.)

The following table should help you find the right tarball for you
if you're using the TARGETARCH value provided by Docker:

${TARGETARCH} ${arch} Notes
amd64 x86_64
arm64 aarch64
arm/v7 arm armv7 with soft-float
arm/v6 armhf Raspberry Pi 1
386 i686 i486 for very old hw
riscv64 riscv64
s390x s390x

from cups-docker.

Zen3515 avatar Zen3515 commented on August 28, 2024

That's ok, let me know if any changes are required.

from cups-docker.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.