diff --git a/README.md b/README.md index a545573..40a2f9a 100644 --- a/README.md +++ b/README.md @@ -26,21 +26,42 @@ Additionally, to test beatmap downloads, you may want to set up a local beatmap For advanced testing purposes. -| Envvar name | Description | Mandatory? | Default value | -|:-----------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------:|:--------------| -| `DB_HOST` | Hostname under which the `osu-web` MySQL instance can be found. | ❌ No | `localhost` | -| `DB_PORT` | Port under which the `osu-web` MySQL instance can be found. | ❌ No | `3306` | -| `DB_USER` | Username to use when logging into the `osu-web` MySQL instance. | ❌ No | `root` | -| `DB_PASS` | Password to use when logging into the `osu-web` MySQL instance. | ❌ No | `""` | -| `DB_NAME` | Name of database to use on the indicated MySQL instance. | ❌ No | `osu` | -| `JWT_VALID_AUDIENCE` | The value of the `aud` claim to use when validating incoming JWTs. Should be set to the client ID assigned to osu! in the `osu-web` target deploy. | ✔️ Yes | None | -| `LOCAL_BEATMAP_STORAGE_PATH` | The path of a directory where the submitted beatmaps should reside. | ⚠️ In development config | None | -| `LEGACY_IO_DOMAIN` | The root domain to which legacy IO requests should be directed to. | ✔️ Yes | None | -| `SHARED_INTEROP_SECRET` | The interop secret used for legacy IO requests. Value should match same environment variable in target `osu-web` instance. | ✔️ Yes | None | -| `S3_ACCESS_KEY` | A valid Amazon S3 access key ID. | ⚠ In staging/production configs | None | -| `S3_SECRET_KEY` | The secret key corresponding to the `S3_ACCESS_KEY`. | ⚠ In staging/production configs | None | -| `S3_CENTRAL_BUCKET_NAME` | The name of the S3 bucket to use for storing beatmap packages and versioned files. | ⚠ In staging/production configs | None | -| `S3_BEATMAPS_BUCKET_NAME` | The name of the S3 bucket to use for storing .osu beatmap files. | ⚠ In staging/production configs | None | -| `SENTRY_DSN` | A valid Sentry DSN to use for logging application events. | ⚠ In staging/production configs | None | -| `DD_AGENT_HOST` | A hostname pointing to a Datadog agent instance to which metrics should be reported. | ⚠ In staging/production configs | None | +This project supports three environment setups. +The choice of the environment is steered by the `ASPNETCORE_ENVIRONMENT` environment variable. +Depending on environment, this service changes behaviour with respect to interactions with external services. + +- `ASPNETCORE_ENVIRONMENT=Development`: + - Local (filesystem-based) beatmap storage is used. + - No purge requests to beatmap mirrors are made on beatmap updates. + - Developer exception pages & API docs (`/api-docs`) are enabled. + - Sentry & Datadog integrations are optional. +- `ASPNETCORE_ENVIRONMENT=Staging`: + - Local (filesystem-based) beatmap storage is used. + - No purge requests to beatmap mirrors are made on beatmap updates. + - Developer exception pages & API docs are disabled. + - Sentry integration is mandatory. + - Datadog integration is optional. +- `ASPNETCORE_ENVIRONMENT=Production`: + - S3-based beatmap storage is used. + - Purge requests to beatmap mirrors are made on beatmap updates. + - Developer exception pages & API docs are disabled. + - Sentry & Datadog integrations are mandatory. + +| Envvar name | Description | Mandatory? | Default value | +|:-----------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------:|:--------------| +| `DB_HOST` | Hostname under which the `osu-web` MySQL instance can be found. | ❌ No | `localhost` | +| `DB_PORT` | Port under which the `osu-web` MySQL instance can be found. | ❌ No | `3306` | +| `DB_USER` | Username to use when logging into the `osu-web` MySQL instance. | ❌ No | `root` | +| `DB_PASS` | Password to use when logging into the `osu-web` MySQL instance. | ❌ No | `""` | +| `DB_NAME` | Name of database to use on the indicated MySQL instance. | ❌ No | `osu` | +| `JWT_VALID_AUDIENCE` | The value of the `aud` claim to use when validating incoming JWTs. Should be set to the client ID assigned to osu! in the `osu-web` target deploy. | ✔️ Yes | None | +| `LOCAL_BEATMAP_STORAGE_PATH` | The path of a directory where the submitted beatmaps should reside. | ⚠️ In development & staging environment | None | +| `LEGACY_IO_DOMAIN` | The root domain to which legacy IO requests should be directed to. | ✔️ Yes | None | +| `SHARED_INTEROP_SECRET` | The interop secret used for legacy IO requests. Value should match same environment variable in target `osu-web` instance. | ✔️ Yes | None | +| `S3_ACCESS_KEY` | A valid Amazon S3 access key ID. | ⚠ In production environment | None | +| `S3_SECRET_KEY` | The secret key corresponding to the `S3_ACCESS_KEY`. | ⚠ In production environment | None | +| `S3_CENTRAL_BUCKET_NAME` | The name of the S3 bucket to use for storing beatmap packages and versioned files. | ⚠ In production environment | None | +| `S3_BEATMAPS_BUCKET_NAME` | The name of the S3 bucket to use for storing .osu beatmap files. | ⚠ In production environment | None | +| `SENTRY_DSN` | A valid Sentry DSN to use for logging application events. | ⚠ In staging & production environment | None | +| `DD_AGENT_HOST` | A hostname pointing to a Datadog agent instance to which metrics should be reported. | ⚠ In production environment | None | diff --git a/osu.Server.BeatmapSubmission/Program.cs b/osu.Server.BeatmapSubmission/Program.cs index d8113ef..4e74299 100644 --- a/osu.Server.BeatmapSubmission/Program.cs +++ b/osu.Server.BeatmapSubmission/Program.cs @@ -60,6 +60,22 @@ public static void Main(string[] args) } case "Staging": + { + builder.Services.AddSingleton(); + builder.Services.AddTransient(); + builder.Services.AddHttpClient(); + builder.Services.AddTransient(); + builder.Services.AddTransient(); + + if (AppSettings.SentryDsn == null) + { + throw new InvalidOperationException("SENTRY_DSN environment variable not set. " + + "Please set the value of this variable to a valid Sentry DSN to use for logging events."); + } + + break; + } + case "Production": { builder.Services.AddSingleton();