feat: Make S3 bucket names configurable via environment variables

This commit is contained in:
Alexa
2026-06-25 14:04:36 +03:00
parent 98fa7b89cf
commit 44fc9047e0
2 changed files with 11 additions and 2 deletions
@@ -62,8 +62,8 @@ public interface IObjectStorage
public static class Buckets public static class Buckets
{ {
public const string Content = "dorknet-content"; public static string Content { get; set; } = "dorknet-content";
public const string Saves = "dorknet-saves"; public static string Saves { get; set; } = "dorknet-saves";
} }
/// <summary> /// <summary>
@@ -157,6 +157,13 @@ public class ObjectStorageService : IObjectStorage, IDisposable
{ {
_log = log; _log = log;
_diskFallbackRoot = Path.Combine(AppContext.BaseDirectory, "data", "object-fallback"); _diskFallbackRoot = Path.Combine(AppContext.BaseDirectory, "data", "object-fallback");
// Bucket names are env-overridable so a new game generation can point at
// fresh buckets (e.g. dorknet2023-*) without a code change. Applied here
// (before the disk/S3 branch) so the disk fallback paths use them too.
if (config["S3:ContentBucket"] is { Length: > 0 } contentBucket) Buckets.Content = contentBucket;
if (config["S3:SavesBucket"] is { Length: > 0 } savesBucket) Buckets.Saves = savesBucket;
_log.LogInformation(
"[storage] buckets content={Content} saves={Saves}", Buckets.Content, Buckets.Saves);
// Provider switch: env-driven. The Garage one-click service in // Provider switch: env-driven. The Garage one-click service in
// Coolify exposes its endpoint on http://garage:3900 and supplies // Coolify exposes its endpoint on http://garage:3900 and supplies
+2
View File
@@ -8,6 +8,8 @@ x-dorknet-service-env: &dorknet-service-env
S3__AccessKey: ${DORKNET_S3_ACCESS_KEY:?Set DORKNET_S3_ACCESS_KEY in Dokploy} S3__AccessKey: ${DORKNET_S3_ACCESS_KEY:?Set DORKNET_S3_ACCESS_KEY in Dokploy}
S3__SecretKey: ${DORKNET_S3_SECRET_KEY:?Set DORKNET_S3_SECRET_KEY in Dokploy} S3__SecretKey: ${DORKNET_S3_SECRET_KEY:?Set DORKNET_S3_SECRET_KEY in Dokploy}
S3__Region: ${DORKNET_S3_REGION:-garage} S3__Region: ${DORKNET_S3_REGION:-garage}
S3__ContentBucket: ${DORKNET_S3_CONTENT_BUCKET:-dorknet-content}
S3__SavesBucket: ${DORKNET_S3_SAVES_BUCKET:-dorknet-saves}
Photon__AppId: ${Photon__AppId:?Set Photon__AppId in Dokploy} Photon__AppId: ${Photon__AppId:?Set Photon__AppId in Dokploy}
Photon__VoiceAppId: ${Photon__VoiceAppId:-} Photon__VoiceAppId: ${Photon__VoiceAppId:-}
Photon__CloudRegion: ${Photon__CloudRegion:-eu} Photon__CloudRegion: ${Photon__CloudRegion:-eu}