feat(docker): convert push script to PowerShell
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# scripts/docker_push.ps1
|
||||
# Build and push Manual Slop image to Gitea container registry.
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
||||
$CredsFile = Join-Path $ProjectRoot "credentials.toml"
|
||||
|
||||
if (-not (Test-Path $CredsFile)) {
|
||||
Write-Error "credentials.toml not found at $CredsFile"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Reading credentials from credentials.toml..."
|
||||
|
||||
$pyScript = @"
|
||||
import tomllib
|
||||
with open(r'$CredsFile', 'rb') as f:
|
||||
creds = tomllib.load(f)
|
||||
g = creds.get('gitea', {})
|
||||
print(g.get('registry_url', '') + '|' + g.get('username', '') + '|' + g.get('token', ''))
|
||||
"@
|
||||
|
||||
$credsJson = python -c $pyScript
|
||||
|
||||
$parts = $credsJson -split '\|'
|
||||
$registryUrl = $parts[0].TrimEnd('/')
|
||||
$giteaUser = $parts[1]
|
||||
$giteaToken = $parts[2]
|
||||
|
||||
if (-not $registryUrl -or -not $giteaUser -or -not $giteaToken) {
|
||||
Write-Error "Gitea credentials incomplete in credentials.toml"
|
||||
Write-Error "Required: registry_url, username, token"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$registryHost = $registryUrl -replace 'https?://', ''
|
||||
$imageName = "manual_slop:latest"
|
||||
$fullTag = "$registryHost/$giteaUser/$imageName"
|
||||
|
||||
Write-Host "Building Docker image..."
|
||||
docker build -t $imageName $ProjectRoot
|
||||
|
||||
Write-Host "Tagging for Gitea registry: $fullTag"
|
||||
docker tag $imageName $fullTag
|
||||
|
||||
Write-Host "Logging in to Gitea registry..."
|
||||
$giteaToken | docker login $registryHost -u $giteaUser --password-stdin
|
||||
|
||||
Write-Host "Pushing to Gitea registry..."
|
||||
docker push $fullTag
|
||||
|
||||
Write-Host "Done! Image available at: $fullTag"
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/docker_push.sh
|
||||
# Build and push Manual Slop image to Gitea container registry.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
CREDS_FILE="$PROJECT_ROOT/credentials.toml"
|
||||
|
||||
if [ ! -f "$CREDS_FILE" ]; then
|
||||
echo "Error: credentials.toml not found at $CREDS_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CREDS_JSON=$(uv run python -c "
|
||||
import tomllib
|
||||
creds = tomllib.load(open('$CREDS_FILE', 'rb'))
|
||||
g = creds.get('gitea', {})
|
||||
print(g.get('registry_url', '') + '|' + g.get('username', '') + '|' + g.get('token', ''))
|
||||
")
|
||||
|
||||
REGISTRY_URL=$(echo "$CREDS_JSON" | cut -d'|' -f1)
|
||||
GITEA_USER=$(echo "$CREDS_JSON" | cut -d'|' -f2)
|
||||
GITEA_TOKEN=$(echo "$CREDS_JSON" | cut -d'|' -f3)
|
||||
|
||||
if [ -z "$REGISTRY_URL" ] || [ -z "$GITEA_USER" ] || [ -z "$GITEA_TOKEN" ]; then
|
||||
echo "Error: gitea credentials incomplete in credentials.toml"
|
||||
echo "Required: registry_url, username, token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE_NAME="manual_slop:latest"
|
||||
FULL_TAG="${REGISTRY_URL}/${GITEA_USER}/${IMAGE_NAME}"
|
||||
|
||||
echo "Building Docker image..."
|
||||
docker build -t "$IMAGE_NAME" "$PROJECT_ROOT"
|
||||
|
||||
echo "Tagging for Gitea registry: $FULL_TAG"
|
||||
docker tag "$IMAGE_NAME" "$FULL_TAG"
|
||||
|
||||
echo "Logging in to Gitea registry..."
|
||||
echo "$GITEA_TOKEN" | docker login "$REGISTRY_URL" -u "$GITEA_USER" --password-stdin
|
||||
|
||||
echo "Pushing to Gitea registry..."
|
||||
docker push "$FULL_TAG"
|
||||
|
||||
echo "Done! Image available at: $FULL_TAG"
|
||||
Reference in New Issue
Block a user