diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..6fa523a
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,24 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/azds.yaml
+**/bin
+**/docker-compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+LICENSE
+README.md
\ No newline at end of file
diff --git a/Birdmap.API/Birdmap.API.csproj b/Birdmap.API/Birdmap.API.csproj
index 1e5227d..0510550 100644
--- a/Birdmap.API/Birdmap.API.csproj
+++ b/Birdmap.API/Birdmap.API.csproj
@@ -8,6 +8,9 @@
ClientApp\
$(DefaultItemExcludes);$(SpaRoot)node_modules\**
Birdmap.API
+ a919c854-b332-49ee-8e38-96549f828836
+ Linux
+ ..\docker-compose.dcproj
@@ -31,6 +34,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/Birdmap.API/Dockerfile b/Birdmap.API/Dockerfile
new file mode 100644
index 0000000..2763799
--- /dev/null
+++ b/Birdmap.API/Dockerfile
@@ -0,0 +1,30 @@
+#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:5.0 AS base
+WORKDIR /app
+EXPOSE 80
+EXPOSE 443
+RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
+RUN apt-get update
+RUN apt-get install -y nodejs
+
+FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
+RUN apt-get update
+RUN apt-get install -y nodejs
+WORKDIR /src
+COPY ["Birdmap.API/Birdmap.API.csproj", "Birdmap.API/"]
+COPY ["Birdmap.BLL/Birdmap.BLL.csproj", "Birdmap.BLL/"]
+COPY ["Birdmap.Common/Birdmap.Common.csproj", "Birdmap.Common/"]
+COPY ["Birdmap.DAL/Birdmap.DAL.csproj", "Birdmap.DAL/"]
+RUN dotnet restore "Birdmap.API/Birdmap.API.csproj"
+COPY . .
+WORKDIR "/src/Birdmap.API"
+RUN dotnet build "Birdmap.API.csproj" -c Release -o /app/build
+
+FROM build AS publish
+RUN dotnet publish "Birdmap.API.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "Birdmap.API.dll"]
\ No newline at end of file
diff --git a/Birdmap.API/Dockerfile.original b/Birdmap.API/Dockerfile.original
new file mode 100644
index 0000000..890c074
--- /dev/null
+++ b/Birdmap.API/Dockerfile.original
@@ -0,0 +1,28 @@
+#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:5.0-buster-slim AS base
+WORKDIR /app
+EXPOSE 80
+EXPOSE 443
+RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
+RUN apt-get install -y nodejs
+
+FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
+RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
+RUN apt-get install -y nodejs
+WORKDIR /src
+COPY ["Birdmap.API/Birdmap.API.csproj", "Birdmap.API/"]
+COPY ["Birdmap.BLL/Birdmap.BLL.csproj", "Birdmap.BLL/"]
+COPY ["Birdmap.Common/Birdmap.Common.csproj", "Birdmap.Common/"]
+COPY ["Birdmap.DAL/Birdmap.DAL.csproj", "Birdmap.DAL/"]
+RUN dotnet restore "Birdmap.API/Birdmap.API.csproj"
+COPY . .
+WORKDIR "/src/Birdmap.API"
+RUN dotnet build "Birdmap.API.csproj" -c Release -o /app/build
+
+FROM build AS publish
+RUN dotnet publish "Birdmap.API.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "Birdmap.API.dll"]
\ No newline at end of file
diff --git a/Birdmap.API/Dockerfile1.original b/Birdmap.API/Dockerfile1.original
new file mode 100644
index 0000000..2763799
--- /dev/null
+++ b/Birdmap.API/Dockerfile1.original
@@ -0,0 +1,30 @@
+#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:5.0 AS base
+WORKDIR /app
+EXPOSE 80
+EXPOSE 443
+RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
+RUN apt-get update
+RUN apt-get install -y nodejs
+
+FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
+RUN apt-get update
+RUN apt-get install -y nodejs
+WORKDIR /src
+COPY ["Birdmap.API/Birdmap.API.csproj", "Birdmap.API/"]
+COPY ["Birdmap.BLL/Birdmap.BLL.csproj", "Birdmap.BLL/"]
+COPY ["Birdmap.Common/Birdmap.Common.csproj", "Birdmap.Common/"]
+COPY ["Birdmap.DAL/Birdmap.DAL.csproj", "Birdmap.DAL/"]
+RUN dotnet restore "Birdmap.API/Birdmap.API.csproj"
+COPY . .
+WORKDIR "/src/Birdmap.API"
+RUN dotnet build "Birdmap.API.csproj" -c Release -o /app/build
+
+FROM build AS publish
+RUN dotnet publish "Birdmap.API.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "Birdmap.API.dll"]
\ No newline at end of file
diff --git a/Birdmap.API/Program.cs b/Birdmap.API/Program.cs
index 74f315c..6310be1 100644
--- a/Birdmap.API/Program.cs
+++ b/Birdmap.API/Program.cs
@@ -20,6 +20,12 @@ namespace Birdmap.API
logger.Debug("Building host...");
var host = CreateHostBuilder(args).Build();
+ using (var scope = host.Services.CreateScope())
+ {
+ var db = scope.ServiceProvider.GetRequiredService();
+ db.Database.EnsureCreated();
+ }
+
logger.Debug("Seeding database...");
SeedDatabase(host);
diff --git a/Birdmap.API/Properties/launchSettings.json b/Birdmap.API/Properties/launchSettings.json
index 939511d..a68e28b 100644
--- a/Birdmap.API/Properties/launchSettings.json
+++ b/Birdmap.API/Properties/launchSettings.json
@@ -1,4 +1,4 @@
-{
+{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
@@ -18,10 +18,17 @@
"Birdmap": {
"commandName": "Project",
"launchBrowser": true,
- "applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
- }
+ },
+ "applicationUrl": "https://localhost:5001;http://localhost:5000"
+ },
+ "Docker": {
+ "commandName": "Docker",
+ "launchBrowser": true,
+ "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
+ "publishAllPorts": true,
+ "useSSL": true
}
}
-}
+}
\ No newline at end of file
diff --git a/Birdmap.API/Services/Mqtt/MqttClientService.cs b/Birdmap.API/Services/Mqtt/MqttClientService.cs
index 8ab03b0..5acb8f2 100644
--- a/Birdmap.API/Services/Mqtt/MqttClientService.cs
+++ b/Birdmap.API/Services/Mqtt/MqttClientService.cs
@@ -117,7 +117,7 @@ namespace Birdmap.API.Services.Mqtt
public async Task HandleDisconnectedAsync(MqttClientDisconnectedEventArgs eventArgs)
{
- _logger.LogWarning(eventArgs.Exception, $"Disconnected. Reason {eventArgs.ReasonCode}. Auth result: {eventArgs.AuthenticateResult}. Reconnecting...");
+ _logger.LogDebug(eventArgs.Exception, $"Disconnected. Reason {eventArgs.ReasonCode}. Auth result: {eventArgs.AuthenticateResult}. Reconnecting...");
await Task.Delay(TimeSpan.FromSeconds(5));
@@ -128,7 +128,7 @@ namespace Birdmap.API.Services.Mqtt
}
catch (Exception ex)
{
- _logger.LogError(ex, $"Reconnect failed...");
+ _logger.LogDebug(ex, $"Reconnect failed...");
}
}
diff --git a/Birdmap.API/appsettings.json b/Birdmap.API/appsettings.json
index c742aab..721fc14 100644
--- a/Birdmap.API/appsettings.json
+++ b/Birdmap.API/appsettings.json
@@ -9,7 +9,8 @@
"AllowedHosts": "*",
"Secret": "7vj.3KW.hYE!}4u6",
// "LocalDbConnectionString": "Data Source=DESKTOP-3600\\SQLEXPRESS;Initial Catalog=birdmap;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
- "LocalDbConnectionString": "Data Source=DESKTOP-3600;Initial Catalog=birdmap;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+ //"LocalDbConnectionString": "Data Source=DESKTOP-3600;Initial Catalog=birdmap;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+ "LocalDbConnectionString": "Data Source=db;Initial Catalog=master;User=sa;Password=asdfjkl-123",
"Defaults": {
"Services": {
"Local Database": "https://localhost:44331/health",
diff --git a/Birdmap.sln b/Birdmap.sln
index 05e0b6c..207e967 100644
--- a/Birdmap.sln
+++ b/Birdmap.sln
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Birdmap.Common", "Birdmap.C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.TestApp.WinForm", "MQTTnet.TestApp.WinForm\MQTTnet.TestApp.WinForm.csproj", "{E1707FE7-4A65-42AC-B71C-6CC1A55FC42A}"
EndProject
+Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{9443433B-1D13-41F0-B345-B36ACD15EF81}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,10 @@ Global
{E1707FE7-4A65-42AC-B71C-6CC1A55FC42A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1707FE7-4A65-42AC-B71C-6CC1A55FC42A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1707FE7-4A65-42AC-B71C-6CC1A55FC42A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9443433B-1D13-41F0-B345-B36ACD15EF81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9443433B-1D13-41F0-B345-B36ACD15EF81}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9443433B-1D13-41F0-B345-B36ACD15EF81}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9443433B-1D13-41F0-B345-B36ACD15EF81}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..b52ad14
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,22 @@
+# https://hub.docker.com/_/microsoft-dotnet
+FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+WORKDIR /app
+EXPOSE 80
+
+RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash -
+RUN apt-get install --yes nodejs
+
+# copy csproj and restore as distinct layers
+WORKDIR /src
+COPY . .
+RUN dotnet restore "Birdmap.API/Birdmap.API.csproj"
+
+# copy everything else and build app
+RUN dotnet publish "Birdmap.API/Birdmap.API.csproj" -c Release -o /app
+
+
+# final stage/image
+FROM mcr.microsoft.com/dotnet/aspnet:5.0
+WORKDIR /app
+COPY --from=build /app .
+ENTRYPOINT ["dotnet", "Birdmap.API.dll"]
diff --git a/docker-compose.dcproj b/docker-compose.dcproj
new file mode 100644
index 0000000..1b62b56
--- /dev/null
+++ b/docker-compose.dcproj
@@ -0,0 +1,18 @@
+
+
+
+ 2.1
+ Linux
+ 9443433b-1d13-41f0-b345-b36acd15ef81
+ LaunchBrowser
+ {Scheme}://localhost:{ServicePort}
+ birdmap.api
+
+
+
+ docker-compose.yml
+
+
+
+
+
\ No newline at end of file
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
new file mode 100644
index 0000000..b7c4c25
--- /dev/null
+++ b/docker-compose.override.yml
@@ -0,0 +1,13 @@
+version: '3.4'
+
+services:
+ birdmap.api:
+ environment:
+ - ASPNETCORE_ENVIRONMENT=Development
+ - ASPNETCORE_URLS=https://+:443;http://+:80
+ ports:
+ - "80"
+ - "443"
+ volumes:
+ - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
+ - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..1dd542d
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,21 @@
+version: '3.4'
+
+services:
+ db:
+ image: "mcr.microsoft.com/mssql/server:2017-latest"
+ environment:
+ - ACCEPT_EULA=Y
+ - SA_PASSWORD=asdfjkl-123
+
+ birdmap.api:
+ image: ${DOCKER_REGISTRY-}birdmapapi
+ ports:
+ - "8000:80"
+ - "5001:443"
+ build:
+ context: .
+ dockerfile: Birdmap.API/Dockerfile
+ depends_on:
+ - db
+ environment:
+ - ASPNETCORE_URLS=https://+:443;http://+:80