Skip to content

Commit

Permalink
Added configuration options to support new certificate types.; bumped…
Browse files Browse the repository at this point in the history
… to version 1.1.0
  • Loading branch information
MattMckenzy committed Feb 16, 2024
1 parent 934f807 commit eb1075a
Show file tree
Hide file tree
Showing 20 changed files with 323 additions and 127 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/*.dockerfile
**/publish.ps1
**/launchSettings.json
LICENSE
README.md
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,6 @@ paket-files/
__pycache__/
*.pyc
/Build
appsettings.Development.json
appsettings.Production.json

# Debug secrets
**/.env
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net7.0/Mail2Gotify.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
},
{
"name": "Docker .NET Launch",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"netCore": {
"appProject": "${workspaceFolder}/Mail2Gotify.csproj"
}
}
]
}
120 changes: 120 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Mail2Gotify.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Mail2Gotify.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/Mail2Gotify.sln"
],
"problemMatcher": "$msCompile"
},
{
"type": "docker-build",
"label": "docker-build: debug",
"dependsOn": [
"build"
],
"dockerBuild": {
"tag": "mail2gotify:dev",
"target": "base",
"dockerfile": "${workspaceFolder}/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
},
"netCore": {
"appProject": "${workspaceFolder}/Mail2Gotify.csproj"
}
},
{
"type": "docker-build",
"label": "docker-build: release",
"dependsOn": [
"build"
],
"dockerBuild": {
"tag": "mail2gotify:latest",
"dockerfile": "${workspaceFolder}/Dockerfile",
"context": "${workspaceFolder}",
"platform": {
"os": "linux",
"architecture": "amd64"
},
"pull": true
},
"netCore": {
"appProject": "${workspaceFolder}/Mail2Gotify.csproj"
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build: debug"
],
"dockerRun": {
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://+:8122",
"TZ": "America/Toronto",
},
"volumes": [
{
"containerPath": "/cache",
"localPath": "${userHome}/Working/Mail2Gotify/Cache"
},
{
"containerPath": "/cert",
"localPath": "${userHome}/Working/Mail2Gotify/Cert"
}
],
"envFiles": [
"${workspaceFolder}/.env"
]
},
"netCore": {
"appProject": "${workspaceFolder}/Mail2Gotify.csproj",
"enableDebugging": true
}
},
{
"type": "docker-run",
"label": "docker-run: release",
"dependsOn": [
"docker-build: release"
],
"dockerRun": {},
"netCore": {
"appProject": "${workspaceFolder}/Mail2Gotify.csproj"
}
}
]
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Change Log

All notable changes to "Mail2Gotify" will be documented in this file.

## 1.1.0

- Added configuration options to support new certificate types.

## 1.0.0

- Initial release
21 changes: 8 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#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/runtime AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app
EXPOSE 587

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

FROM build AS publish
RUN dotnet publish "Mail2Gotify.csproj" -c Release -o /app/publish
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish
ARG TARGETARCH
ARG CONFIG
COPY . ./app
WORKDIR /app
RUN dotnet restore "Mail2Gotify.csproj" -a $TARGETARCH
RUN dotnet publish "Mail2Gotify.csproj" --self-contained -a $TARGETARCH -c $CONFIG -o publish

FROM base AS final
WORKDIR /app
Expand Down
7 changes: 0 additions & 7 deletions Exceptions/BadRequestException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,5 @@ public BadRequestException(string message) : base(message)
public BadRequestException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Constructor with serialization info and streaming context.
/// </summary>
protected BadRequestException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
9 changes: 0 additions & 9 deletions Exceptions/CommunicationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,5 @@ public CommunicationException(string message) : base(message)
public CommunicationException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Default constructor with which to serialize.
/// </summary>
/// <param name="info">The serialization info to use.</param>
/// <param name="context">The streaming context to use.</param>
protected CommunicationException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
7 changes: 0 additions & 7 deletions Exceptions/ConflictException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,5 @@ public ConflictException(string message) : base(message)
public ConflictException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Constructor with serialization info and streaming context.
/// </summary>
protected ConflictException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
9 changes: 0 additions & 9 deletions Exceptions/ForbiddenException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,5 @@ public ForbiddenException(string message) : base(message)
public ForbiddenException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Default constructor with which to serialize.
/// </summary>
/// <param name="info">The serialization info to use.</param>
/// <param name="context">The streaming context to use.</param>
protected ForbiddenException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
7 changes: 0 additions & 7 deletions Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,5 @@ public NotFoundException(string message) : base(message)
public NotFoundException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Constructor with serialization info and streaming context.
/// </summary>
protected NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
9 changes: 0 additions & 9 deletions Exceptions/UnauthorizedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,5 @@ public UnauthorizedException(string message) : base(message)
public UnauthorizedException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Default constructor with which to serialize.
/// </summary>
/// <param name="info">The serialization info to use.</param>
/// <param name="context">The streaming context to use.</param>
protected UnauthorizedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
9 changes: 0 additions & 9 deletions Exceptions/UnprocessableEntityException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,5 @@ public UnprocessableEntityException(string message) : base(message)
public UnprocessableEntityException(string message, Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Default constructor with which to serialize.
/// </summary>
/// <param name="info">The serialization info to use.</param>
/// <param name="context">The streaming context to use.</param>
protected UnprocessableEntityException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
39 changes: 17 additions & 22 deletions Mail2Gotify.csproj
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="MimeKit" Version="3.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="MimeKit" Version="4.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Polly" Version="8.1.0" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageReference Include="SmtpServer" Version="9.0.2" />
<PackageReference Include="SmtpServer" Version="10.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
6 changes: 6 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Mail2Gotify.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Polly;
Expand All @@ -18,6 +19,11 @@ static async Task Main(string[] args)
{
#pragma warning disable CA1416 // Validate platform compatibility
await Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(builder => {
builder.SetBasePath(Directory.GetCurrentDirectory());
builder.AddJsonFile($"appsettings.json", optional: false);
builder.AddEnvironmentVariables();
})
.UseContentRoot(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
.ConfigureServices((hostContext, services) =>
{
Expand Down
Loading

0 comments on commit eb1075a

Please sign in to comment.