add-blazor-project #31

Merged
jleicher merged 5 commits from add-blazor-project into master 2020-12-29 21:04:02 +01:00
5 changed files with 68 additions and 0 deletions
Showing only changes of commit c7984f6fef - Show all commits

23
Apps/Api/Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /source
COPY *.sln .
COPY Application/*.csproj ./Application/
COPY Domain/*.csproj ./Domain/
COPY Infrastructure/*.csproj ./Infrastructure/
COPY Apps/Api/*.csproj ./Apps/Api/
RUN dotnet restore
COPY Application/. ./Application/
COPY Domain/. ./Domain/
COPY Infrastructure/. ./Infrastructure/
COPY Apps/Api/. ./Apps/Api/
WORKDIR /source/Apps/Api
RUN dotnet publish -c release -o /app --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
COPY --from=build /app ./
EXPOSE 80
ENTRYPOINT ["dotnet", "Api.dll"]

View File

@ -1,3 +1,4 @@
using System;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
@ -14,6 +15,7 @@ namespace Api
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseUrls($"http://0.0.0.0:{Environment.GetEnvironmentVariable("PORT") ?? "8888"}");
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}); });
} }

View File

@ -6,9 +6,13 @@
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> <button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
<MyField @bind-Name="_name" />
@code { @code {
private int currentCount = 0; private int currentCount = 0;
private string _name = "Julien";
private void IncrementCount() private void IncrementCount()
{ {
currentCount++; currentCount++;

View File

@ -0,0 +1,16 @@
<p>Current name is @Name</p>
<button @onclick="ChangeName">Change name to "John"</button>
@code
{
[Parameter]
public string Name { get; set; }
[Parameter]
public EventCallback<string> NameChanged { get; set ; }
private void ChangeName()
{
NameChanged.InvokeAsync("John");
}
}

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /source
COPY *.sln .
COPY Application/*.csproj ./Application/
COPY Domain/*.csproj ./Domain/
COPY Infrastructure/*.csproj ./Infrastructure/
COPY Apps/Api/*.csproj ./Apps/Api/
RUN dotnet restore
COPY Application/. ./Application/
COPY Domain/. ./Domain/
COPY Infrastructure/. ./Infrastructure/
COPY Apps/Api/. ./Apps/Api/
WORKDIR /source/Apps/Api
RUN dotnet publish -c release -o /app --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
COPY --from=build /app ./
EXPOSE 80
ENTRYPOINT ["dotnet", "Api.dll"]