Skip to content

Commit

Permalink
Adjust staging environment configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Jan 10, 2025
1 parent 82190f3 commit 9186b7f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
54 changes: 37 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,41 @@ 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 & Datadog integrations are mandatory.
- `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 staging & production environment | None |

22 changes: 22 additions & 0 deletions osu.Server.BeatmapSubmission/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ public static void Main(string[] args)
}

case "Staging":
{
builder.Services.AddSingleton<IBeatmapStorage, LocalBeatmapStorage>();
builder.Services.AddTransient<BeatmapPackagePatcher>();
builder.Services.AddHttpClient();
builder.Services.AddTransient<ILegacyIO, LegacyIO>();
builder.Services.AddTransient<IMirrorService, NoOpMirrorService>();

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.");
}

if (AppSettings.DatadogAgentHost == null)
{
throw new InvalidOperationException("DD_AGENT_HOST environment variable not set. "
+ "Please set the value of this variable to a valid hostname of a Datadog agent.");
}

break;
}

case "Production":
{
builder.Services.AddSingleton<IBeatmapStorage, S3BeatmapStorage>();
Expand Down

0 comments on commit 9186b7f

Please sign in to comment.