Skip to content

Commit

Permalink
Switch to app user
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Wilms committed Nov 11, 2024
1 parent 476e946 commit 077998d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0
WORKDIR /app
COPY app .

USER app
ENTRYPOINT ["./Nexus"]
16 changes: 9 additions & 7 deletions src/Nexus/Core/NexusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,24 @@ internal record PathsOptions() : NexusOptionsBase, IPackageManagementPathsOption
public const string Section = "Paths";

public string Config { get; set; } = Path.Combine(PlatformSpecificRoot, "config");

public string Cache { get; set; } = Path.Combine(PlatformSpecificRoot, "cache");

public string Catalogs { get; set; } = Path.Combine(PlatformSpecificRoot, "catalogs");

public string Artifacts { get; set; } = Path.Combine(PlatformSpecificRoot, "artifacts");
public string Packages { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nexus", "packages");
// GetGlobalPackagesFolder: https://github.com/NuGet/NuGet.Client/blob/0fc58e13683565e7bdf30e706d49e58fc497bbed/src/NuGet.Core/NuGet.Configuration/Utility/SettingsUtility.cs#L225-L254
// GetFolderPath: https://github.com/NuGet/NuGet.Client/blob/1d75910076b2ecfbe5f142227cfb4fb45c093a1e/src/NuGet.Core/NuGet.Common/PathUtil/NuGetEnvironment.cs#L54-L57

public string Packages { get; set; } = Path.Combine(PlatformSpecificRoot, "packages");

#region Support

public static string DefaultSettingsPath { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Nexus", "settings.json")
: "/etc/nexus/settings.json";
? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Nexus", "settings.json")
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "nexus", "settings.json");

private static string PlatformSpecificRoot { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Nexus")
: "/var/lib/nexus";
? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Nexus")
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "nexus");

#endregion
}
Expand Down

0 comments on commit 077998d

Please sign in to comment.