anastasijasavov 3 years ago
parent
commit
9052354881

+ 25
- 0
.dockerignore View File

@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

+ 0
- 83
Dockerfile View File

@@ -1,83 +0,0 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

WORKDIR /app

EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build

WORKDIR /src

COPY ["SpotifyService/SpotifyService.csproj", "SpotifyService/SpotifyService/"]

COPY ["IdentityProvider/IdentityProvider.csproj", "IdentityProvider/IdentityProvider/"]

COPY ["NemAnBlazor/NemAnBlazor.csproj", "NemAnBlazor/NemAnBlazor/"]

COPY ["SpotifyWorker/SpotifyWorker.csproj", "SpotifyWorker/SpotifyWorker/"]

COPY *.sln .

COPY *.csproj ./

RUN dotnet restore "SpotifyService/SpotifyService.csproj"

RUN dotnet restore "IdentityProvider/IdentityProvider.csproj"

RUN dotnet restore "NemAnBlazor/NemAnBlazor.csproj"

RUN dotnet restore "SpotifyWorker/SpotifyWorker.csproj"

COPY . .

WORKDIR "/src/SpotifyService/SpotifyService"

RUN dotnet build "SpotifyService.csproj" -c Release -o /app/build

COPY . .

WORKDIR "/src/IdentityProvider/IdentityProvider"

RUN dotnet build "IdentityProvider.csproj" -c Release -o /app/build1

COPY . .

WORKDIR "/src/NemAnBlazor/NemAnBlazor"

RUN dotnet build "NemAnBlazor.csproj" -c Release -o /app/build2

COPY . .

WORKDIR "/src/SpotifyWorker/SpotifyWorker"

RUN dotnet build "SpotifyWorker.csproj" -c Release -o /app/build3

FROM build AS publish

RUN dotnet publish -c Release -o /app/publish "/src/SpotifyService/SpotifyService.csproj"

RUN dotnet publish -c Release -o /app/publish1 "/src/IdentityProvider/IdentityProvider.csproj"

RUN dotnet publish -c Release -o /app/publish2 "/src/NemAnBlazor/NemAnBlazor.csproj"

RUN dotnet publish -c Release -o /app/publish3 "/src/SpotifyWorker/SpotifyWorker.csproj"

FROM base AS final

WORKDIR /app

COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "SpotifyService.dll"]

COPY --from=publish /app/publish1 .

ENTRYPOINT ["dotnet", "IdentityProvider.dll"]

COPY --from=publish /app/publish2 .

ENTRYPOINT ["dotnet", "NemAnBlazor.dll"]

COPY --from=publish /app/publish3 .

ENTRYPOINT ["dotnet", "SpotifyWorker.dll"]

+ 24
- 0
IdentityProvider/Dockerfile View File

@@ -0,0 +1,24 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["IdentityProvider/IdentityProvider.csproj", "IdentityProvider/"]
COPY ["GrpcShared/GrpcShared.csproj", "GrpcShared/"]
COPY ["NemAnBlazor/NemAnBlazor.csproj", "NemAnBlazor/"]
RUN dotnet restore "IdentityProvider/IdentityProvider.csproj"
COPY . .
WORKDIR "/src/IdentityProvider"
RUN dotnet build "IdentityProvider.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "IdentityProvider.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "IdentityProvider.dll"]

+ 4
- 0
IdentityProvider/IdentityProvider.csproj View File

@@ -4,12 +4,16 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>d42a42c9-e639-4515-9976-91c672b2dcc2</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.40.0" />
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.47.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.8" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="MongoDB.Driver" Version="2.17.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="protobuf-net.Grpc" Version="1.0.171" />

+ 20
- 16
IdentityProvider/Properties/launchSettings.json View File

@@ -1,30 +1,34 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28725",
"sslPort": 44342
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
},
"SpotifyService": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": "true",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true,
"useSSL": true
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28725",
"sslPort": 44342
}
}
}

+ 6
- 0
NemAn.sln View File

