Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
deftdawg opened this issue Nov 8, 2024 · 21 comments
Open

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

deftdawg opened this issue Nov 8, 2024 · 21 comments

Comments

@deftdawg
Copy link
Contributor

deftdawg commented Nov 8, 2024

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated [email protected]: this library is no longer supported
npm warn deprecated [email protected]: this package is now deprecated
npm warn deprecated [email protected]: Please use @electron/notarize moving forward.  There is no API change, just a package name change
npm warn deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm warn deprecated [email protected]: 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
Copy link
Contributor Author

deftdawg commented Nov 22, 2024

RUN npm install --omit=dev

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
Copy link
Contributor Author

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

@fynnfluegge
Copy link
Owner

fynnfluegge commented Nov 22, 2024

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
Copy link
Contributor Author

deftdawg commented Nov 22, 2024

Good news is requests are correctly routing to localhost, bad news is everything going to 3002 is dying because of CORS 😢

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
Copy link
Owner

fynnfluegge commented Nov 24, 2024

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

fynnfluegge commented Nov 25, 2024

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
Copy link
Owner

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

@deftdawg
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

Maybe you better add it, I see sam build line 51

@fynnfluegge
Copy link
Owner

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

@s0lstice
Copy link

s0lstice commented Dec 5, 2024

Hello,

The same issue is happening on my end. I installed it yesterday. A few seconds after the first ‘docker-compose’, the ‘rocketnotes-API’ exited with code 1, with these logs:

[...]
Traceback (most recent call last):

  File "samcli/local/docker/utils.py", line 88, in is_docker_reachable

  File "docker/client.py", line 201, in ping

  File "docker/api/daemon.py", line 166, in ping

  File "docker/utils/decorators.py", line 44, in inner

  File "docker/api/client.py", line 246, in _get

  File "requests/sessions.py", line 602, in get

  File "requests/sessions.py", line 589, in request

  File "requests/sessions.py", line 703, in send

  File "requests/adapters.py", line 682, in send

requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused'))

2024-12-05 21:44:12,406 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2024-12-05 21:44:12,421 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2024-12-05 21:44:12,421 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '99d67dc3-6eac-444d-8ac2-219a58efa6c8', 'installationId': '364b7bbf-fb72-4a40-b57f-d58ef4023930', 'sessionId': 'e93b97c3-3e8b-46e0-a4f3-fb0f02a3b2ad', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.10', 'samcliVersion': '1.130.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local start-api', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '0ebb429fa86d481c2630fac53db1c91cffed5d4d41d1021c179444eb67e7ee0b', 'initialCommit': None}, 'duration': 2288, 'exitReason': 'DockerIsNotReachableException', 'exitCode': 1}}]}

2024-12-05 21:44:12,422 | Unable to find Click Context for getting session_id.

2024-12-05 21:44:12,422 | Sending Telemetry: {'metrics': [{'events': {'requestId': '8c9c60ee-182c-4c98-bc45-acaa1d676ceb', 'installationId': '364b7bbf-fb72-4a40-b57f-d58ef4023930', 'sessionId': 'e93b97c3-3e8b-46e0-a4f3-fb0f02a3b2ad', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.10', 'samcliVersion': '1.130.0', 'commandName': 'sam local start-api', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': '36a2837a07b548859642b381fcc4d6fb', 'time_stamp': '2024-12-05 21:44:10.089', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'e1255416a2d1400f938ec1064db31846', 'time_stamp': '2024-12-05 21:44:10.118', 'exception_name': None}]}}}]}

2024-12-05 21:44:12,968 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

2024-12-05 21:44:12,968 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?

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.

Does this PR fix something ? Maybe it hasn't accepted yet.

Thank you for sharing your work, I hop I can try it soon.

@deftdawg
Copy link
Contributor Author

deftdawg commented Dec 5, 2024

Nope, sadly my PR was just to fix the web container regression... API server still needs some kind of SAM fix, I don't know anything about SAM stuff, so just hoping for another release soonish so we can try again.

@fynnfluegge
Copy link
Owner

Hi, thanks for reporting @s0lstice. I am still not able to reproduce this error on my machine. Any kind of system information would be helpful

@deftdawg
Copy link
Contributor Author

deftdawg commented Dec 6, 2024

I'd offer to give you my current VM, but it's likely going to be ~40GB exported (I have a bunch of other unrelated OSS on it). I could try to reproduce a smaller Virtualbox VM next week that replicates the issue, if that would be of value.

@s0lstice
Copy link

s0lstice commented Dec 6, 2024

I have this issue on Debian 11 (VM) and Ubuntu 24.04.1 LTS,
On the Debian, only docker is installed and other containers are stopped.

Is AWS CLI required on host ? The ‘dynamodb-init’ script uses it, and there are no warning messages if there is a failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants