Add Docker build/deploy scripts, .dockerignore, and registry skill
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Construit l'image Docker Imago backend via WSL Debian.
|
||||
.DESCRIPTION
|
||||
Build l'image Docker pour le backend Imago en utilisant Docker
|
||||
sous WSL Debian avec BuildKit activé.
|
||||
.PARAMETRES
|
||||
-full : Construction complète sans cache (--no-cache).
|
||||
.EXEMPLE
|
||||
.\build-img.ps1 # Build avec cache
|
||||
.\build-img.ps1 -full # Build complet sans cache
|
||||
#>
|
||||
|
||||
param(
|
||||
[switch]$full
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
try {
|
||||
$scriptDir = $PSScriptRoot
|
||||
$projectRoot = (Get-Item (Join-Path $scriptDir '..')).FullName
|
||||
|
||||
# Convertir chemin Windows vers WSL
|
||||
$wslProjectRoot = $projectRoot -replace '^([A-Za-z]):\\', '/mnt/$1/' -replace '\\', '/'
|
||||
$wslProjectRoot = $wslProjectRoot.ToLower()
|
||||
|
||||
# Vérifier Docker dans WSL Debian
|
||||
Write-Host "Vérification de Docker dans WSL Debian..." -ForegroundColor Cyan
|
||||
$dockerCheck = wsl -d Debian bash -c "docker --version" 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Docker n'est pas disponible dans WSL Debian"
|
||||
exit 1
|
||||
}
|
||||
Write-Host "Docker détecté" -ForegroundColor Green
|
||||
|
||||
$noCache = if ($full) { '--no-cache' } else { '' }
|
||||
|
||||
# Commande de build
|
||||
$cdCmd = "cd `"$wslProjectRoot`""
|
||||
$dockerCmd = "docker build $noCache --progress=plain -t imago-backend:latest -f Dockerfile ."
|
||||
$innerCmd = "export DOCKER_BUILDKIT=1 && $cdCmd && $dockerCmd"
|
||||
|
||||
Write-Host "Construction de l'image imago-backend:latest..." -ForegroundColor Cyan
|
||||
$buildResult = wsl -d Debian bash -lc $innerCmd 2>&1
|
||||
$buildResult | ForEach-Object { Write-Host $_ }
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Erreur lors de la construction de l'image (code: $LASTEXITCODE)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Image imago-backend:latest construite avec succès." -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Error "Erreur : $_"
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user