@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityProvider", "Identit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GrpcShared", "GrpcShared\GrpcShared.csproj", "{C142D6DF-066A-4ADA-86A3-1C736136C1FA}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{5DEF4BC2-FFBE-4CA8-80D5-CC87D065C0CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
{C142D6DF-066A-4ADA-86A3-1C736136C1FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C142D6DF-066A-4ADA-86A3-1C736136C1FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C142D6DF-066A-4ADA-86A3-1C736136C1FA}.Release|Any CPU.Build.0 = Release|Any CPU
{5DEF4BC2-FFBE-4CA8-80D5-CC87D065C0CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DEF4BC2-FFBE-4CA8-80D5-CC87D065C0CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DEF4BC2-FFBE-4CA8-80D5-CC87D065C0CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DEF4BC2-FFBE-4CA8-80D5-CC87D065C0CD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

+ 1
- 0
NemAnBlazor/NemAnBlazor.csproj View File

@@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

+ 25
- 0
SpotifyService/Dockerfile View File

@@ -0,0 +1,25 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["SpotifyService/SpotifyService.csproj", "SpotifyService/"]
COPY ["GrpcShared/GrpcShared.csproj", "GrpcShared/"]
COPY ["IdentityProvider/IdentityProvider.csproj", "IdentityProvider/"]
COPY ["NemAnBlazor/NemAnBlazor.csproj", "NemAnBlazor/"]
RUN dotnet restore "SpotifyService/SpotifyService.csproj"
COPY . .
WORKDIR "/src/SpotifyService"
RUN dotnet build "SpotifyService.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "SpotifyService.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SpotifyService.dll"]

+ 23
- 16
SpotifyService/Properties/launchSettings.json View File

@@ -1,30 +1,37 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28725",
"sslPort": 44342
}
},
{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
},
"SpotifyService": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": "true",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true,
"useSSL": true
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28725",
"sslPort": 44342
}
}
}
}

+ 5
- 1
SpotifyService/SpotifyService.csproj View File

@@ -1,9 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>2d734739-67f9-4962-a0ef-c43fbc662a6b</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>

<ItemGroup>
@@ -12,6 +15,7 @@
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.47.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.8" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.8" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="protobuf-net.Grpc" Version="1.0.171" />

+ 24
- 0
SpotifyWorker/Dockerfile View File

@@ -0,0 +1,24 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["SpotifyWorker/SpotifyWorker.csproj", "SpotifyWorker/"]
COPY ["SpotifyService/SpotifyService.csproj", "SpotifyService/"]
COPY ["GrpcShared/GrpcShared.csproj", "GrpcShared/"]
COPY ["IdentityProvider/IdentityProvider.csproj", "IdentityProvider/"]
COPY ["NemAnBlazor/NemAnBlazor.csproj", "NemAnBlazor/"]
RUN dotnet restore "SpotifyWorker/SpotifyWorker.csproj"
COPY . .
WORKDIR "/src/SpotifyWorker"
RUN dotnet build "SpotifyWorker.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "SpotifyWorker.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SpotifyWorker.dll"]

+ 7
- 4
SpotifyWorker/Properties/launchSettings.json View File

@@ -1,11 +1,14 @@
{
{
"profiles": {
"SpotifyWorker": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true
},
"Docker": {
"commandName": "Docker"
}
}
}
}

+ 2
- 0
SpotifyWorker/SpotifyWorker.csproj View File

@@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-SpotifyWorker-32F09870-7D1D-49C3-A41E-BCD7B23F1454</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
@@ -16,6 +17,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="protobuf-net.Grpc" Version="1.0.171" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

+ 11
- 0
SpotifyWorker/Worker.cs View File

@@ -17,6 +17,8 @@ namespace SpotifyWorker

private IStatsService _serviceClient;
private IIdentityService _identityService;
private Timer _timer;

public Worker(ILogger<Worker> logger)
{
_logger = logger;
@@ -26,8 +28,17 @@ namespace SpotifyWorker
}
public override Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Service is starting.");

_timer = new Timer(DoWork, null, TimeSpan.Zero,
TimeSpan.FromSeconds(5));

return base.StartAsync(cancellationToken);
}
private void DoWork(object state)
{
_logger.LogInformation("Service is running.");
}
public class GrpcServerStartup
{
public void ConfigureServices(IServiceCollection services)

+ 18
- 0
docker-compose.dcproj View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>5def4bc2-ffbe-4ca8-80d5-cc87d065c0cd</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>spotifyservice</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>

+ 31
- 0
docker-compose.override.yml View File

@@ -0,0 +1,31 @@
version: '3.4'

services:
spotifyservice:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://localhost:5001;http://localhost:5000
ports:
- "5001"
- "5000"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro

identityprovider:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://127.0.0.1:5002
ports:
- "5002"
- "443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro

spotifyworker:
environment:
- DOTNET_ENVIRONMENT=Development
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro


+ 24
- 0
docker-compose.yml View File

@@ -0,0 +1,24 @@
version: '3.4'

services:
spotifyservice:
image: ${DOCKER_REGISTRY-}spotifyservice
build:
context: .
dockerfile: SpotifyService/Dockerfile

identityprovider:
image: ${DOCKER_REGISTRY-}identityprovider
build:
context: .
dockerfile: IdentityProvider/Dockerfile


spotifyworker:
image: ${DOCKER_REGISTRY-}spotifyworker
build:
context: .
dockerfile: SpotifyWorker/Dockerfile



+ 13
- 0
launchSettings.json View File

@@ -0,0 +1,13 @@
{
"profiles": {
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"serviceActions": {
"identityprovider": "StartDebugging",
"spotifyservice": "StartDebugging",
"spotifyworker": "StartDebugging"
}
}
}
}

Loading…
Cancel
Save