Преглед изворни кода

Fixed permissions issue in dockerfile

Tim Jones пре 1 месец
родитељ
комит
ff983fd07a
7 измењених фајлова са 25 додато и 11 уклоњено
  1. BIN
      .DS_Store
  2. 1 1
      README.md
  3. BIN
      RackPeek.Web/.DS_Store
  4. 3 1
      RackPeek.Web/Dockerfile
  5. 20 8
      RackPeek.Web/Program.cs
  6. 1 1
      notes.md
  7. BIN
      vhs/.DS_Store

+ 1 - 1
README.md

@@ -8,7 +8,7 @@ RackPeek is open source and community-driven.
 Code, docs, ideas, bug reports, and real-world usage feedback are all massively appreciated.
 Code, docs, ideas, bug reports, and real-world usage feedback are all massively appreciated.
 If you run a home lab, you belong here.
 If you run a home lab, you belong here.
 
 
-[![Join our Discord](https://img.shields.io/badge/Discord-Join%20Us-7289DA?logo=discord&logoColor=white)](https://discord.gg/egXRPdesee) [![Live Demo](https://img.shields.io/badge/Live%20Demo-Try%20RackPeek%20Online-2ea44f?logo=githubpages&logoColor=white)](https://timmoth.github.io/RackPeek/) [![Docker Hub](https://img.shields.io/badge/Docker%20Hub-rackpeek-2496ED?logo=docker&logoColor=white)](https://hub.docker.com/repository/docker/aptacode/rackpeek/general)
+[![Join our Discord](https://img.shields.io/badge/Discord-Join%20Us-7289DA?logo=discord&logoColor=white)](https://discord.gg/egXRPdesee) [![Live Demo](https://img.shields.io/badge/Live%20Demo-Try%20RackPeek%20Online-2ea44f?logo=githubpages&logoColor=white)](https://timmoth.github.io/RackPeek/) [![Docker Hub](https://img.shields.io/badge/Docker%20Hub-rackpeek-2496ED?logo=docker&logoColor=white)](https://hub.docker.com/r/aptacode/rackpeek/)
 
 
 We’re gathering feedback from homelabbers to validate direction and prioritize features.  
 We’re gathering feedback from homelabbers to validate direction and prioritize features.  
 Answer whichever questions stand out to you, your input directly shapes the project.
 Answer whichever questions stand out to you, your input directly shapes the project.

BIN
RackPeek.Web/.DS_Store


+ 3 - 1
RackPeek.Web/Dockerfile

@@ -23,8 +23,10 @@ RUN dotnet publish "./RackPeek.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publi
 FROM base AS final
 FROM base AS final
 WORKDIR /app
 WORKDIR /app
 
 
-# Directory expected to be mounted by the user
+RUN mkdir -p /app/config && chown -R $APP_UID /app/config
+
 VOLUME ["/app/config"]
 VOLUME ["/app/config"]
 
 
 COPY --from=publish /app/publish .
 COPY --from=publish /app/publish .
 ENTRYPOINT ["dotnet", "RackPeek.Web.dll"]
 ENTRYPOINT ["dotnet", "RackPeek.Web.dll"]
+

+ 20 - 8
RackPeek.Web/Program.cs

@@ -24,30 +24,42 @@ public class Program
         );
         );
 
 
         var yamlDir = "./config";
         var yamlDir = "./config";
+        var yamlFileName = "config.yaml";
+
         var basePath = Directory.GetCurrentDirectory();
         var basePath = Directory.GetCurrentDirectory();
 
 
-        // Resolve yamlDir as relative to basePath
         var yamlPath = Path.IsPathRooted(yamlDir)
         var yamlPath = Path.IsPathRooted(yamlDir)
             ? yamlDir
             ? yamlDir
             : Path.Combine(basePath, yamlDir);
             : Path.Combine(basePath, yamlDir);
 
 
-        if (!Directory.Exists(yamlPath))
-            throw new DirectoryNotFoundException(
-                $"YAML directory not found: {yamlPath}"
-            );
+        Directory.CreateDirectory(yamlPath);
+
+        var yamlFilePath = Path.Combine(yamlPath, yamlFileName);
+
+        if (!File.Exists(yamlFilePath))
+        {
+            // Create empty file safely
+            await using var fs = new FileStream(
+                yamlFilePath,
+                FileMode.CreateNew,
+                FileAccess.Write,
+                FileShare.None);
+            // optionally write default YAML content
+            await using var writer = new StreamWriter(fs);
+            await writer.WriteLineAsync("# default config");
+        }
 
 
         builder.Services.AddScoped<ITextFileStore, PhysicalTextFileStore>();
         builder.Services.AddScoped<ITextFileStore, PhysicalTextFileStore>();
 
 
         var resources = new ResourceCollection();
         var resources = new ResourceCollection();
         builder.Services.AddSingleton(resources);
         builder.Services.AddSingleton(resources);
-        
+
         builder.Services.AddScoped<IResourceCollection>(sp =>
         builder.Services.AddScoped<IResourceCollection>(sp =>
             new YamlResourceCollection(
             new YamlResourceCollection(
-                "./config/config.yaml",
+                yamlFilePath,
                 sp.GetRequiredService<ITextFileStore>(),
                 sp.GetRequiredService<ITextFileStore>(),
                 sp.GetRequiredService<ResourceCollection>()));
                 sp.GetRequiredService<ResourceCollection>()));
         
         
-        
         // Infrastructure
         // Infrastructure
         builder.Services.AddScoped<IHardwareRepository, YamlHardwareRepository>();
         builder.Services.AddScoped<IHardwareRepository, YamlHardwareRepository>();
         builder.Services.AddScoped<ISystemRepository, YamlSystemRepository>();
         builder.Services.AddScoped<ISystemRepository, YamlSystemRepository>();

+ 1 - 1
notes.md

@@ -28,7 +28,7 @@ chmod +x webui_capture.sh
 docker buildx build \
 docker buildx build \
   --platform linux/amd64,linux/arm64 \
   --platform linux/amd64,linux/arm64 \
   -f ./Dockerfile \
   -f ./Dockerfile \
-  -t aptacode/rackpeek:v0.0.3 \
+  -t aptacode/rackpeek:v0.0.5 \
   -t aptacode/rackpeek:latest \
   -t aptacode/rackpeek:latest \
   --push ..
   --push ..