fynnfluegge / rocketnotes

AI-powered Markdown note taking app - leverage vector embeddings and LLMs with your personal notes - 100% local or in the cloud
https://www.takeniftynotes.net
MIT License
1.07k stars 56 forks source link

API server doesn't start under docker-compose #156

Open deftdawg opened 3 weeks ago

deftdawg commented 3 weeks ago

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

[deftdawg@maxsun:~/source/rocketnotes]$ docker-compose logs api
rocketnotes-api  | 2024-11-08 21:28:31,365 | No config file found in this directory.
rocketnotes-api  | 2024-11-08 21:28:31,365 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/var/task/samconfig.toml'
rocketnotes-api  | 2024-11-08 21:28:31,365 | Config file location: /var/task/samconfig.toml
rocketnotes-api  | 2024-11-08 21:28:31,365 | Config file '/var/task/samconfig.toml' does not exist
rocketnotes-api  | 2024-11-08 21:28:31,376 | Using SAM Template at /var/task/.aws-sam/build/template.yaml
rocketnotes-api  | 2024-11-08 21:28:31,384 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/var/task/samconfig.toml'
rocketnotes-api  | 2024-11-08 21:28:31,384 | Using config file: samconfig.toml, config environment: default
rocketnotes-api  | 2024-11-08 21:28:31,384 | Expand command line arguments to:
rocketnotes-api  | 2024-11-08 21:28:31,384 | --template_file=/var/task/.aws-sam/build/template.yaml --host=0.0.0.0 --port=3002 --docker_volume_basedir=/home/deftdawg/source/rocketnotes/.aws-sam/build --docker_network=rocketnotes_local-serverless-network --static_dir=public --layer_cache_basedir=/root/.aws-sam/layers-pkg --container_host=localhost --container_host_interface=127.0.0.1
rocketnotes-api  | 2024-11-08 21:28:31,432 | local start-api command is called
rocketnotes-api  | 2024-11-08 21:28:31,442 | No Parameters detected in the template
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource helloWorldFunction is helloWorldFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getDocumentFunction is getDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getDocumentTreeFunction is getDocumentTreeFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentFunction is saveDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentTreeFunction is saveDocumentTreeFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentPublicFunction is saveDocumentPublicFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentTitleFunction is saveDocumentTitleFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource searchDocumentFunction is searchDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getSharedDocumentFunction is getSharedDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveVectorEmbeddingsFunction is saveVectorEmbeddingsFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource semanticSearchFunction is semanticSearchFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource chatFunction is chatFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveUserConfigFunction is saveUserConfigFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getUserConfigFunction is getUserConfigFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | Sam customer defined id is more priority than other IDs. Customer defined id for resource textCompletionFunction is textCompletionFunction
rocketnotes-api  | 2024-11-08 21:28:31,456 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
rocketnotes-api  | 2024-11-08 21:28:31,457 | 0 stacks found in the template
rocketnotes-api  | 2024-11-08 21:28:31,457 | No Parameters detected in the template
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource helloWorldFunction is helloWorldFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getDocumentFunction is getDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getDocumentTreeFunction is getDocumentTreeFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentFunction is saveDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentTreeFunction is saveDocumentTreeFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentPublicFunction is saveDocumentPublicFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveDocumentTitleFunction is saveDocumentTitleFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource searchDocumentFunction is searchDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getSharedDocumentFunction is getSharedDocumentFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveVectorEmbeddingsFunction is saveVectorEmbeddingsFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource semanticSearchFunction is semanticSearchFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource chatFunction is chatFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource saveUserConfigFunction is saveUserConfigFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource getUserConfigFunction is getUserConfigFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | Sam customer defined id is more priority than other IDs. Customer defined id for resource textCompletionFunction is textCompletionFunction
rocketnotes-api  | 2024-11-08 21:28:31,469 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
rocketnotes-api  | 2024-11-08 21:28:31,470 | 16 resources found in the stack
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='helloWorldFunction' and CodeUri='helloWorldFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='getDocumentFunction' and CodeUri='getDocumentFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='getDocumentTreeFunction' and CodeUri='getDocumentTreeFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='saveDocumentFunction' and CodeUri='saveDocumentFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='saveDocumentTreeFunction' and CodeUri='saveDocumentTreeFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='saveDocumentPublicFunction' and CodeUri='saveDocumentPublicFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='saveDocumentTitleFunction' and CodeUri='saveDocumentTitleFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='searchDocumentFunction' and CodeUri='searchDocumentFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='getSharedDocumentFunction' and CodeUri='getSharedDocumentFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='saveVectorEmbeddingsFunction' and ImageUri='savevectorembeddingsfunction:latest'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='semanticSearchFunction' and ImageUri='semanticsearchfunction:latest'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='chatFunction' and ImageUri='chatfunction:latest'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='saveUserConfigFunction' and CodeUri='saveUserConfigFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='getUserConfigFunction' and CodeUri='getUserConfigFunction'
rocketnotes-api  | 2024-11-08 21:28:31,471 | Found Serverless function with name='textCompletionFunction' and CodeUri='textCompletionFunction'
rocketnotes-api  | 2024-11-08 21:28:31,472 | Docker is not reachable
rocketnotes-api  | Traceback (most recent call last):
rocketnotes-api  |   File "urllib3/connectionpool.py", line 791, in urlopen
rocketnotes-api  |   File "urllib3/connectionpool.py", line 497, in _make_request
rocketnotes-api  |   File "urllib3/connection.py", line 395, in request
rocketnotes-api  |   File "http/client.py", line 1293, in endheaders
rocketnotes-api  |   File "http/client.py", line 1052, in _send_output
rocketnotes-api  |   File "http/client.py", line 990, in send
rocketnotes-api  |   File "docker/transport/unixconn.py", line 27, in connect
rocketnotes-api  | ConnectionRefusedError: [Errno 111] Connection refused
rocketnotes-api  |
rocketnotes-api  | During handling of the above exception, another exception occurred:
rocketnotes-api  |
rocketnotes-api  | Traceback (most recent call last):
rocketnotes-api  |   File "requests/adapters.py", line 486, in send
rocketnotes-api  |   File "urllib3/connectionpool.py", line 845, in urlopen
rocketnotes-api  |   File "urllib3/util/retry.py", line 470, in increment
rocketnotes-api  |   File "urllib3/util/util.py", line 38, in reraise
rocketnotes-api  |   File "urllib3/connectionpool.py", line 791, in urlopen
rocketnotes-api  |   File "urllib3/connectionpool.py", line 497, in _make_request
rocketnotes-api  |   File "urllib3/connection.py", line 395, in request
rocketnotes-api  |   File "http/client.py", line 1293, in endheaders
rocketnotes-api  |   File "http/client.py", line 1052, in _send_output
rocketnotes-api  |   File "http/client.py", line 990, in send
rocketnotes-api  |   File "docker/transport/unixconn.py", line 27, in connect
rocketnotes-api  | urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))
rocketnotes-api  |
rocketnotes-api  | During handling of the above exception, another exception occurred:
rocketnotes-api  |
rocketnotes-api  | Traceback (most recent call last):
rocketnotes-api  |   File "samcli/local/docker/utils.py", line 91, in is_docker_reachable
rocketnotes-api  |   File "docker/client.py", line 201, in ping
rocketnotes-api  |   File "docker/api/daemon.py", line 166, in ping
rocketnotes-api  |   File "docker/utils/decorators.py", line 44, in inner
rocketnotes-api  |   File "docker/api/client.py", line 236, in _get
rocketnotes-api  |   File "requests/sessions.py", line 602, in get
rocketnotes-api  |   File "requests/sessions.py", line 589, in request
rocketnotes-api  |   File "requests/sessions.py", line 703, in send
rocketnotes-api  |   File "requests/adapters.py", line 501, in send
rocketnotes-api  | requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))
rocketnotes-api  | 2024-11-08 21:28:31,473 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
rocketnotes-api  | 2024-11-08 21:28:31,480 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
rocketnotes-api  | 2024-11-08 21:28:31,480 | Unable to find Click Context for getting session_id.
rocketnotes-api  | Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?
fynnfluegge commented 1 week 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?

deftdawg commented 1 week ago

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
deftdawg commented 1 week ago

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
deftdawg commented 1 week ago

https://github.com/fynnfluegge/rocketnotes/blob/50ac58ba96fea01348496f9ce3927ffa1ce34e39/webapp/Dockerfile#L7

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

deftdawg commented 1 week ago

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:

fynnfluegge commented 1 week ago

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 🙂

deftdawg commented 1 week ago

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)

fynnfluegge commented 6 days ago

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?

deftdawg commented 5 days ago

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

deftdawg commented 5 days ago

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.

fynnfluegge commented 5 days ago

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.

fynnfluegge commented 5 days ago

Nice finding! If you like you can raise a PR to fix it

deftdawg commented 5 days ago

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?

fynnfluegge commented 5 days ago

here before the step Build and push Docker image api https://github.com/fynnfluegge/rocketnotes/blob/main/.github/workflows/docker-build-and-publish.yaml

deftdawg commented 4 days ago

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

fynnfluegge commented 4 days ago

Oh ok sorry, I was blind, I added it already. Then I need to test this again after the next release, let's see