Fix image not running in K8s (ROSA)
Trying to solve the container exiting with error code `243`. `npm` throws `243` for any command you try to run with it.
Here is how to get into the container while the entrypoint normally errors.
```
$ oc run -i --tty --image=ghcr.io/matrix-org/matrix-public-archive/matrix-public-archive:sha-65edaea1a9713bb2cc93fa98638327fdeff765cd mpa-test2 --port=3050 --restart=Never --env="DOMAIN=cluster" --command /bin/bash
$ npm start
$ echo $?
243
```
Why does the same image work in Docker?
```
$ docker run -it --entrypoint /bin/bash ghcr.io/matrix-org/matrix-public-archive/matrix-public-archive:sha-65edaea1a9713bb2cc93fa98638327fdeff765cd
$ npm start
# it starts ✅
```
## Root cause
Seems like it could be either of these issues. Both are `8.6.0`+ problems as well which lines up with the `npm` version available in each base image.
- https://github.com/npm/cli/issues/4769
- https://github.com/npm/cli/issues/4996
- Specific comment about breaking stuff in k8s for other people, https://github.com/npm/cli/issues/4996#issuecomment-1150290804
Easy get the app running steps:
1. Install
2. Edit the config to point at your homeserver
3. Run the app!
---
This is made possible thanks to the change we made in https://github.com/matrix-org/matrix-public-archive/pull/20#discussion_r897567619 to start using a scoped custom version of `hydrogen-view-sdk`. This includes all of the scratch changes necessary to get this project running which makes the `npm install` just work out of the box without all of the `npm link` hassle.
1. Build test homeserver Docker images which can federate with each other
2. Run end-to-end (e2e) tests
#### Dev notes
Sharing variables across jobs when the `services` field can't access the `env` context, https://github.community/t/how-to-use-env-with-container-image/17252/24
```yaml
env:
FOO: bar
jobs:
set_env:
outputs:
var: ${{ steps.save_var.outputs.var }}
steps:
- id: save_var
run: echo "::set-output name=var::${{ env.FOO }}"
actual_job:
needs: set_env
container:
image: ...whatever_you_need_here...${{ needs.set_env.outputs.var }}
```
Remove `matrix-bot-sdk` usage in tests because it didn't have timestamp massaging `?ts` and it's not really necessary to rely on since we can just call the API directly 🤷. `matrix-bot-sdk` is also very annoying having to build rust crypto packages.
We're now using direct `fetch` requests against the Matrix API and lightweight `client` object.
All 3 current tests pass ✅
Get this project running again after a few months of changes
from `hydrogen-view-sdk` and now finally after
https://github.com/vector-im/hydrogen-web/pull/693
merged to make the SDK friendly to locally link and develop on.
Because we had to update the `assets` `export` to avoid the following deprecation warning:
```
(node:133896) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./assets/" in the "exports" field module resolution of the package at C:\Users\MLM\Documents\GitHub\element\matrix-public-archive\node_modules\hydrogen-view-sdk\package.json.
Update this package.json to use a subpath pattern like "./assets/*".
(Use `node --trace-deprecation ...` to show where the warning was created)
```
`hydrogen-view-sdk` `package.json` before:
```json
{
"exports": {
".": {
"import": "./lib-build/hydrogen.es.js",
"require": "./lib-build/hydrogen.cjs.js"
},
"./paths/vite": "./paths/vite.js",
"./style.css": "./style.css",
"./assets/": "./asset-build/assets/"
}
}
```
`hydrogen-view-sdk` `package.json` after:
```json
{
"exports": {
".": {
"import": "./lib-build/hydrogen.es.js",
"require": "./lib-build/hydrogen.cjs.js"
},
"./paths/vite": "./paths/vite.js",
"./style.css": "./style.css",
"./assets/*": "./asset-build/assets/*"
}
}
```