From: Rudra-IITM Date: Fri, 5 Apr 2024 17:00:54 +0000 (+0530) Subject: add dockerfile and docker-compose file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fa277007a40a627664a696c3ca75aa8ae29e00c;p=thirdparty%2Fcups.git add dockerfile and docker-compose file --- diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..89c105fb26 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,35 @@ +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/go/build-context-dockerignore/ + +**/.DS_Store +**/__pycache__ +**/.venv +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +container-config diff --git a/.gitignore b/.gitignore index 1ebc7616b3..9767410098 100644 --- a/.gitignore +++ b/.gitignore @@ -162,4 +162,5 @@ /vcnet/x64 /xcode/CUPS.xcodeproj/project.xcworkspace/ /xcode/CUPS.xcodeproj/xcuserdata/ - +.DS_store +container-config \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..a8f2dfccba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# syntax=docker/dockerfile:1 + +# Use the latest Ubuntu base image +FROM ubuntu:latest + +# Set the working directory inside the container +WORKDIR /workspaces/cups + +# Update package list and upgrade existing packages +RUN apt-get update -y && apt-get upgrade -y + +# Install required dependencies for CUPS +RUN apt-get install -y \ + autoconf \ + build-essential \ + libavahi-client-dev \ + libgnutls28-dev \ + libkrb5-dev \ + libnss-mdns \ + libpam-dev \ + libsystemd-dev \ + libusb-1.0-0-dev \ + zlib1g-dev \ + openssl \ + sudo + +# Copy the current directory contents into the container's working directory +COPY . . + +# Expose port 631 for CUPS web interface +EXPOSE 631 diff --git a/INSTALL.md b/INSTALL.md index 452baadd66..0b6f113dfa 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -185,3 +185,29 @@ logging: the messages to stderr. Prefix a filename with "+" to append to an existing file. You can include a single "%d" in the filename to embed the current process ID. + +Build Using Docker +------------------ + +### Prerequisites + +- Docker installed on your system + +### Build and Run + +To build and run CUPS using Docker, follow these steps: + +1. Clone this repository to your local machine. + +2. Navigate to the root directory of the cloned repository. + +3. Run the following command to start the Docker containers in the background: + + ```bash + docker-compose up -d + ``` + +4. To start interactive terminal in container + ```bash + docker exec -it cups /bin/bash + ``` diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000000..b530a67d30 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,48 @@ +version: "3.8" + +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 + + # build CUPS + ./configure + make + make install + + # 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