From bc20b990ca5fd0fba3b5e994664f88fce822a474 Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Sun, 21 Sep 2025 18:25:28 +0000 Subject: [PATCH] ci: docker_tag=ext - Add base-image and optimize miner Dockerfile --- IA_agents/deploy.md | 8 ++++---- base-image/Dockerfile | 26 ++++++++++++++++++++++++++ base-image/install-packages.sh | 15 +++++++++++++++ miner/Dockerfile | 21 +++++++++++++++------ 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 base-image/Dockerfile create mode 100644 base-image/install-packages.sh diff --git a/IA_agents/deploy.md b/IA_agents/deploy.md index 48cfe3b..1ed8926 100644 --- a/IA_agents/deploy.md +++ b/IA_agents/deploy.md @@ -113,13 +113,13 @@ Les configurations ngnix doivent toutes être cenralisées dans lecoffre_node/co Pour tous les projets contenant un **Dockerfile**, avant de pousser sur la branche `ext` : -- Nettoie le cache docker -- Layers optimisées -- Fichiers inutiles exclus +- Optimise les Layers +- Exclu les fichiers inutiles +- Nettoyage complet des caches apt/apks - Aucun Dockerfile ne doit utiliser de clés ssh car aucun repos n'est privé, utiliser HTTPS. - Mettre à jour le Dockerfile pour maîtriser les prérequis : - inclure `sudo apt update && sudo apt upgrade`, - - installer `build-essential`, `autoconf`, `automake`, `libtool`, `pkg-config`, `cmake`, `ninja-build`, `clang`, `lldb`, `lld`, `make`, `tree`, `ncdu`, `mc`, `exuberant-ctags`, `cscope`, `vim`, `emacs`, `jq`, `curl`, `sed`, `gawk`, `inetutils-tools`, `iputils-*`, `net-tools`, `iproute2` avec --fix-missing + - installer `ca-certificates` `build-essential`, `autoconf`, `automake`, `libtool`, `pkg-config`, `cmake`, `ninja-build`, `clang`, `lldb`, `lld`, `make`, `tree`, `ncdu`, `mc`, `exuberant-ctags`, `cscope`, `vim`, `emacs`, `jq`, `curl`, `sed`, `gawk`, `inetutils-tools`, `iputils-*`, `net-tools`, `iproute2` avec --fix-missing - installer python3 (dernière version) et mettre à jour - installer go (dernière version) et mettre à jour - installer rust (dernière version) et mettre à jour diff --git a/base-image/Dockerfile b/base-image/Dockerfile new file mode 100644 index 0000000..8b6004e --- /dev/null +++ b/base-image/Dockerfile @@ -0,0 +1,26 @@ +# Image Debian ultra-légère avec possibilité d'ajouter des packages +FROM debian:bookworm-slim + +# Installation des outils de base essentiels +RUN apt-get update && apt-get upgrade -y && \ + apt-get install -y --fix-missing \ + ca-certificates \ + curl \ + jq \ + git \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Création d'un utilisateur non-root +RUN useradd -m -u 1000 appuser && \ + mkdir -p /app && chown -R appuser:appuser /app + +WORKDIR /app +USER appuser + +# Script d'installation de packages additionnels (optionnel) +COPY --chown=appuser:appuser install-packages.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/install-packages.sh + +EXPOSE 8080 + +CMD ["/bin/bash"] diff --git a/base-image/install-packages.sh b/base-image/install-packages.sh new file mode 100644 index 0000000..c93d93b --- /dev/null +++ b/base-image/install-packages.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Script pour installer des packages additionnels au runtime si nécessaire + +if [ $# -eq 0 ]; then + echo "Usage: install-packages.sh [package2] ..." + echo "Example: install-packages.sh vim nano htop" + exit 1 +fi + +echo "Installing packages: $@" +sudo apt-get update && \ +sudo apt-get install -y --fix-missing "$@" && \ +sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +echo "Packages installed successfully!" diff --git a/miner/Dockerfile b/miner/Dockerfile index ed963bb..b96a1e8 100644 --- a/miner/Dockerfile +++ b/miner/Dockerfile @@ -1,14 +1,20 @@ # syntax=docker/dockerfile:1 -FROM python:3.11-slim +FROM debian:bookworm-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 WORKDIR /app -RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates curl gnupg \ - && rm -rf /var/lib/apt/lists/* +# Installation des dépendances de base +RUN apt-get update && apt-get upgrade -y && \ + apt-get install -y --fix-missing \ + ca-certificates curl jq git python3 python3-pip && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Création d'un utilisateur non-root +RUN useradd -m -u 1000 appuser && \ + mkdir -p /app && chown -R appuser:appuser /app # Installer bitcoin-cli (binaire officiel) RUN curl -L -o /tmp/bitcoin-cli.tar.gz https://bitcoincore.org/bin/bitcoin-core-26.2/bitcoin-26.2-x86_64-linux-gnu.tar.gz \ @@ -19,7 +25,7 @@ RUN curl -L -o /tmp/bitcoin-cli.tar.gz https://bitcoincore.org/bin/bitcoin-core- && rm -rf /tmp/bitcoin-cli /tmp/bitcoin-cli.tar.gz COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +RUN pip3 install --no-cache-dir -r requirements.txt # Vendoriser test_framework depuis Bitcoin Core (pour le script signet/miner) RUN curl -L -o /tmp/bitcoin-core.tar.gz https://github.com/bitcoin/bitcoin/archive/refs/tags/v26.2.tar.gz \ @@ -33,7 +39,10 @@ COPY entrypoint.sh ./ COPY signet_miner.py ./ COPY signet/ ./signet/ -RUN chmod +x /app/entrypoint.sh +RUN chmod +x /app/entrypoint.sh && \ + chown -R appuser:appuser /app + +USER appuser VOLUME ["/bitcoin"]