diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..5b3fef46f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,77 @@ +# Git files +.git +.gitignore +.gitmodules + +# Documentation +README.md +CONTRIBUTING.md +CODE_OF_CONDUCT.md +SECURITY.md +LICENSE +LICENSE_NOTICE +docs/ +mkdocs_remote.yml + +# Development files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Node.js +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# PHP dependencies (will be installed via composer in container) +vendor/ + +# Build artifacts +dist/ +build/ + +# Test files +tests/ +test/ +phpunit.xml +phpstan.neon + +# Development configuration +eslint.config.mjs +gulpfile.mjs +package-lock.json +composer.lock + +# Docker files (except the one being built) +docker-compose.yml +Dockerfile.old + +# Temporary files +tmp/ +temp/ +*.tmp + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# IDE files +*.sublime-project +*.sublime-workspace + +# Log files +*.log + +# Crowdin configuration +crowdin_config.yml + +# Installation scripts (may not be needed in container) +install-photobooth.sh diff --git a/.gitignore b/.gitignore index a5a111dde..b75c8f0e2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,25 @@ digicamcontrol/ HEAD manual/faq.* node_modules/ -private/* + +!private/data/.gitkeep +!private/data/images/.gitkeep +!private/data/keying/.gitkeep +!private/data/print/.gitkeep +!private/data/qrcodes/.gitkeep +!private/data/thumbs/.gitkeep +!private/data/test/.gitkeep +!private/data/tmp/.gitkeep + +!private/fonts/.gitkeep +!private/images/background/.gitkeep +!private/images/demo/.gitkeep +!private/images/frames/.gitkeep +!private/images/keyingBackgrounds/.gitkeep +!private/images/placeholder/.gitkeep + +!private/videos/background/.gitkeep + !private/README.md resources/css/* !resources/css/README.md diff --git a/Dockerfile b/Dockerfile index 046d607e0..acf66e35d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,97 @@ -FROM webdevops/php-apache:8.3 +# Use Ubuntu 24.04 as the base image +FROM ubuntu:24.04 -# Adjust LimitRequestLine and -# update and install dependencies -RUN echo "LimitRequestLine 12000" > /opt/docker/etc/httpd/conf.d/limits.conf \ - && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - build-essential \ - git \ - gphoto2 \ - libimage-exiftool-perl \ - rsync \ - udisks2 \ - python3 \ - ca-certificates \ - curl \ - gnupg \ - nodejs \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* +# Set environment variables to avoid interactive prompts during installation +ENV DEBIAN_FRONTEND=noninteractive -# Copy files -WORKDIR /app -COPY . . +# Install all dependencies, configure system, and clean up in a single layer +RUN apt-get update && apt-get install -y --no-install-recommends \ + # Core runtime dependencies + apache2 \ + php \ + php-cli \ + php-mbstring \ + php-xml \ + php-curl \ + php-zip \ + php-gd \ + gphoto2 \ + libimage-exiftool-perl \ + rsync \ + udisks2 \ + python3 \ + cups \ + ipp-usb \ + avahi-daemon \ + avahi-utils \ + dbus \ + printer-driver-gutenprint \ + # Build dependencies (will be removed later) + build-essential \ + git \ + ca-certificates \ + curl \ + gnupg \ + # Install Node.js 20.x + && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -y nodejs \ + && npm install -g npm@latest \ + # Configure www-data user and groups + && (id -u www-data || useradd -r -s /usr/sbin/nologin www-data) \ + && gpasswd -a www-data plugdev \ + && gpasswd -a www-data lp \ + && gpasswd -a www-data lpadmin \ + && usermod -aG root www-data \ + && mkdir -p /var/www/html \ + && chown -R www-data:www-data /var/www/html \ + && chsh -s /bin/bash www-data \ + # Configure Apache + && a2enmod rewrite \ + && a2enmod headers \ + && echo "LimitRequestLine 12000" > /etc/apache2/conf-available/limits.conf \ + && a2enconf limits \ + && chown -R www-data:www-data /var/www/ \ + && chmod -R 755 /var/www/ -RUN chown -R application:application /app +# Switch to the www-data user for building +USER www-data -# switch to application user -USER application +# Set the working directory +WORKDIR /var/www/html -# Install and build -RUN git config --global --add safe.directory /app \ +# Clone the Photobooth repository and build the application, then clean up +RUN rm -rf /var/www/html/* \ + && git clone https://github.com/PhotoboothProject/photobooth /var/www/html \ + && cd /var/www/html \ && git submodule update --init \ && npm install \ - && npm run build + && npm run build \ + # Clean up after build to reduce image size + && npm cache clean --force \ + && rm -rf node_modules/.cache \ + && rm -rf .git + +# Switch back to root for final configuration +USER root + +# Copy configuration script for my Wireless Canon 1500 printer usb printer maybe do not need this +COPY scripts/configure_printer.sh /usr/local/bin/configure_printer.sh + +# Remove build dependencies and clean up to reduce image size +RUN apt-get remove -y \ + build-essential \ + git \ + curl \ + gnupg \ + ca-certificates \ + && apt-get autoremove -y \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/* \ + && rm -rf /var/tmp/* + +# Expose ports for HTTP and HTTPS +EXPOSE 80 443 + +# Start Apache in the foreground +CMD dbus-daemon --system --fork & /usr/sbin/ipp-usb & service cups start && apachectl -D FOREGROUND \ No newline at end of file diff --git a/Dockerfile.old b/Dockerfile.old new file mode 100644 index 000000000..bf015394d --- /dev/null +++ b/Dockerfile.old @@ -0,0 +1,36 @@ +FROM webdevops/php-apache:8.3 + +# Adjust LimitRequestLine and +# update and install dependencies +RUN echo "LimitRequestLine 12000" > /opt/docker/etc/httpd/conf.d/limits.conf \ + && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + git \ + gphoto2 \ + libimage-exiftool-perl \ + rsync \ + udisks2 \ + python3 \ + ca-certificates \ + curl \ + gnupg \ + nodejs \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Copy files +WORKDIR /app +COPY . . + +RUN chown -R application:application /app + +# switch to application user +#USER application + +# Install and build +RUN git config --global --add safe.directory /app \ + && git submodule update --init \ + && npm install \ + && npm run build diff --git a/docker-compose.yml b/docker-compose.yml index 910541354..e1b01f9bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,18 @@ -version: "3.9" - services: photobooth: build: . + image: photobox:latest ports: - "80:80" - "443:443" environment: - COMPOSER_VERSION=2 + volumes: + - ./private/data:/var/www/html/data + - ./private/private:/var/www/html/private + - ./scripts/configure_printer.sh:/usr/local/bin/configure_printer.sh + devices: + - /dev/bus/usb:/dev/bus/usb # Mount USB devices for gphoto2 + network_mode: host + privileged: true # Grant elevated privileges for device access + restart: always \ No newline at end of file diff --git a/private/.gitkeep b/private/.gitkeep new file mode 100644 index 000000000..f3322310c --- /dev/null +++ b/private/.gitkeep @@ -0,0 +1,2 @@ +# This file ensures the images directory is tracked by Git +# Git doesn't track empty directories, so this file keeps the folder structure \ No newline at end of file diff --git a/private/data/.gitkeep b/private/data/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/data/images/.gitkeep b/private/data/images/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/data/keying/.gitkeep b/private/data/keying/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/data/print/.gitkeep b/private/data/print/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/data/qrcodes/.gitkeep b/private/data/qrcodes/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/data/test/.gitkeep b/private/data/test/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/data/thumbs/.gitkeep b/private/data/thumbs/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/data/tmp/.gitkeep b/private/data/tmp/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/private/.gitkeep b/private/private/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/private/fonts/.gitkeep b/private/private/fonts/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/private/images/background/.gitkeep b/private/private/images/background/.gitkeep new file mode 100644 index 000000000..aabdaed52 --- /dev/null +++ b/private/private/images/background/.gitkeep @@ -0,0 +1,2 @@ +# This file preserves the entire images directory structure +# Including all subdirectories like background/, tmp/, keying/, etc. \ No newline at end of file diff --git a/private/private/images/cheese/owl.jpg b/private/private/images/cheese/owl.jpg new file mode 100644 index 000000000..8adb75d1b Binary files /dev/null and b/private/private/images/cheese/owl.jpg differ diff --git a/private/private/images/demo/.gitkeep b/private/private/images/demo/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/private/images/frames/.gitkeep b/private/private/images/frames/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/private/images/keyingBackgrounds/.gitkeep b/private/private/images/keyingBackgrounds/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/private/images/logo/Photobooth_party2025.png b/private/private/images/logo/Photobooth_party2025.png new file mode 100644 index 000000000..e96ab36fd Binary files /dev/null and b/private/private/images/logo/Photobooth_party2025.png differ diff --git a/private/private/images/placeholder/.gitkeep b/private/private/images/placeholder/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/private/private/videos/background/.gitkeep b/private/private/videos/background/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/configure_printer.sh b/scripts/configure_printer.sh new file mode 100644 index 000000000..8944e7c0d --- /dev/null +++ b/scripts/configure_printer.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Start avahi-daemon +echo "Starting avahi-daemon..." +/usr/sbin/avahi-daemon --no-chroot & + +# Wait for avahi-daemon to initialize +sleep 10 + +# Detect the printer's IPP URI +echo "Detecting printer's IPP URI..." +PRINTER_URI=$(lpinfo -v | grep "ipp://" | awk '{print $2}') + +if [ -z "$PRINTER_URI" ]; then + echo "No IPP printer detected. Exiting." + exit 1 +fi + +echo "Printer detected at: $PRINTER_URI" + +# Add and configure the Canon SELPHY CP1500 printer using IPP +echo "Configuring the printer..." +lpadmin -p canon -E -v "$PRINTER_URI" -m everywhere +lpoptions -d canon + +# Verify the printer configuration +echo "Verifying the printer configuration..." +lpstat -p + +# Test lpinfo -v and lpstat -p