feat: Dev Container (#1149)

* temporary dvctr

* start of work

* fix: timeouts in windows

* fish?

* feat: better, working stuff

* refactor: rename database-seeds to seeds/

* better

* fdsaf

* feat: don't let our container get owned by root

* fix: better user handling

* feat: falling asleep at my desk i yield to you what i have done

* feat: autoadminify

* docs: denote trickshot

* feat: open in browser on launch

* better seeds workings...

* fix: dont kill shell

* docs: mention dev/debs

* fix: whoops

* fix: make seeds load within the century

* feat: rest of the containerisation

* feat: new alias

* style: fix linter errors

* fix: bad call

* fix: better justfile
This commit is contained in:
zk
2024-08-17 15:01:40 +01:00
committed by GitHub
parent 14831a576c
commit 593adb2717
305 changed files with 6028 additions and 712 deletions
@@ -1,14 +1,11 @@
/* eslint-disable no-await-in-loop */
// This script syncs this tachi instances database up with the tachi-database-seeds.
import { Command } from "commander";
import db, { monkDB } from "external/mongo/db";
import fjsh from "fast-json-stable-hash";
import { PullDatabaseSeeds } from "lib/database-seeds/repo";
import CreateLogCtx from "lib/logger/logger";
import { UpdateGoalsInFolder } from "lib/score-import/framework/goals/goals";
import UpdateIsPrimaryStatus from "lib/score-mutation/update-isprimary";
import { ServerConfig, TachiConfig } from "lib/setup/config";
import { PullDatabaseSeeds } from "lib/seeds/repo";
import { TachiConfig } from "lib/setup/config";
import { RemoveStaleFolderShowcaseStats } from "lib/showcase/showcase";
import { UpdateQuestSubscriptions } from "lib/targets/quests";
import { RecalcAllScores } from "utils/calculations/recalc-scores";
@@ -98,7 +95,6 @@ async function GenericUpsert<T extends Record<string, any>>(
const exists = map.get(document[field]);
if (exists === undefined) {
logger.verbose(`Inserting new: ${document[field]}`);
insertOps.push({
// @ts-expect-error Actually, T is assignable to OptionalId<T>.
insertOne: { document },
@@ -361,23 +357,11 @@ const syncInstructions: Array<SyncInstructions> = [
const logger = CreateLogCtx("Database Sync");
const program = new Command();
program.option("-l, --localPath <path/to/database-seeds/collections>");
program.parse(process.argv);
const options: {
localPath: string | undefined;
} = program.opts();
async function SynchroniseDBWithSeeds() {
// Wait for mongo to connect first.
await monkDB.then(() => void 0);
const databaseSeedsRepo = await PullDatabaseSeeds(
options.localPath,
ServerConfig.SEEDS_CONFIG?.BRANCH
);
const databaseSeedsRepo = await PullDatabaseSeeds();
for await (const { collectionName, data } of databaseSeedsRepo.IterateCollections()) {
const spawnLogger = CreateLogCtx(`${collectionName} Sync`);