Add project files.

This commit is contained in:
2026-02-21 10:30:14 -07:00
parent 398161da53
commit f662d576d1
28 changed files with 1127 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# Use the official .NET 10 ASP.NET runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
EXPOSE 8080
# Use the .NET 10 SDK for building
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# COPY both project files to restore dependencies
COPY ["paperless-ngx-export.service/paperless-ngx-export.service.csproj", "paperless-ngx-export.service/"]
COPY ["paperless-ngx-export/paperless-ngx-export.csproj", "paperless-ngx-export/"]
# Restore based on the main project
RUN dotnet restore "paperless-ngx-export.service/paperless-ngx-export.service.csproj"
# Copy everything else and build
COPY . .
WORKDIR "/src/paperless-ngx-export.service"
RUN dotnet build "paperless-ngx-export.service.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "paperless-ngx-export.service.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "paperless-ngx-export.service.dll"]

View File

@@ -0,0 +1,80 @@
using Microsoft.AspNetCore.Mvc;
using paperless_ngx_export;
using System.IO;
using System.Reflection.Metadata.Ecma335;
using System.Text;
namespace paperless_ngx_export.service
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", (IConfiguration config) =>
#if DEBUG
{
return Results.Content("<html><body><a href=\"/calendar\">Calendar</a><br /><a href=\"/spreadsheet\">Spreadsheet</a></body></html>", "text/html");
}
#else
"API"
#endif
);
app.MapGet("/calendar", async (IConfiguration config) =>
{
// Retrieve the environment variable
string? apiToken = config["PAPERLESS_TOKEN"];
string? apiBase = config["PAPERLESS_API_URI"];
if (apiToken == null)
{
return Results.Problem("PAPERLESS_TOKEN is missing from the environment.");
}
if (apiBase== null)
{
return Results.Problem("PAPERLESS_API_URI is missing from the environment.");
}
api.init(apiToken!, apiBase!);
var caldav = await api.getExpirationDatesCalDAVAsync();
return Results.Content(caldav, "text/calendar", Encoding.UTF8);
});
app.MapGet("/spreadsheet", async (IConfiguration config) =>
{
#if DEBUG
string? apiToken = "cfa320a52bec92cc7bef74415238ee000fc42a3c";
string? apiBase = "https://paperless.camcass.ca/api/";
#else
// Retrieve the environment variable
string? apiToken = config["PAPERLESS_TOKEN"];
string? apiBase = config["PAPERLESS_API_URI"];
#endif
if (apiToken == null)
{
return Results.Problem("PAPERLESS_TOKEN is missing from the environment.");
}
if (apiBase == null)
{
return Results.Problem("PAPERLESS_API_URI is missing from the environment.");
}
api.init(apiToken!, apiBase!);
var content = await spreadsheet.GetSummarySpreadsheetAsByteArrayAsync();
return Results.File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"Report.xlsx");
});
app.Run();
}
}
}

View File

@@ -0,0 +1,24 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5066"
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": false
}
},
"$schema": "https://json.schemastore.org/launchsettings.json"
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,9 @@
services:
paperless-ngx-export-api-service:
image: paperless-ngx-export-api
ports:
- "8082:8080"
environment:
- PAPERLESS_TOKEN=cfa320a52bec92cc7bef74415238ee000fc42a3c
- PAPERLESS_API_URI=https://paperless.camcass.ca/api/
restart: unless-stopped

View File

@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>paperness_ngx_export.service</RootNamespace>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\paperless-ngx-export\paperless-ngx-export.csproj" />
</ItemGroup>
</Project>