This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimized the Code and added a Dockerfile
- Loading branch information
1 parent
8a8ded2
commit ca69da4
Showing
6 changed files
with
208 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/.idea | ||
**/*.*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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ obj/ | |
riderModule.iml | ||
/_ReSharper.Caches/ | ||
/.idea/ | ||
config.xml | ||
config.xml | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base | ||
WORKDIR /app | ||
EXPOSE 5102 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
WORKDIR /src | ||
COPY ["KekUploadServer/KekUploadServer.csproj", "KekUploadServer/"] | ||
RUN dotnet restore "KekUploadServer/KekUploadServer.csproj" | ||
COPY . . | ||
WORKDIR "/src/KekUploadServer" | ||
RUN dotnet build "KekUploadServer.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "KekUploadServer.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
RUN apt update | ||
RUN apt install -y ffmpeg | ||
RUN rm -rf /var/lib/apt/lists/* | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
RUN mkdir -p /app/config/ | ||
WORKDIR /app/config | ||
ENTRYPOINT ["dotnet", "../KekUploadServer.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,57 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace KekUploadServer.Controllers; | ||
|
||
public class FrontendController : Controller | ||
namespace KekUploadServer.Controllers | ||
{ | ||
[Route("/")] | ||
[HttpGet] | ||
public IActionResult Index() | ||
public class FrontendController : Controller | ||
{ | ||
return File(new FileStream(Data.EnsureNotNullConfig().WebRoot + "index.html", FileMode.Open), "text/html"); | ||
} | ||
[HttpGet("/")] | ||
public IActionResult Index() | ||
{ | ||
var filePath = Path.Combine(Data.EnsureNotNullConfig().WebRoot, "index.html"); | ||
return PhysicalFile(filePath, "text/html"); | ||
} | ||
|
||
[Route("theme.js")] | ||
[HttpGet] | ||
public IActionResult Theme() | ||
{ | ||
return File(new FileStream(Data.EnsureNotNullConfig().WebRoot + "theme.js", FileMode.Open), "text/javascript"); | ||
} | ||
[HttpGet("theme.js")] | ||
public IActionResult Theme() | ||
{ | ||
var filePath = Path.Combine(Data.EnsureNotNullConfig().WebRoot, "theme.js"); | ||
return PhysicalFile(filePath, "text/javascript"); | ||
} | ||
|
||
[Route("themes/{theme}")] | ||
[HttpGet] | ||
public IActionResult Themes(string theme) | ||
{ | ||
return File(new FileStream(Data.EnsureNotNullConfig().WebRoot + "themes/" + theme, FileMode.Open), "text/css"); | ||
} | ||
[HttpGet("themes/{theme}")] | ||
public IActionResult Themes(string theme) | ||
{ | ||
var filePath = Path.Combine(Data.EnsureNotNullConfig().WebRoot, "themes", theme); | ||
return PhysicalFile(filePath, "text/css"); | ||
} | ||
|
||
[Route("assets/{asset}")] | ||
[HttpGet] | ||
public IActionResult Assets(string asset) | ||
{ | ||
var file = Data.EnsureNotNullConfig().WebRoot + "assets/" + asset; | ||
var fileInfo = new FileInfo(file); | ||
return File(new FileStream(file, FileMode.Open), | ||
"text/" + fileInfo.Extension.Replace(".", "").Replace("js", "javascript")); | ||
} | ||
[HttpGet("assets/{asset}")] | ||
public IActionResult Assets(string asset) | ||
{ | ||
var filePath = Path.Combine(Data.EnsureNotNullConfig().WebRoot, "assets", asset); | ||
var contentType = GetContentType(filePath); | ||
return PhysicalFile(filePath, contentType); | ||
} | ||
|
||
[Route("favicon.{ext}")] | ||
[HttpGet] | ||
public IActionResult Favicon(string ext) | ||
{ | ||
return File(new FileStream(Data.EnsureNotNullConfig().WebRoot + "favicon." + ext, FileMode.Open), | ||
"image/" + ext); | ||
[HttpGet("favicon.{ext}")] | ||
public IActionResult Favicon(string ext) | ||
{ | ||
var filePath = Path.Combine(Data.EnsureNotNullConfig().WebRoot, $"favicon.{ext}"); | ||
var contentType = GetContentType(filePath); | ||
return PhysicalFile(filePath, contentType); | ||
} | ||
|
||
private static string GetContentType(string filePath) | ||
{ | ||
var extension = Path.GetExtension(filePath); | ||
return extension switch | ||
{ | ||
".css" => "text/css", | ||
".js" => "text/javascript", | ||
".png" => "image/png", | ||
".ico" => "image/x-icon", | ||
_ => "application/octet-stream", | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.