Skip to content

Commit

Permalink
Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbl4 committed Aug 21, 2023
1 parent 4b6c2cd commit 2478165
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
4 changes: 3 additions & 1 deletion DataService/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"Enrich": ["FromLogContext", "WithThreadId"]
},
"AllowedHosts": "*",
"ServiceOptions": {
"ServiceOptions": {
},
"SeedDataLoaderOptions": {
"SeedDataDirectory": "var/seed-data"
},
"StorageServiceOptions": {
Expand Down
7 changes: 7 additions & 0 deletions DataService/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-preview
ADD ./bin/ /app/
ADD ./var/ /app/var/
WORKDIR /app
EXPOSE 80
ENV ASPNETCORE_URLS=http://*:80
CMD [ "dotnet", "DataService.dll" ]
43 changes: 43 additions & 0 deletions DataService/publish-docker.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#1.0.2

function Main()
{
$version = GetNextVersion

$publishRoot = "./_build"
$containerRoot = "./_build/bin"
$imageName = "data-service"
$platforms = @("arm64","amd64")
rmdir -Force -Recurs $publishRoot
dotnet publish -c Release /p:Version=$version -o $containerRoot
mkdir "$publishRoot/var/data"
pushd
cd data-service-ui
ng build --output-path ..\_build\var\www
popd
foreach ($p in $platforms)
{
Write-Host "Building $($p) $($version)"
docker build --pull --platform "linux/$($p)" -t "maxbl4/$imageName-$($p):$version" -t "maxbl4/$imageName-$($p):latest" -f dockerfile $publishRoot
docker push "maxbl4/$imageName-$($p):$version"
docker push "maxbl4/$imageName-$($p):latest"
}

UpdateVersion $version
}

function GetNextVersion()
{
$lines = Get-Content $MyInvocation.ScriptName
$version = [System.Version]::Parse($lines[0].Substring(1))
return "$($version.Major).$($version.Minor).$($version.Build + 1)"
}

function UpdateVersion($version)
{
$lines = Get-Content $MyInvocation.ScriptName
$lines[0] = "#$version"
Set-Content $MyInvocation.ScriptName $lines -Encoding UTF8
}

Main

0 comments on commit 2478165

Please sign in to comment.