Commit 39e54a81 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Ménage & intégration de la config docker pour créer le serveur de conversion

parent 4f23a7e9
Loading
Loading
Loading
Loading
Loading

Module.php

deleted100644 → 0
+0 −26
Original line number Diff line number Diff line
<?php

namespace Unicaen\OpenDocument;

use Laminas\ModuleManager\Feature\ConfigProviderInterface;
use Laminas\Mvc\MvcEvent;

/**
 *
 *
 * @author Laurent LECLUSE <laurent.lecluse at unicaen.fr>
 */
class Module implements ConfigProviderInterface
{
    public function onBootstrap(MvcEvent $e)
    {

    }



    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }
}
+3 −5
Original line number Diff line number Diff line
@@ -8,13 +8,11 @@
        }
    ],
    "require"     : {
        "guzzlehttp/guzzle": "^7.9"
    },
    "autoload"    : {
        "psr-4": {
            "Unicaen\\OpenDocument\\": "src/"
        },
        "classmap": [
            "./Module.php"
        ]
        }
    }
}

config/module.config.php

deleted100644 → 0
+0 −13
Original line number Diff line number Diff line
<?php

namespace Unicaen\OpenDocument;

return [

    'view_manager' => [
        'template_path_stack' => [
            'import' => __DIR__ . '/../view',
        ],
    ],

];
 No newline at end of file

odconv/Dockerfile

0 → 100644
+43 −0
Original line number Diff line number Diff line
FROM python:3.13-alpine

# Install system dependencies for LibreOffice (fonts, java for Excel formats, etc.)
# Also include build-base for pip installations
RUN apk update && apk add --no-cache \
    build-base \
    libreoffice \
    openjdk11-jre \
    fontconfig \
    ttf-dejavu \
    && rm -rf /var/cache/apk/*

# Create non-root user with writable HOME and initialize LibreOffice profile
RUN adduser -D appuser && \
    mkdir -p /home/appuser/.config/libreoffice && \
    chown -R appuser:appuser /home/appuser && \
    ls -la /home/appuser  # Debug: Check if directory exists (remove after testing)

# Set workdir
WORKDIR /app

# Copy app files
COPY requirements.txt .
COPY main.py .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Use the non-root user
USER appuser

# Set HOME to avoid user profile errors
ENV HOME=/home/appuser

# Expose the port
EXPOSE 8000

# Default environment variables
ENV WORKERS=4
ENV TIMEOUT=300

# Start command: Gunicorn with Uvicorn workers, long timeouts, and debug logging
CMD ["sh", "-c", "gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 --workers ${WORKERS} --timeout ${TIMEOUT} --log-level debug main:app"]
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
services:
  odconv:
    build:
      context: .
#    container_name: ${APP_NAME}-odconv
    environment:
      - WORKERS=4  # Nombre de workers pour gérer la charge (ajustez pour plus de concurrency)
      - TIMEOUT=300  # Timeout en secondes pour les requêtes (long pour les conversions lentes)
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000"]  # Simple check HTTP
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    mem_limit: 1g  # Limite mémoire pour éviter abus (ajustez selon vos besoins)
    cpus: 2.0  # Limite CPU pour scaler (ajustez selon le hardware)
 No newline at end of file
Loading