mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-09-24 20:00:27 +01:00
This PR was coauthored by alexhb1 and davidemarcoli. It builds on the FE rework created by alex, but adds a myriad of additional tweaks and optimizations to make the frontend feel modern, fast, and responsive. The summary of the changes is as follows: ### Architecture Changes React/TypeScript Migration: Refactored frontend from template/JS structure to React/TypeScript application for better maintainability and scalability WebSocket Integration: Implemented real-time updates for download status and progress with automatic fallback to polling Gevent Worker: Configured production WebSocket support ### UI/UX Improvements <img width="1502" height="890" alt="Screenshot 2025-11-10 at 10 02 59 AM" src="https://github.com/user-attachments/assets/86bf8649-623f-413c-b8e5-656e687e55a8" /> Downloads Sidebar: Replaced bottom downloads section with sidebar interface for better organization <img width="201" height="450" alt="Screenshot 2025-11-10 at 10 07 52 AM" src="https://github.com/user-attachments/assets/92b98e7c-c3bc-4b7e-80f1-252c3a760e33" /> Status Badges: Color-coded download status indicators instead of plain text Pinned Header: Fixed header position for consistent navigation Enhanced Book Cards: Improved layout and hover states with info modal button <img width="1474" height="899" alt="Screenshot 2025-11-10 at 10 08 18 AM" src="https://github.com/user-attachments/assets/9216d8a3-f662-434d-80e6-2a69b96abc31" /> Download Progress: Circular progress indicator on download buttons Toast Notifications: Added user feedback for actions Spinner Feedback: Loading indicators on search and download buttons Animations: Smooth transitions and fluid progress updates ### Mobile & Responsive Design Mobile-friendly Layouts: Optimized book cards and search interface for mobile <img width="225" height="450" alt="Screenshot 2025-11-10 at 10 05 49 AM" src="https://github.com/user-attachments/assets/c8236c1c-5837-4309-9577-46db7292a54b" /> Keyboard Handling: Improved mobile keyboard behavior with proper input types PWA Improvements: Enhanced progressive web app functionality Responsive Search: Better search box width and positioning across devices ### Developer Experience Development Mode: Separate frontend dev server that works with existing backend container Makefile: Added build automation and development commands Documentation: Updated README with frontend architecture details ### Bug Fixes Fixed "Clear completed" functionality Fixed dark mode toggle text Fixed sticky header behavior Fixed mobile search box positioning Removed active downloads requirement for initial state view ### Additional Features ESC Key: Close downloads sidebar with ESC key Calibre-Web Button: Direct link to Calibre-Web instance <img width="282" height="83" alt="Screenshot 2025-11-11 at 9 38 05 AM" src="https://github.com/user-attachments/assets/273075be-9743-4e13-9e48-5bf498f6c067" /> Granular Status Tracking: More detailed download progress information obtained via websockets --------- Co-authored-by: Alex <alex.bilbie1@gmail.com> Co-authored-by: Zack Yancey <yanceyz@proton.me> Co-authored-by: davidemarcoli <davide@marcoli.ch>
166 lines
4.8 KiB
Docker
166 lines
4.8 KiB
Docker
# Frontend build stage
|
|
FROM node:20-alpine AS frontend-builder
|
|
|
|
WORKDIR /frontend
|
|
|
|
# Copy frontend package files
|
|
COPY src/frontend/package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy frontend source
|
|
COPY src/frontend/ ./
|
|
|
|
# Build the frontend
|
|
RUN npm run build
|
|
|
|
# Use python-slim as the base image
|
|
FROM python:3.10-slim AS base
|
|
|
|
# Add build argument for version
|
|
ARG BUILD_VERSION
|
|
ENV BUILD_VERSION=${BUILD_VERSION}
|
|
ARG RELEASE_VERSION
|
|
ENV RELEASE_VERSION=${RELEASE_VERSION}
|
|
|
|
# Set shell to bash with pipefail option
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
# Consistent environment variables grouped together
|
|
ENV DEBIAN_FRONTEND=noninteractive \
|
|
DOCKERMODE=true \
|
|
PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONIOENCODING=UTF-8 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
PIP_DEFAULT_TIMEOUT=100 \
|
|
NAME=Calibre-Web-Automated-Book-Downloader \
|
|
PYTHONPATH=/app \
|
|
# UID/GID will be handled by entrypoint script, but TZ/Locale are still needed
|
|
LANG=en_US.UTF-8 \
|
|
LANGUAGE=en_US:en \
|
|
LC_ALL=en_US.UTF-8 \
|
|
APP_ENV=prod
|
|
|
|
# Set ARG for build-time expansion (FLASK_PORT), ENV for runtime access
|
|
ENV FLASK_PORT=8084
|
|
|
|
# Configure locale, timezone, and perform initial cleanup in a single layer
|
|
# User/group creation is removed
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
# For locale
|
|
locales tzdata \
|
|
# For healthcheck
|
|
curl \
|
|
# For entrypoint
|
|
dumb-init \
|
|
# For debug
|
|
zip iputils-ping \
|
|
# For user switching
|
|
sudo && \
|
|
# Cleanup APT cache *after* all installs in this layer
|
|
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
# Default to UTC timezone but will be overridden by the entrypoint script
|
|
ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone && \
|
|
# Configure locale
|
|
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
|
|
locale-gen en_US.UTF-8 && \
|
|
echo "LC_ALL=en_US.UTF-8" >> /etc/environment && \
|
|
echo "LANG=en_US.UTF-8" > /etc/locale.conf
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install Python dependencies using pip
|
|
# Upgrade pip first, then copy requirements and install
|
|
# Copying requirements-base.txt separately leverages build cache
|
|
COPY requirements-base.txt .
|
|
RUN pip install --no-cache-dir -r requirements-base.txt && \
|
|
# Clean root's pip cache
|
|
rm -rf /root/.cache
|
|
|
|
# Copy application code *after* dependencies are installed
|
|
COPY . .
|
|
|
|
# Copy built frontend from frontend-builder stage
|
|
COPY --from=frontend-builder /frontend/dist /app/frontend-dist
|
|
|
|
# Final setup: permissions and directories in one layer
|
|
# Only creating directories and setting executable bits.
|
|
# Ownership will be handled by the entrypoint script.
|
|
RUN mkdir -p /var/log/cwa-book-downloader /cwa-book-ingest && \
|
|
chmod +x /app/entrypoint.sh /app/tor.sh /app/genDebug.sh
|
|
|
|
# Expose the application port
|
|
EXPOSE ${FLASK_PORT}
|
|
|
|
# Add healthcheck for container status
|
|
# This will run as root initially, but check localhost which should work if the app binds correctly.
|
|
HEALTHCHECK --interval=60s --timeout=60s --start-period=60s --retries=3 \
|
|
CMD curl -s http://localhost:${FLASK_PORT}/request/api/status > /dev/null || exit 1
|
|
|
|
# Use dumb-init as the entrypoint to handle signals properly
|
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
|
|
|
|
|
FROM base AS cwa-bd
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
# For dumb display
|
|
xvfb \
|
|
# For screen recording
|
|
ffmpeg \
|
|
# --- Chromium ---
|
|
chromium \
|
|
# --- ChromeDriver ---
|
|
chromium-driver \
|
|
# For tkinter (pyautogui)
|
|
python3-tk
|
|
|
|
# install additional dependencies
|
|
COPY requirements-cwa-bd.txt .
|
|
RUN pip install --no-cache-dir -r requirements-cwa-bd.txt && \
|
|
# Clean root's pip cache
|
|
rm -rf /root/.cache
|
|
|
|
# Add this line to grant read/execute permissions to others
|
|
RUN chmod -R o+rx /usr/bin/chromium && \
|
|
chmod -R o+rx /usr/bin/chromedriver && \
|
|
chmod -R o+w /usr/local/lib/python3.10/site-packages/seleniumbase/drivers/
|
|
|
|
# Default command to run the application entrypoint script
|
|
CMD ["/app/entrypoint.sh"]
|
|
|
|
FROM cwa-bd AS cwa-bd-tor
|
|
|
|
ENV USING_TOR=true
|
|
|
|
# Install Tor and dependencies
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
# --- Tor ---
|
|
tor \
|
|
# --- iptables ---
|
|
iptables && \
|
|
update-alternatives --set iptables /usr/sbin/iptables-legacy && \
|
|
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy && \
|
|
# Cleanup APT cache *after* all installs in this layer
|
|
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Override the default command to run Tor
|
|
CMD ["/app/entrypoint.sh"]
|
|
|
|
FROM base AS cwa-bd-extbp
|
|
|
|
ENV USING_EXTERNAL_BYPASSER=true
|
|
|
|
CMD ["/app/entrypoint.sh"]
|