Files
digiserver-v2/Dockerfile
T
ske087 2af04e1db3 feat: add weblink playlists, SSH player deployment, Caddy HTTPS, build player page
- Content model: add url column + is_weblink() for web page content items
- Player model: add deployment tracking fields (status, timestamps, message)
- Content blueprint: add add_weblink and add_weblink_to_playlist routes;
  weblinks auto-deleted when removed from playlist
- Players blueprint: add SSH deploy mode in add_player; weblink-aware playlist
- API blueprint: weblink URL served directly in playlist response;
  add /api/deploy/test-ssh and /api/deploy/player endpoints
- Admin blueprint: add build-player page (clone from Gitea, write base config);
  replace nginx status card with Caddy status on HTTPS config page
- caddy_manager: rewritten to generate proper HTTPS/internal-CA Caddyfiles
  and reload Caddy via admin API (/load) for live config updates
- ssh_deploy, background_tasks, player_build: new utils for SSH deployment
- background_tasks: push Flask app context into background thread so DB
  updates after deployment complete correctly
- ssh_deploy: robust install script detection with passwordless sudo injection
  (uses SSH credentials, cleaned up after install)
- Dockerfile: add git, sshpass, openssh-client, rsync
- docker-compose: switch nginx to Caddy on ports 80/443; add port 5000 for dev
- Templates: add_player deploy mode UI, weblink form in playlist/upload pages,
  build_player admin page, Caddy status on HTTPS config page
- Migrations: add_url_to_content, add_deployment_fields_to_player
- app.py: call db.create_all() on startup for schema bootstrap
- config.py: add PLAYER_CODE_DIR and PLAYER_REPO_URL settings
2026-07-13 16:46:19 +03:00

65 lines
1.9 KiB
Docker

# Use Python 3.13 slim image
FROM python:3.13-slim
# Set working directory
WORKDIR /app
# Install system dependencies including LibreOffice for PPTX conversion
RUN apt-get update && \
apt-get install -y --no-install-recommends \
poppler-utils \
ffmpeg \
libmagic1 \
sudo \
fonts-noto-color-emoji \
libreoffice-core \
libreoffice-impress \
libreoffice-writer \
sshpass \
openssh-client \
rsync \
git \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy entire application code into container
# This includes: app/, migrations/, configs, and all scripts
# Code is immutable in the image - only data folders are mounted as volumes
COPY . .
# Copy and set permissions for entrypoint script
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# Set environment variables
ENV FLASK_APP=app.app:create_app
ENV PYTHONUNBUFFERED=1
ENV FLASK_ENV=production
# Expose port
EXPOSE 5000
# Create a non-root user and grant sudo access for dependency installation
RUN useradd -m -u 1000 appuser && \
chown -R appuser:appuser /app /docker-entrypoint.sh && \
echo "Defaults:appuser !requiretty, !use_pty" >> /etc/sudoers && \
echo "appuser ALL=(ALL) NOPASSWD: /usr/bin/apt-get" >> /etc/sudoers && \
echo "appuser ALL=(ALL) NOPASSWD: /app/install_libreoffice.sh" >> /etc/sudoers && \
echo "appuser ALL=(ALL) NOPASSWD: /app/install_emoji_fonts.sh" >> /etc/sudoers && \
chmod +x /app/install_libreoffice.sh /app/install_emoji_fonts.sh
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5000/').read()" || exit 1
# Run the application via entrypoint
ENTRYPOINT ["/docker-entrypoint.sh"]