Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 8540780

Browse files
leave nothing unparameterized
1 parent 5265537 commit 8540780

5 files changed

Lines changed: 39 additions & 16 deletions

File tree

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
ARG CONTAINER_RUNTIME=2.2.1-runtime-deps-alpine3.8
2+
13
FROM node:10.12.0-alpine AS build-javascript
24
ARG CLIENT_VERSION=0.9.2
35
ARG NPM_REGISTRY=https://registry.npmjs.org
@@ -16,6 +18,8 @@ RUN yarn && \
1618

1719
FROM microsoft/dotnet:2.2.102-sdk-stretch AS build-dotnet
1820
ARG CLIENT_PACKAGE=@sqlstreamstore/browser
21+
ARG RUNTIME=alpine-x64
22+
ARG LIBRARY_VERSION=1.2.0
1923

2024
WORKDIR /app
2125

@@ -24,8 +28,6 @@ COPY .git ./
2428
RUN dotnet tool install -g minver-cli --version 1.0.0-beta.2 && \
2529
/root/.dotnet/tools/minver > .version
2630

27-
WORKDIR /app
28-
2931
COPY ./*.sln ./
3032

3133
WORKDIR /app/src
@@ -38,7 +40,7 @@ WORKDIR /app
3840

3941
COPY ./NuGet.Config ./
4042

41-
RUN dotnet restore --runtime=alpine-x64
43+
RUN dotnet restore --runtime=${RUNTIME}
4244

4345
WORKDIR /app/src
4446

@@ -56,9 +58,9 @@ COPY ./build .
5658

5759
WORKDIR /app
5860

59-
RUN dotnet run --project build/build.csproj
61+
RUN dotnet run --project build/build.csproj -- --runtime=${RUNTIME} --library-version=${LIBRARY_VERSION}
6062

61-
FROM microsoft/dotnet:2.2.1-runtime-deps-alpine3.8 AS runtime
63+
FROM microsoft/dotnet:${CONTAINER_RUNTIME} AS runtime
6264

6365
WORKDIR /app
6466
COPY --from=build-dotnet /app/.version ./

build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ REMOTE_IMAGE="sqlstreamstore/hal"
99

1010
docker build \
1111
--build-arg MYGET_API_KEY=$MYGET_API_KEY \
12+
--build-arg RUNTIME_CONTAINER=${RUNTIME_CONTAINER:-2.2.1-runtime-deps-alpine3.8} \
13+
--build-arg RUNTIME=${RUNTIME:-alpine-x64} \
14+
--build-arg LIBRARY_VERSION=${LIBRARY_VERSION:-1.2.0-beta.*} \
1215
--tag ${LOCAL} \
1316
.
1417

build/Program.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Linq;
4-
using System.Runtime.InteropServices;
5-
using System.Threading.Tasks;
4+
using Fclp;
65
using static Bullseye.Targets;
76
using static SimpleExec.Command;
87

@@ -17,19 +16,36 @@ public static void Main(string[] args)
1716
const string build = nameof(Build);
1817
const string publish = nameof(Publish);
1918

19+
var runtime = "alpine-x64";
20+
var libraryVersion = "1.2.0-beta.*";
21+
22+
var parser = new FluentCommandLineParser();
23+
parser.Setup<string>("runtime")
24+
.Callback(r => runtime = r);
25+
parser.Setup<string>("library-version")
26+
.Callback(v => libraryVersion = v);
27+
28+
var result = parser.Parse(args);
29+
30+
args = result
31+
.AdditionalOptions
32+
.SelectMany(option => new[] {option.Key.Length == 1 ? $"-{option.Key}" : $"--{option.Key}", option.Value})
33+
.Where(arg => arg != null)
34+
.ToArray();
35+
2036
Target(
2137
clean,
2238
Clean);
2339

2440
Target(
2541
build,
2642
DependsOn(clean),
27-
Build);
43+
Build(libraryVersion));
2844

2945
Target(
3046
publish,
3147
DependsOn(build),
32-
Publish);
48+
Publish(runtime, libraryVersion));
3349

3450
Target("default", DependsOn(publish));
3551

@@ -49,11 +65,11 @@ public static void Main(string[] args)
4965
}
5066
};
5167

52-
private static readonly Action Build = () => Run(
68+
private static Action Build(string libraryVersion) => () => Run(
5369
"dotnet",
54-
"build SqlStreamStore.Server.sln --configuration Release");
70+
$"build SqlStreamStore.Server.sln --configuration=Release /p:LibraryVersion={libraryVersion}");
5571

56-
private static readonly Action Publish = () => Run(
72+
private static Action Publish(string runtime, string libraryVersion) => () => Run(
5773
"dotnet",
58-
$"publish --configuration=Release --output=../../{PublishDir} --runtime=alpine-x64 /p:ShowLinkerSizeComparison=true src/SqlStreamStore.Server");
74+
$"publish --configuration=Release --output=../../{PublishDir} --runtime={runtime} /p:ShowLinkerSizeComparison=true /p:LibraryVersion={libraryVersion} src/SqlStreamStore.Server");
5975
}

build/build.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Bullseye" Version="2.3.0" />
11+
<PackageReference Include="FluentCommandLineParser.NETStandard" Version="1.5.0.31-commands" />
1112
<PackageReference Include="SimpleExec" Version="4.2.0" />
1213
</ItemGroup>
1314

src/SqlStreamStore.Server/SqlStreamStore.Server.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
66
<LangVersion>latest</LangVersion>
77
<CrossGenDuringPublish>false</CrossGenDuringPublish>
8+
<LibraryVersion Condition="$(LibraryVersion) == ''">1.2.0-beta.*</LibraryVersion>
89
</PropertyGroup>
910
<ItemGroup>
1011
<PackageReference Include="ILLink.Tasks" Version="0.1.5-preview-1841731" />
@@ -16,9 +17,9 @@
1617
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.2.0" />
1718
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
1819
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
19-
<PackageReference Include="SqlStreamStore.MsSql" Version="1.2.0-beta.*" />
20-
<PackageReference Include="SqlStreamStore.Postgres" Version="1.2.0-beta.*" />
21-
<PackageReference Include="SqlStreamStore.HAL" Version="1.2.0-beta.*" />
20+
<PackageReference Include="SqlStreamStore.MsSql" Version="$(LibraryVersion)" />
21+
<PackageReference Include="SqlStreamStore.Postgres" Version="$(LibraryVersion)" />
22+
<PackageReference Include="SqlStreamStore.HAL" Version="$(LibraryVersion)" />
2223
</ItemGroup>
2324
<ItemGroup>
2425
<EmbeddedResource Include="Browser\build\**">

0 commit comments

Comments
 (0)