FROM vectorim/element-web:latest USER root # Installation des dépendances légères : python3, pip, supervisor, curl RUN apk add --no-cache \ python3 \ py3-pip \ supervisor \ curl \ build-base \ python3-dev \ libffi-dev \ openssl-dev \ wget \ && rm -rf /var/cache/apk/* # Virtualenv et installation de Synapse RUN python3 -m venv /opt/venv_synapse && \ /opt/venv_synapse/bin/pip install --upgrade pip wheel && \ /opt/venv_synapse/bin/pip install --no-cache-dir matrix-synapse # Créer l'utilisateur huggingface (UID 1000) RUN adduser -D -u 1000 huggingface # Créer les dossiers internes pour les templates RUN mkdir -p /opt/synapse-templates # Copier les fichiers de config (ils seront recopiés dans /data au runtime) COPY --chown=huggingface:huggingface synapse/homeserver.yaml /opt/synapse-templates/ COPY --chown=huggingface:huggingface synapse/log.config /opt/synapse-templates/ # Config Element et supervisord COPY --chown=huggingface:huggingface config.json /app/config.json COPY --chown=huggingface:huggingface supervisord.conf /etc/supervisord.conf COPY --chown=huggingface:huggingface scripts/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh RUN mkdir -p /app/admin && \ wget -q https://github.com/Awesome-Technologies/synapse-admin/releases/download/0.11.4/synapse-admin-0.11.4.tar.gz -O /tmp/synapse-admin.tar.gz && \ tar xzf /tmp/synapse-admin.tar.gz --strip-components=1 -C /app/admin && \ rm /tmp/synapse-admin.tar.gz # Configuration Nginx avec upstream pour éviter les 502 RUN echo 'worker_processes 1; \ pid /tmp/nginx.pid; \ events { worker_connections 1024; } \ http { \ include /etc/nginx/mime.types; \ default_type application/octet-stream; \ client_body_temp_path /tmp/client_temp; \ proxy_temp_path /tmp/proxy_temp; \ fastcgi_temp_path /tmp/fastcgi_temp; \ uwsgi_temp_path /tmp/uwsgi_temp; \ scgi_temp_path /tmp/scgi_temp; \ upstream synapse_backend { \ server 127.0.0.1:8008 fail_timeout=0; \ } \ server { \ listen 7860; \ server_name localhost; \ location /_matrix { \ proxy_pass http://synapse_backend; \ proxy_set_header Host $host; \ proxy_set_header X-Forwarded-For $remote_addr; \ proxy_set_header X-Forwarded-Proto $scheme; \ client_max_body_size 50M; \ } \ # Redirection /admin → /admin/ location = /admin { \ return 301 /admin/; \ } \ # Contenu statique de synapse-admin location /admin/ { \ alias /app/admin/; \ index index.html; \ try_files $uri $uri/ /admin/index.html; \ } \ location /_synapse { \ proxy_pass http://synapse_backend; \ proxy_set_header Host $host; \ proxy_set_header X-Forwarded-For $remote_addr; \ proxy_set_header X-Forwarded-Proto $scheme; \ client_max_body_size 50M; \ } \ location / { \ root /app; \ index index.html; \ try_files $uri $uri/ /index.html; \ } \ } \ }' > /etc/nginx/nginx.conf RUN rm -rf /docker-entrypoint.d/* RUN chmod -R 777 /tmp /var/cache/nginx /var/run /var/log/nginx USER huggingface EXPOSE 7860 ENTRYPOINT ["/entrypoint.sh"] CMD ["supervisord", "-c", "/etc/supervisord.conf"]