Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
76 lines
2.0 KiB
Docker
76 lines
2.0 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 \
|
|
ansible-lint \
|
|
ttyd \
|
|
git \
|
|
curl \
|
|
libjpeg62-turbo \
|
|
zlib1g \
|
|
libfreetype6 \
|
|
libpng16-16 \
|
|
fonts-noto-color-emoji \
|
|
&& 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 point d'entrée principal
|
|
COPY main.py ./
|
|
|
|
# Copie du code de l'application (doit rester un sous-dossier /app/app/)
|
|
COPY app/ ./app/
|
|
|
|
# Copie de la configuration Ansible
|
|
COPY ansible/ /ansible/
|
|
|
|
# Copie des fichiers Alembic (migrations)
|
|
COPY alembic/ /alembic/
|
|
COPY alembic.ini /alembic.ini
|
|
|
|
# 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 LOGS_DIR=/app/data
|
|
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 8008
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8008/api/health || exit 1
|
|
|
|
# Commande de démarrage
|
|
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8008"]
|