61 lines
1.7 KiB
Docker
61 lines
1.7 KiB
Docker
# Dockerfile pour Homelab Automation Dashboard avec Ansible
|
|
FROM python:3.11-slim
|
|
|
|
# Métadonnées
|
|
LABEL maintainer="Homelab Automation"
|
|
LABEL description="Dashboard d'automatisation Homelab avec FastAPI et Ansible"
|
|
LABEL version="1.0"
|
|
|
|
# Variables d'environnement
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV ANSIBLE_HOST_KEY_CHECKING=False
|
|
ENV ANSIBLE_RETRY_FILES_ENABLED=False
|
|
|
|
# Répertoire de travail
|
|
WORKDIR /app
|
|
|
|
# Installation des dépendances système pour Ansible et SSH
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
openssh-client \
|
|
sshpass \
|
|
ansible \
|
|
git \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& apt-get clean
|
|
|
|
# Création du répertoire SSH et configuration
|
|
RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh
|
|
|
|
# Copie des requirements et installation des dépendances Python
|
|
COPY app/requirements.txt ./
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copie du code de l'application
|
|
COPY app/ ./
|
|
|
|
# Copie de la configuration Ansible
|
|
COPY ansible/ /ansible/
|
|
|
|
# Création du répertoire pour les clés SSH (sera monté en volume)
|
|
RUN mkdir -p /app/ssh_keys /app/data
|
|
|
|
# Configuration Ansible pour utiliser le bon répertoire
|
|
ENV ANSIBLE_CONFIG=/ansible/ansible.cfg
|
|
|
|
# Variables par défaut pour la base SQLite dans le conteneur
|
|
ENV HOMELAB_DATA_DIR=/app/data
|
|
ENV DB_PATH=/app/data/homelab.db
|
|
ENV DATABASE_URL=sqlite+aiosqlite:////app/data/homelab.db
|
|
|
|
# Exposition du port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/api/health || exit 1
|
|
|
|
# Commande de démarrage
|
|
CMD ["python", "-m", "uvicorn", "app_optimized:app", "--host", "0.0.0.0", "--port", "8000"]
|