Skip to content

Commit 11cf396

Browse files
authored
Update to Node 22 (#431)
* Update tsconfig target & module * Webserver deps * Use node 22 * Modernized or whatever * Update readme * node16 module resolution * Update TS to 5.7 * build with tsc -b * Add some local deploy testing instructions * Make it work in node 22 * Fix prettier
1 parent 3dadd8f commit 11cf396

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1450
-159
lines changed

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
root: true,
33
parser: "@typescript-eslint/parser",
4+
parserOptions: { sourceType: "module" },
45
plugins: ["@typescript-eslint"],
56
extends: [
67
"eslint:recommended",

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
# TODO: see if we need to do anything special to cache docker images
2121
- uses: actions/setup-node@v3
2222
with:
23-
node-version: 20
23+
node-version: 22
2424
cache: npm
2525

2626
- name: Login to GitHub Container Registry

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,78 @@ Useful saved commands, auto-moderation tools, and more, for the Reactiflux serve
77
Contact @vcarl (`@vcarl#7694` in Discord) for help getting into the test server.
88

99
See [the contributing guide](./CONTRIBUTING.md) for specific instructions.
10+
11+
## Testing deployment
12+
13+
You must have a working `.env` file that enables you to run the bot locally. With the values in `.env`, create a `reactibot-env` secret in your local minikube cluster. Everything must be provided a value, but it's okay if some of them are just random strings.
14+
15+
```sh
16+
kubectl create secret generic reactibot-env \
17+
--from-literal=DISCORD_HASH= \
18+
--from-literal=DISCORD_PUBLIC_KEY= \
19+
--from-literal=DISCORD_APP_ID= \
20+
--from-literal=GUILD_ID= \
21+
--from-literal=OPENAI_KEY='<only needed if testing resume review>' \
22+
--from-literal=GH_READ_TOKEN='<only needed if testing React docs integration>' \
23+
--from-literal=AMPLITUDE_KEY='<optional, use random string>'
24+
```
25+
26+
(you can delete this secret with `kubectl delete secret reactibot-env`)
27+
28+
### Locally
29+
30+
Set up kubectl and minikube locally. It's kinda hard.
31+
32+
Start up a local Docker image registry.
33+
34+
```sh
35+
docker run -d -p 5000:5000 --name registry registry:2.7
36+
```
37+
38+
`-d` means this will run in "detached mode", so it will exit without logs after pulling required images and starting. You can view logs for it with `docker logs -f registry`.
39+
40+
Create a file, `k8s-context`, in the project root, alongside the Dockerfile, with an IMAGE variable for kubectl to use.
41+
42+
```sh
43+
echo IMAGE=reactibot:latest > k8s-context
44+
```
45+
46+
Run a docker build and tag it. We need to retrieve the image ID of the build we run, which complicates the command.
47+
48+
```sh
49+
docker build . -t reactibot
50+
docker tag $(docker images reactibot:latest | tr -s ' ' | cut -f3 -d' ' | tail -n 1) localhost:5000/reactibot
51+
```
52+
53+
Run a local deploy.
54+
55+
```sh
56+
kubectl apply -k .
57+
```
58+
59+
If it doesn't deploy correctly (e.g. `kubectl get pods` shows a status other than success), you can debug it with `kubectl describe pod reactibot-deployment`
60+
61+
### Testing with GHCR
62+
63+
I actually couldn't get a local registry working so I fell back on using ghcr.io, GitHub container registry.
64+
65+
Create a file, `k8s-context`, in the project root, alongside the Dockerfile, with an IMAGE variable for kubectl to use.
66+
67+
```sh
68+
echo IMAGE=ghcr.io/<your gh>/reactibot:test > k8s-context
69+
```
70+
71+
Run a docker build, tag it, and push to the registry. We need to retrieve the image ID of the build we run, which complicates the command.
72+
73+
```sh
74+
docker build . -t <your gh>/reactibot:test
75+
docker tag $(docker images <your gh>/reactibot:test | tr -s ' ' | cut -f3 -d' ' | tail -n 1) ghcr.io/<your gh>/reactibot:test
76+
```
77+
78+
Run a local deploy.
79+
80+
```sh
81+
kubectl apply -k .
82+
```
83+
84+
If it doesn't deploy correctly (e.g. `kubectl get pods` shows a status other than success), you can debug it with `kubectl describe pod reactibot-deployment`

0 commit comments

Comments
 (0)