diff --git a/Dockerfile b/Dockerfile index 73cf005..9d21ffd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,4 +16,4 @@ COPY --from=builder /app/target/release/cdxs /usr/local/bin/cdxs EXPOSE 8765 VOLUME ["/data"] -CMD ["cdxs", "server", "run", "--bind", "0.0.0.0:8765", "--data", "/data/cdxs.toml"] +CMD ["cdxs", "server", "run", "--bind", "0.0.0.0:8765", "--data-dir", "/data"] diff --git a/compose.yml b/compose.yml index d7f3eaf..24a8ace 100644 --- a/compose.yml +++ b/compose.yml @@ -1,7 +1,6 @@ services: cdxs-server: - build: . - image: cdxs-server:latest + image: docker.pchuan.top/cdxs:latest container_name: cdxs-server restart: unless-stopped ports: diff --git a/scripts/publish-docker.ps1 b/scripts/publish-docker.ps1 new file mode 100644 index 0000000..033a7ba --- /dev/null +++ b/scripts/publish-docker.ps1 @@ -0,0 +1,48 @@ +param( + [string]$Registry = "docker.pchuan.top", + [string]$ImageName = "cdxs", + [string]$Tag = "", + [switch]$NoLatest, + [string]$Platform = "" +) + +$ErrorActionPreference = "Stop" + +$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") +Set-Location $repoRoot + +if (-not $Tag) { + $cargoToml = Get-Content -Raw -Path "Cargo.toml" + if ($cargoToml -notmatch '(?m)^version\s*=\s*"([^"]+)"') { + throw "Cannot read package version from Cargo.toml" + } + $Tag = $Matches[1] +} + +$image = "$Registry/$ImageName" +$versionTag = "${image}:$Tag" +$latestTag = "${image}:latest" + +Write-Host "Building $versionTag" +$buildArgs = @("build", "-t", $versionTag) +if (-not $NoLatest) { + $buildArgs += @("-t", $latestTag) +} +if ($Platform) { + $buildArgs += @("--platform", $Platform) +} +$buildArgs += "." +docker @buildArgs + +Write-Host "Pushing $versionTag" +docker push $versionTag + +if (-not $NoLatest) { + Write-Host "Pushing $latestTag" + docker push $latestTag +} + +Write-Host "Published $versionTag" +if (-not $NoLatest) { + Write-Host "Published $latestTag" +}