mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-27 02:21:27 +08:00
Merge f3a6b4d833 into 5d169e933a
This commit is contained in:
commit
5b086bdf4c
8 changed files with 246 additions and 30 deletions
|
|
@ -7,7 +7,9 @@ export async function setup(): Promise<void> {
|
|||
process.env.TZ = "UTC";
|
||||
|
||||
//use testcontainer to start mongodb
|
||||
const mongoContainer = new GenericContainer("mongo:5.0.13")
|
||||
const mongoContainer = new GenericContainer(
|
||||
"mongodb/mongodb-community-server:8.2.1-ubi8"
|
||||
)
|
||||
.withExposedPorts(27017)
|
||||
.withWaitStrategy(Wait.forListeningPorts());
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ services:
|
|||
|
||||
mongodb:
|
||||
container_name: monkeytype-mongodb
|
||||
image: mongo:5.0.13
|
||||
image: mongodb/mongodb-community-server:8.2.1-ubi8
|
||||
restart: on-failure
|
||||
ports:
|
||||
- "${DOCKER_DB_PORT:-27017}:27017"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ services:
|
|||
|
||||
mongodb:
|
||||
container_name: monkeytype-mongodb
|
||||
image: mongo:5.0.13
|
||||
image: mongodb/mongodb-community-server:8.2.1-ubi8
|
||||
restart: on-failure
|
||||
ports:
|
||||
- "${DOCKER_DB_PORT:-27017}:27017"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
"ioredis": "4.28.5",
|
||||
"lru-cache": "7.10.1",
|
||||
"mjml": "4.15.0",
|
||||
"mongodb": "6.3.0",
|
||||
"mongodb": "6.20.0",
|
||||
"mustache": "4.2.0",
|
||||
"nodemailer": "7.0.11",
|
||||
"object-hash": "3.0.0",
|
||||
|
|
|
|||
|
|
@ -57,6 +57,11 @@ export async function connect(): Promise<void> {
|
|||
try {
|
||||
await mongoClient.connect();
|
||||
db = mongoClient.db(DB_NAME);
|
||||
|
||||
const info = (await db.command({ buildInfo: 1 })) as { version: string };
|
||||
if (info.version !== "8.2.1") {
|
||||
throw new Error("Expected version 8.2.1 but got " + info.version);
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(getErrorMessage(error) ?? "Unknown error");
|
||||
Logger.error(
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ services:
|
|||
|
||||
monkeytype-mongodb:
|
||||
container_name: monkeytype-mongodb
|
||||
image: mongo:5.0.13
|
||||
image: mongodb/mongodb-community-server:8.2.1-ubi8
|
||||
restart: on-failure
|
||||
volumes:
|
||||
- mongo-data:/data/db
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
# Monkeytype Self Hosting
|
||||
|
||||
<!-- TOC ignore:true -->
|
||||
|
||||
## Table of contents
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
- [Monkeytype Self Hosting](#monkeytype-self-hosting)
|
||||
- [Table of contents](#table-of-contents)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Quickstart](#quickstart)
|
||||
- [Account System](#account-system)
|
||||
|
|
@ -20,6 +15,12 @@
|
|||
- [env file](#env-file)
|
||||
- [serviceAccountKey.json](#serviceaccountkeyjson)
|
||||
- [backend-configuration.json](#backend-configurationjson)
|
||||
- [Upgrades](#upgrades)
|
||||
- [v.....](#v)
|
||||
- [Backup](#backup)
|
||||
- [Upgrade MongoDB with dump/restore](#upgrade-mongodb--with-dumprestore)
|
||||
- [Upgrade MongoDB incremental](#upgrade-mongodb-incremental)
|
||||
- [References](#references)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
|
|
@ -190,3 +191,212 @@ Configuration of the backend. Check the [default configuration](https://github.c
|
|||
|
||||
> [!NOTE]
|
||||
> Configuration changes are applied only on container startup. You must restart the container for your updates to take effect.
|
||||
|
||||
|
||||
## Upgrades
|
||||
|
||||
### v.....
|
||||
|
||||
Starting with this version you will need to update the MongoDB container from 5.0 to 8.2. Follow the steps carefully.
|
||||
|
||||
#### Backup
|
||||
|
||||
Make sure the container is _STOPPED_ and run this command:
|
||||
|
||||
```
|
||||
docker run --rm -v monkeytype_mongo_data:/from -v $(pwd):/backup alpine tar czf /backup/monkeytype-mongodb.tar.gz -C /from .
|
||||
```
|
||||
|
||||
In case you need to restore the backup run this commands:
|
||||
|
||||
```
|
||||
docker volume rm monkeytype_mongo_data
|
||||
docker volume create monkeytype_mongo_data
|
||||
docker run --rm -v monkeytype_mongo_data:/to -v $(pwd):/backup alpine tar xzf /backup/monkeytype-mongodb.tar.gz -C /to
|
||||
|
||||
```
|
||||
|
||||
There are two ways to update your MongoDB instance to 8.2. You can use the dump/restore method if your database is not very huge and you have the storage for the full database dump. If not follow the guide for [Upgrade MongoDB incremental](#upgrade-mongodb-incremental)
|
||||
|
||||
#### Upgrade MongoDB with dump/restore
|
||||
|
||||
Make sure the container is _STOPPED_ and execute this command:
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name mongodb-upgrade \
|
||||
-v monkeytype_mongo_data:/data/db \
|
||||
-v $(pwd):/backup \
|
||||
-p 27017:27017 \
|
||||
mongo:5.0.13
|
||||
```
|
||||
|
||||
Then dump the data using
|
||||
|
||||
```
|
||||
docker exec -it mongodb-upgrade \
|
||||
mongodump --db=monkeytype --out=/backup
|
||||
```
|
||||
|
||||
And stop the container again:
|
||||
|
||||
```
|
||||
docker stop mongodb-upgrade
|
||||
docker rm mongodb-upgrade
|
||||
```
|
||||
|
||||
Then replace the volume with an empty one:
|
||||
|
||||
```
|
||||
docker volume rm monkeytype_mongo_data
|
||||
docker volume create monkeytype_mongo_data
|
||||
```
|
||||
|
||||
Now start a new container with version 8.2
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name mongodb-upgrade \
|
||||
-v monkeytype_mongo_data:/data/db \
|
||||
-v $(pwd):/backup \
|
||||
-p 27017:27017 \
|
||||
mongodb/mongodb-community-server:8.2.1-ubi8
|
||||
```
|
||||
|
||||
|
||||
Then restore the data using
|
||||
|
||||
```
|
||||
docker exec -it mongodb-upgrade \
|
||||
mongorestore --host=localhost --port=27017 \
|
||||
--db=monkeytype \
|
||||
--drop \
|
||||
/backup/monkeytype
|
||||
```
|
||||
|
||||
And stop the container again:
|
||||
|
||||
```
|
||||
docker stop mongodb-upgrade
|
||||
docker rm mongodb-upgrade
|
||||
```
|
||||
|
||||
At this point the MongoDB container is upgraded to version 8.2.
|
||||
|
||||
Now you can start your instance with `docker compose` as normal.
|
||||
|
||||
#### Upgrade MongoDB incremental
|
||||
|
||||
MongoDB needs to be upgraded for each major version. Don't skip any of theese steps:
|
||||
|
||||
Make sure the container is _STOPPED_ and run this command:
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name mongodb-upgrade \
|
||||
-v monkeytype_mongo_data:/data/db \
|
||||
-p 27017:27017 \
|
||||
mongo:6.0
|
||||
```
|
||||
|
||||
When the container is _HEALTHY_ run this command:
|
||||
|
||||
```
|
||||
docker exec -it mongodb-upgrade mongosh --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } )'
|
||||
```
|
||||
|
||||
Wait a few seconds and execute:
|
||||
|
||||
```
|
||||
docker stop mongodb-upgrade
|
||||
docker rm mongodb-upgrade
|
||||
```
|
||||
|
||||
At this point the MongoDB container is upgraded to version 6.0.
|
||||
|
||||
Make sure the container is _STOPPED_ and run this command:
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name mongodb-upgrade \
|
||||
-v monkeytype_mongo_data:/data/db \
|
||||
-p 27017:27017 \
|
||||
mongo:7.0
|
||||
```
|
||||
|
||||
When the container is _HEALTHY_ run this command:
|
||||
|
||||
```
|
||||
docker exec -it mongodb-upgrade mongosh --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "7.0", confirm: true } )'
|
||||
```
|
||||
|
||||
Wait a few seconds and execute:
|
||||
|
||||
```
|
||||
docker stop mongodb-upgrade
|
||||
docker rm mongodb-upgrade
|
||||
```
|
||||
|
||||
At this point the MongoDB container is upgraded to version 7.0.
|
||||
|
||||
Make sure the container is _STOPPED_ and run this command:
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name mongodb-upgrade \
|
||||
-v monkeytype_mongo_data:/data/db \
|
||||
-p 27017:27017 \
|
||||
mongo:8.0
|
||||
```
|
||||
|
||||
When the container is _HEALTHY_ run this command:
|
||||
|
||||
```
|
||||
docker exec -it mongodb-upgrade mongosh --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "8.0", confirm: true } )'
|
||||
```
|
||||
|
||||
Wait a few seconds and execute:
|
||||
|
||||
```
|
||||
docker stop mongodb-upgrade
|
||||
docker rm mongodb-upgrade
|
||||
```
|
||||
|
||||
At this point the MongoDB container is upgraded to version 8.0.
|
||||
|
||||
Make sure the container is _STOPPED_ and run this command:
|
||||
|
||||
```
|
||||
docker run --rm -v monkeytype_mongo_data:/data/db alpine chown -R 998:996 /data/db
|
||||
```
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name mongodb-upgrade \
|
||||
-v monkeytype_mongo_data:/data/db \
|
||||
-p 27017:27017 \
|
||||
mongodb/mongodb-community-server:8.2.1-ubi8
|
||||
```
|
||||
|
||||
When the container is _HEALTHY_ run this command:
|
||||
|
||||
```
|
||||
docker exec -it mongodb-upgrade mongosh --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "8.2", confirm: true } )'
|
||||
```
|
||||
|
||||
Wait a few seconds and execute:
|
||||
|
||||
```
|
||||
docker stop mongodb-upgrade
|
||||
docker rm mongodb-upgrade
|
||||
```
|
||||
|
||||
At this point the MongoDB container is upgraded to version 8.2.
|
||||
|
||||
Now you can start your instance with `docker compose` as normal.
|
||||
|
||||
#### References
|
||||
- https://www.mongodb.com/docs/v6.0/release-notes/6.0-upgrade-standalone/
|
||||
- https://www.mongodb.com/docs/v7.0/release-notes/7.0-upgrade-standalone/
|
||||
- https://www.mongodb.com/docs/v8.0/release-notes/8.0-upgrade-standalone/#std-label-8.0-upgrade-standalone
|
||||
- https://www.mongodb.com/docs/manual/release-notes/8.2-upgrade-standalone/
|
||||
|
|
|
|||
39
pnpm-lock.yaml
generated
39
pnpm-lock.yaml
generated
|
|
@ -126,8 +126,8 @@ importers:
|
|||
specifier: 4.15.0
|
||||
version: 4.15.0(encoding@0.1.13)
|
||||
mongodb:
|
||||
specifier: 6.3.0
|
||||
version: 6.3.0(socks@2.8.3)
|
||||
specifier: 6.20.0
|
||||
version: 6.20.0(socks@2.8.3)
|
||||
mustache:
|
||||
specifier: 4.2.0
|
||||
version: 4.2.0
|
||||
|
|
@ -2355,8 +2355,8 @@ packages:
|
|||
'@mdn/browser-compat-data@5.7.6':
|
||||
resolution: {integrity: sha512-7xdrMX0Wk7grrTZQwAoy1GkvPMFoizStUoL+VmtUkAxegbCCec+3FKwOM6yc/uGU5+BEczQHXAlWiqvM8JeENg==}
|
||||
|
||||
'@mongodb-js/saslprep@1.1.8':
|
||||
resolution: {integrity: sha512-qKwC/M/nNNaKUBMQ0nuzm47b7ZYWQHN3pcXq4IIcoSBc2hOIrflAxJduIvvqmhoz3gR2TacTAs8vlsCVPkiEdQ==}
|
||||
'@mongodb-js/saslprep@1.3.2':
|
||||
resolution: {integrity: sha512-QgA5AySqB27cGTXBFmnpifAi7HxoGUeezwo6p9dI03MuDB6Pp33zgclqVb6oVK3j6I9Vesg0+oojW2XxB59SGg==}
|
||||
|
||||
'@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3':
|
||||
resolution: {integrity: sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==}
|
||||
|
|
@ -3891,10 +3891,9 @@ packages:
|
|||
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
||||
hasBin: true
|
||||
|
||||
bson@6.8.0:
|
||||
resolution: {integrity: sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ==}
|
||||
bson@6.10.4:
|
||||
resolution: {integrity: sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==}
|
||||
engines: {node: '>=16.20.1'}
|
||||
deprecated: a critical bug affecting only useBigInt64=true deserialization usage is fixed in bson@6.10.3
|
||||
|
||||
buffer-crc32@1.0.0:
|
||||
resolution: {integrity: sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==}
|
||||
|
|
@ -6881,19 +6880,19 @@ packages:
|
|||
moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
|
||||
mongodb-connection-string-url@3.0.1:
|
||||
resolution: {integrity: sha512-XqMGwRX0Lgn05TDB4PyG2h2kKO/FfWJyCzYQbIhXUxz7ETt0I/FqHjUeqj37irJ+Dl1ZtU82uYyj14u2XsZKfg==}
|
||||
mongodb-connection-string-url@3.0.2:
|
||||
resolution: {integrity: sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==}
|
||||
|
||||
mongodb@6.3.0:
|
||||
resolution: {integrity: sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==}
|
||||
mongodb@6.20.0:
|
||||
resolution: {integrity: sha512-Tl6MEIU3K4Rq3TSHd+sZQqRBoGlFsOgNrH5ltAcFBV62Re3Fd+FcaVf8uSEQFOJ51SDowDVttBTONMfoYWrWlQ==}
|
||||
engines: {node: '>=16.20.1'}
|
||||
peerDependencies:
|
||||
'@aws-sdk/credential-providers': ^3.188.0
|
||||
'@mongodb-js/zstd': ^1.1.0
|
||||
'@mongodb-js/zstd': ^1.1.0 || ^2.0.0
|
||||
gcp-metadata: ^5.2.0
|
||||
kerberos: ^2.0.1
|
||||
mongodb-client-encryption: '>=6.0.0 <7'
|
||||
snappy: ^7.2.2
|
||||
snappy: ^7.3.2
|
||||
socks: ^2.7.1
|
||||
peerDependenciesMeta:
|
||||
'@aws-sdk/credential-providers':
|
||||
|
|
@ -11516,7 +11515,7 @@ snapshots:
|
|||
|
||||
'@mdn/browser-compat-data@5.7.6': {}
|
||||
|
||||
'@mongodb-js/saslprep@1.1.8':
|
||||
'@mongodb-js/saslprep@1.3.2':
|
||||
dependencies:
|
||||
sparse-bitfield: 3.0.3
|
||||
|
||||
|
|
@ -13156,7 +13155,7 @@ snapshots:
|
|||
node-releases: 2.0.27
|
||||
update-browserslist-db: 1.2.3(browserslist@4.28.0)
|
||||
|
||||
bson@6.8.0: {}
|
||||
bson@6.10.4: {}
|
||||
|
||||
buffer-crc32@1.0.0: {}
|
||||
|
||||
|
|
@ -16819,16 +16818,16 @@ snapshots:
|
|||
|
||||
moment@2.30.1: {}
|
||||
|
||||
mongodb-connection-string-url@3.0.1:
|
||||
mongodb-connection-string-url@3.0.2:
|
||||
dependencies:
|
||||
'@types/whatwg-url': 11.0.5
|
||||
whatwg-url: 13.0.0
|
||||
|
||||
mongodb@6.3.0(socks@2.8.3):
|
||||
mongodb@6.20.0(socks@2.8.3):
|
||||
dependencies:
|
||||
'@mongodb-js/saslprep': 1.1.8
|
||||
bson: 6.8.0
|
||||
mongodb-connection-string-url: 3.0.1
|
||||
'@mongodb-js/saslprep': 1.3.2
|
||||
bson: 6.10.4
|
||||
mongodb-connection-string-url: 3.0.2
|
||||
optionalDependencies:
|
||||
socks: 2.8.3
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue