Open deftdawg opened 3 weeks ago
Hi @deftdawg, I published new docker images. However, I never saw this kind of error when starting with docker-compose
. What is your OS?
I pulled the latest from the repo and reran docker-compose
just now, result is the same. Also tried disabling the system firewall, no change.
The host OS is nixOS, a distribution of Linux.
Here's what I have for my docker networks and interfaces:
deftdawg maxsun ☎ ~ source rocketnotes main 1+ 1⚑ $ docker network ls
NETWORK ID NAME DRIVER SCOPE
a6ad9c151db9 bridge bridge local
2808ca3f183b host host local
c5707abeb32a local-ai-packaged_demo bridge local
b6c43989b8ab none null local
b0d82b2b4d5c rocketnotes_default bridge local
2d20ba9d1a3b rocketnotes_local-serverless-network bridge local
deftdawg maxsun ☎ ~ source rocketnotes main 1+ 1⚑ $ ifconfig -a
WireGuard: flags=209<UP,POINTOPOINT,RUNNING,NOARP> mtu 1420
inet 10.9.0.2 netmask 255.255.255.0 destination 10.9.0.2
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
RX packets 201098 bytes 173240852 (165.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 178101 bytes 23373824 (22.2 MiB)
TX errors 1932 dropped 0 overruns 0 carrier 0 collisions 0
enp10s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.176 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 2607:fea8:3b80:b530:2473:ec28:d852:3f1e prefixlen 64 scopeid 0x0<global>
inet6 2607:fea8:3b80:b530:9c4a:b8bc:5a87:ea52 prefixlen 64 scopeid 0x0<global>
inet6 fe80::2e2:69ff:fe63:3162 prefixlen 64 scopeid 0x20<link>
inet6 2607:fea8:3b80:b530:2e2:69ff:fe63:3162 prefixlen 64 scopeid 0x0<global>
ether 00:e2:69:63:31:62 txqueuelen 1000 (Ethernet)
RX packets 13690168 bytes 12838557173 (11.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16993518 bytes 22272594172 (20.7 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 946457 bytes 126273086 (120.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 946457 bytes 126273086 (120.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vboxnet0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.56.1 netmask 255.255.255.0 broadcast 0.0.0.0
ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 80 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:59:ed:dc txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 80 overruns 0 carrier 0 collisions 0
wlp11s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 56:98:49:55:38:52 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 298871
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19
I actually found I still had the old images from 7 months ago cached, so I rmi
-ed them...
The new api
container still crashes - though running another docker inside a Virtualbox VM (NixOS is hosting the VM), api
doesn't crash inside the VM; so maybe that's specific networking my NixOS machine or something.
The really bad news is now both my NixOS and my Virtualbox docker hosts both see the webapp
server crash with the following error:
rocketnotes-webapp | node:internal/modules/cjs/loader:1143
rocketnotes-webapp | throw err;
rocketnotes-webapp | ^
rocketnotes-webapp |
rocketnotes-webapp | Error: Cannot find module 'express'
rocketnotes-webapp | Require stack:
rocketnotes-webapp | - /root/server.js
rocketnotes-webapp | at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
rocketnotes-webapp | at Module._load (node:internal/modules/cjs/loader:981:27)
rocketnotes-webapp | at Module.require (node:internal/modules/cjs/loader:1231:19)
rocketnotes-webapp | at require (node:internal/modules/helpers:177:18)
rocketnotes-webapp | at Object.<anonymous> (/root/server.js:1:17)
rocketnotes-webapp | at Module._compile (node:internal/modules/cjs/loader:1364:14)
rocketnotes-webapp | at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
rocketnotes-webapp | at Module.load (node:internal/modules/cjs/loader:1203:32)
rocketnotes-webapp | at Module._load (node:internal/modules/cjs/loader:1019:12)
rocketnotes-webapp | at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
rocketnotes-webapp | code: 'MODULE_NOT_FOUND',
rocketnotes-webapp | requireStack: [ '/root/server.js' ]
rocketnotes-webapp | }
rocketnotes-webapp |
rocketnotes-webapp | Node.js v18.20.5
rocketnotes-webapp | node:internal/modules/cjs/loader:1143
rocketnotes-webapp | throw err;
rocketnotes-webapp | ^
rocketnotes-webapp |
rocketnotes-webapp | Error: Cannot find module 'express'
rocketnotes-webapp | Require stack:
rocketnotes-webapp | - /root/server.js
rocketnotes-webapp | at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
rocketnotes-webapp | at Module._load (node:internal/modules/cjs/loader:981:27)
rocketnotes-webapp | at Module.require (node:internal/modules/cjs/loader:1231:19)
rocketnotes-webapp | at require (node:internal/modules/helpers:177:18)
rocketnotes-webapp | at Object.<anonymous> (/root/server.js:1:17)
rocketnotes-webapp | at Module._compile (node:internal/modules/cjs/loader:1364:14)
rocketnotes-webapp | at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
rocketnotes-webapp | at Module.load (node:internal/modules/cjs/loader:1203:32)
rocketnotes-webapp | at Module._load (node:internal/modules/cjs/loader:1019:12)
rocketnotes-webapp | at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
rocketnotes-webapp | code: 'MODULE_NOT_FOUND',
rocketnotes-webapp | requireStack: [ '/root/server.js' ]
rocketnotes-webapp | }
rocketnotes-webapp |
rocketnotes-webapp | Node.js v18.20.5
The prior version of the webapp image from 7 months ago, used to start with only 1 line:
rocketnotes-webapp | Server listen on port 3001
If I manually start the container, I can get server.js to run if I use npm to install express:
root@3a82ca8c84c0:~# node ./server.js
node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module 'express'
Require stack:
- /root/server.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/root/server.js:1:17)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/root/server.js' ]
}
Node.js v18.20.5
root@3a82ca8c84c0:~# npm install express
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated string-similarity@1.1.0: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated rimraf@2.7.1: Rimraf versions prior to v4 are no longer supported
npm warn deprecated phin@2.9.3: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated
npm warn deprecated electron-notarize@1.2.2: Please use @electron/notarize moving forward. There is no API change, just a package name change
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm warn deprecated electron-packager@17.1.2: Please use @electron/packager moving forward. There is no API change, just a package name change
added 1031 packages, and audited 2220 packages in 29s
196 packages are looking for funding
run `npm fund` for details
38 vulnerabilities (9 low, 13 moderate, 12 high, 4 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues possible (including breaking changes), run:
npm audit fix --force
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
root@3a82ca8c84c0:~# node ./server.js
Server listen on port 3001
Looks like express is only automatically installed as a dev dep, when I run it without the omit, express gets installed. You might need to explicitly add it to your packages.json
EDIT: PR'd it #166
hitting http://localhost:3001 on my Virtualbox, I get bounced off to an OAuth2 server:
https://takeniftynotes.auth.eu-central-1.amazoncognito.com/login?response_type=code&client_id=tt3v27pnqqh7elqdvq9tgmr9v&redirect_uri=https://app.takeniftynotes.net
to prevent myself from being logged into takeniftynote.net, I add an /etc/hosts
entry 127.0.0.1 app.takeniftynotes.net
...
That gives me a ERR_CONNECTION_REFUSED
browser error, then I replace https://app.takeniftynotes.net/
with http://localhost:3001/
retaining the query string such that the whole URL looks like https://app.takeniftynotes.net/?code=...
I get logged in to the UI locally, some css and stuff are loading from it, but everything else is still going to Amazon in the EU (saveDocumentTitle -> 717zri8ug2.execute-api.eu-central-1.amazonaws.com)... The previous version of webapp seemed to do more locally (there were options for Ollama) even though the APIs were borked from my broken API server... :cry:
Thanks for your effort and awesome catch! I added a tiny comment to your PR, if you would like to address I am happy to merge.
Regarding the current images, I did a mistake with the environment of the image build. If you pull the webapp image again it should be fixed. Also the missing express is fixed. However the code change is not pushed, It can be done with your PR then 🙂
Good news is requests are correctly routing to localhost, bad news is everything going to 3002 is dying because of CORS :cry:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3002/saveDocument. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 502.
API server shows this in the log, attempting to saveDocument:
rocketnotes-api | 2024-11-22 23:29:41,078 | Cleaning all decompressed code dirs
rocketnotes-api | 2024-11-22 23:29:41,078 | Exception on /saveDocument [POST]
rocketnotes-api | Traceback (most recent call last):
rocketnotes-api | File "flask/app.py", line 1473, in wsgi_app
rocketnotes-api | File "flask/app.py", line 882, in full_dispatch_request
rocketnotes-api | File "flask/app.py", line 880, in full_dispatch_request
rocketnotes-api | File "flask/app.py", line 865, in dispatch_request
rocketnotes-api | File "samcli/local/apigw/local_apigw_service.py", line 731, in _request_handler
rocketnotes-api | File "samcli/local/apigw/local_apigw_service.py", line 619, in _invoke_lambda_function
rocketnotes-api | File "samcli/commands/local/lib/local_lambda.py", line 166, in invoke
rocketnotes-api | File "samcli/lib/telemetry/metric.py", line 325, in wrapped_func
rocketnotes-api | File "samcli/local/lambdafn/runtime.py", line 238, in invoke
rocketnotes-api | File "samcli/local/docker/container.py", line 442, in wait_for_result
rocketnotes-api | File "samcli/local/docker/container.py", line 488, in _wait_for_socket_connection
rocketnotes-api | File "samcli/local/docker/container.py", line 506, in _can_connect_to_socket
rocketnotes-api | socket.gaierror: [Errno -2] Name or service not known
rocketnotes-api | 2024-11-22 23:29:41,078 | Lambda execution failed (<InternalServerError '500: Internal Server Error'>,)
(This running inside the VM where API comes up okay)
Good news is requests are correctly routing to localhost, bad news is everything going to 3002 is dying because of CORS 😢
For me the latest containers are working. The CORS error is shown in the browser log even if the api container has an internal error. Do you have all containers running including dynamodb, S3 and the docker network? These are started if you are using docker-compose up
. Further, have you created the initial user profile with sh ./dynamodb-init.sh
?
Ran docker-compose up and then the s3-init script, thought that was all I was supposed to do; however I noticed last night the API server appears to be attempting to load its lambdas from the project directory on the Docker host.
Those directories are empty, seems like I need to do some steps to build or need to fix the api server to reference pre-built lambdas within the image assuming there are any. To build the lambdas looks it would need aws-cdk and golang from the cdk folders json, ran out of time before I got a chance to scan the readmes
Ah okay based on the Dockerfile.sam
, it looks like all the lambda-hander's in ./lambda-handler
are moved dropped into the the api server for the API server to compile... not sure why mine just hand empty directories under ./.aws-sam/build
... weird.
Ah I got it. If you pull the latest docker images I published few days ago it should work, since I was building the images locally. The images before were broken because these have been built and published in the pipeline. I just introduced that pipeline. But I made a mistake. In the pipeline sam build
is missing https://github.com/fynnfluegge/rocketnotes/blob/main/.github/workflows/docker-build-and-publish.yaml
That's why it was empty. A pipeline step sam build
must be added before the next release. Locally I had sam build
generated files available, that's why the latest
docker image works.
Nice finding! If you like you can raise a PR to fix it
Nice finding! If you like you can raise a PR to fix it
I'm not clear where sam build
step needs to be added... in the Dockerfile.sam?
here before the step Build and push Docker image api
https://github.com/fynnfluegge/rocketnotes/blob/main/.github/workflows/docker-build-and-publish.yaml
Maybe you better add it, I see sam build
line 51
https://github.com/fynnfluegge/rocketnotes/blob/1259e7096afcabb74062509fd18cd2db4aff239a/.github/workflows/docker-build-and-publish.yaml#L51
Oh ok sorry, I was blind, I added it already. Then I need to test this again after the next release, let's see
The API server doesn't start properly when doing
docker-compose up
, full log at the bottom.I tried to poke around within the container after...
docker run --rm -it -p 3002:3002 --entrypoint /bin/bash fynnfluegge/rocketnotes-api:latest
There was no
docker
command available in the path...