Skip to content

Commit

Permalink
Update to Node 22 (#431)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
vcarl authored Jan 14, 2025
1 parent 3dadd8f commit 11cf396
Show file tree
Hide file tree
Showing 43 changed files with 1,450 additions and 159 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: { sourceType: "module" },
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# TODO: see if we need to do anything special to cache docker images
- uses: actions/setup-node@v3
with:
node-version: 20
node-version: 22
cache: npm

- name: Login to GitHub Container Registry
Expand Down
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,78 @@ Useful saved commands, auto-moderation tools, and more, for the Reactiflux serve
Contact @vcarl (`@vcarl#7694` in Discord) for help getting into the test server.

See [the contributing guide](./CONTRIBUTING.md) for specific instructions.

## Testing deployment

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.

```sh
kubectl create secret generic reactibot-env \
--from-literal=DISCORD_HASH= \
--from-literal=DISCORD_PUBLIC_KEY= \
--from-literal=DISCORD_APP_ID= \
--from-literal=GUILD_ID= \
--from-literal=OPENAI_KEY='<only needed if testing resume review>' \
--from-literal=GH_READ_TOKEN='<only needed if testing React docs integration>' \
--from-literal=AMPLITUDE_KEY='<optional, use random string>'
```

(you can delete this secret with `kubectl delete secret reactibot-env`)

### Locally

Set up kubectl and minikube locally. It's kinda hard.

Start up a local Docker image registry.

```sh
docker run -d -p 5000:5000 --name registry registry:2.7
```

`-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`.

Create a file, `k8s-context`, in the project root, alongside the Dockerfile, with an IMAGE variable for kubectl to use.

```sh
echo IMAGE=reactibot:latest > k8s-context
```

Run a docker build and tag it. We need to retrieve the image ID of the build we run, which complicates the command.

```sh
docker build . -t reactibot
docker tag $(docker images reactibot:latest | tr -s ' ' | cut -f3 -d' ' | tail -n 1) localhost:5000/reactibot
```

Run a local deploy.

```sh
kubectl apply -k .
```

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`

### Testing with GHCR

I actually couldn't get a local registry working so I fell back on using ghcr.io, GitHub container registry.

Create a file, `k8s-context`, in the project root, alongside the Dockerfile, with an IMAGE variable for kubectl to use.

```sh
echo IMAGE=ghcr.io/<your gh>/reactibot:test > k8s-context
```

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.

```sh
docker build . -t <your gh>/reactibot:test
docker tag $(docker images <your gh>/reactibot:test | tr -s ' ' | cut -f3 -d' ' | tail -n 1) ghcr.io/<your gh>/reactibot:test
```

Run a local deploy.

```sh
kubectl apply -k .
```

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`
Loading

0 comments on commit 11cf396

Please sign in to comment.