Skip to content

Commit

Permalink
docker is now officially supported
Browse files Browse the repository at this point in the history
  • Loading branch information
mplogas committed Mar 15, 2024
1 parent 97e2933 commit 52de91e
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 13 deletions.
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**/.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
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
1 change: 1 addition & 0 deletions KernelMemory.FileWatcher.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{83
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
G:\docker\km-filewatcher\appsettings.json = G:\docker\km-filewatcher\appsettings.json
LICENSE.txt = LICENSE.txt
README.md = README.md
EndProjectSection
Expand Down
25 changes: 25 additions & 0 deletions KernelMemory.FileWatcher/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
USER 0
RUN mkdir -p /data /config
USER app
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["KernelMemory.FileWatcher/KernelMemory.FileWatcher.csproj", "KernelMemory.FileWatcher/"]
RUN dotnet restore "./KernelMemory.FileWatcher/./KernelMemory.FileWatcher.csproj"
COPY . .
WORKDIR "/src/KernelMemory.FileWatcher"
RUN dotnet build "./KernelMemory.FileWatcher.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./KernelMemory.FileWatcher.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "KernelMemory.FileWatcher.dll"]
4 changes: 4 additions & 0 deletions KernelMemory.FileWatcher/KernelMemory.FileWatcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileRunArguments>-v G:\docker\km-filewatcher\appsettings.json:/config/appsettings.json:rw -v E:\Resilio\Obsidian\PersonalVault\talks:/data/notes-talks:ro</DockerfileRunArguments>
<DockerfileBuildArguments>-t mplogas/km-filewatcher:dev</DockerfileBuildArguments>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,6 +25,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Serilog" Version="3.1.1">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion KernelMemory.FileWatcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static void StartWatcher(IServiceProvider services)

private static IHostBuilder CreateHostBuilder(string[] args)
{
var basePath = AppContext.BaseDirectory;
var basePath = File.Exists("/config/appsettings.json") ? "/config" : AppContext.BaseDirectory;
var configuration = new ConfigurationBuilder()
.SetBasePath(basePath)
.AddJsonFile("appsettings.json", false)
Expand Down
10 changes: 10 additions & 0 deletions KernelMemory.FileWatcher/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"KernelMemory.FileWatcher": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}
13 changes: 1 addition & 12 deletions KernelMemory.FileWatcher/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,11 @@
"Filter": "*.md",
"Index": "folder-02",
"IncludeSubdirectories": true
},
{
"Path": "E:\\Resilio\\Obsidian\\PersonalVault\\talks",
"Filters": [
"*.md",
"*.pdf",
"*.txt"
],
"Index": "notes-talks",
"IncludeSubdirectories": true,
"InitialScan": false
}
]
},
"KernelMemory": {
"Endpoint": "http://192.168.65.2:9001/upload",
"Endpoint": "http://127.0.0.1:9001",
"ApiKey": "",
"Schedule": "00:00:30"
}
Expand Down

0 comments on commit 52de91e

Please sign in to comment.