68 lines
2 KiB
PowerShell
68 lines
2 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Deploys the Douyin_TikTok_Download_API to a local Docker image or pushes to a remote registry.
|
|
|
|
.DESCRIPTION
|
|
This script builds the Docker image and optionally pushes it to a registry or saves it as a tar file for manual transfer.
|
|
|
|
.PARAMETER Push
|
|
If specified, pushes the image to the registry defined in $Registry.
|
|
|
|
.PARAMETER Save
|
|
If specified, saves the image to a .tar file for manual transfer.
|
|
|
|
.EXAMPLE
|
|
.\deploy.ps1 -Save
|
|
Builds the image and saves it to douyin_tiktok_download_api.tar
|
|
|
|
.EXAMPLE
|
|
.\deploy.ps1 -Push
|
|
Builds the image and pushes it to your private registry.
|
|
#>
|
|
|
|
param (
|
|
[Switch]$Push,
|
|
[Switch]$Save
|
|
)
|
|
|
|
$ImageName = "douyin_tiktok_download_api"
|
|
# Update this with your actual registry if you use one, e.g., git.khoavo.myds.me/vndangkhoa/douyin-api
|
|
$Registry = "git.khoavo.myds.me/vndangkhoa/douyin-api"
|
|
$Tag = "latest"
|
|
|
|
Write-Host "Building Docker image..." -ForegroundColor Cyan
|
|
docker-compose build
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Build failed!"
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Build successful!" -ForegroundColor Green
|
|
|
|
if ($Save) {
|
|
Write-Host "Saving image to ${ImageName}.tar..." -ForegroundColor Cyan
|
|
docker save -o ${ImageName}.tar ${ImageName}:${Tag}
|
|
Write-Host "Image saved to ${PWD}\${ImageName}.tar" -ForegroundColor Green
|
|
Write-Host "You can now upload this file to your Synology NAS and load it via Docker."
|
|
}
|
|
|
|
if ($Push) {
|
|
$RemoteImage = "${Registry}:${Tag}"
|
|
Write-Host "Tagging image as ${RemoteImage}..." -ForegroundColor Cyan
|
|
docker tag ${ImageName}:${Tag} ${RemoteImage}
|
|
|
|
Write-Host "Pushing image to ${Registry}..." -ForegroundColor Cyan
|
|
docker push ${RemoteImage}
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Push failed! Make sure you are logged in to the registry."
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Push successful!" -ForegroundColor Green
|
|
}
|
|
|
|
if (-not $Push -and -not $Save) {
|
|
Write-Host "Build complete. Use -Save to create a transferable file or -Push to push to a registry." -ForegroundColor Yellow
|
|
}
|