notea-org / notea

πŸ“’ Self hosted note taking app stored on S3
2.06k stars 377 forks source link

Internal Server Error on Docker Method #30

Closed ilovefreesw closed 3 years ago

ilovefreesw commented 3 years ago

image

Docker command:

testo101@testo:~$ sudo docker run -d \
>   --name notea \
>   -p 3000:3000 \
>   -e STORE_ACCESS_KEY=AKIAJxxxxxxxxxxZQ \
>   -e STORE_SECRET_KEY=Sv7xxxxxxxxxxxxxxxxxxxxxxxxxxxxftym \
>   -e STORE_BUCKET=notea \
>   -e STORE_REGION=us-east-1 \
>   -e STORE_FORCE_PATH_STYLE=true \
>   -e PASSWORD=notea \
>   cinwell/notea
[sudo] password for testo101: 
Unable to find image 'cinwell/notea:latest' locally
latest: Pulling from cinwell/notea
540db60ca938: Pull complete 
7e50016d5624: Pull complete 
c43b2bfd1b9f: Pull complete 
97029819a1de: Pull complete 
74236504af82: Pull complete 
7560e3ae15b8: Pull complete 
ab919bc89f13: Pull complete 
6081e29b8041: Pull complete 
Digest: sha256:ba75a9425b64fee7c77e07b4fed131c54d35274a30be8089fef59bcacda89a22
Status: Downloaded newer image for cinwell/notea:latest
ba936740feca497449a0bbc3e0e54f0b1ffef084a776d69c0b6127d88b1b2741
QingWei-Li commented 3 years ago

Please take a look at docker log. Did you manually create the bucket?

sbkg0002 commented 3 years ago

I have the same error when using Exoscale S3.

Docker logs gives me:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5TypeError: Cannot read property 'byteLength' of undefined
    at Object.fromArrayBuffer (/app/node_modules/@aws-sdk/util-buffer-from/dist/cjs/index.js:6:60)
    at castSourceData (/app/node_modules/@aws-sdk/hash-node/dist/cjs/index.js:29:31)
    at Hash.update (/app/node_modules/@aws-sdk/hash-node/dist/cjs/index.js:12:26)
    at hmac (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/credentialDerivation.js:60:10)
    at Object.getSigningKey (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/credentialDerivation.js:32:29)
    at SignatureV4.getSigningKey (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/SignatureV4.js:139:39)
    at SignatureV4.signRequest (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/SignatureV4.js:98:73)
    at async /app/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js:14:22
    at async StandardRetryStrategy.retry (/app/node_modules/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:56:46)
    at async /app/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22 {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

Edit; running today's latest, on a empty bucket.

ilovefreesw commented 3 years ago

For some reasons, I couldn't create notea bucket so I used an existing one. Logs in my case:

testo101@testo:~/Downloads$ sudo docker logs 6a
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5
PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
    at deserializeAws_restXmlGetObjectCommandError (/app/node_modules/@aws-sdk/client-s3/dist/cjs/protocols/Aws_restXml.js:6184:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /app/node_modules/@aws-sdk/middleware-serde/dist/cjs/deserializerMiddleware.js:6:20
    at async /app/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js:12:24
    at async StandardRetryStrategy.retry (/app/node_modules/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:56:46)
    at async /app/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
    at async StoreS3.getObject (/app/.next/server/pages/index.js:2379:22)
    at async getSettings (/app/.next/server/pages/index.js:6795:44)
    at async handler (/app/.next/server/pages/index.js:2219:18)
    at async handler (/app/.next/server/pages/index.js:6896:17) {
  Code: 'PermanentRedirect',
  Endpoint: 'ilfstesting.s3-us-west-2.amazonaws.com',
  Bucket: 'ilfstesting',
  RequestId: '7193SM52DAAGZEXC',
  HostId: '3TQ0EeNQs3U5gZcjYJMZVdKO1iOQqjDrrJupOLbDaULJqU4xiD6tFT7sNPeqjtBa0XM4SXxz46M=',
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 301,
    requestId: undefined,
    extendedRequestId: '3TQ0EeNQs3U5gZcjYJMZVdKO1iOQqjDrrJupOLbDaULJqU4xiD6tFT7sNPeqjtBa0XM4SXxz46M=',
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}
ilovefreesw commented 3 years ago

For some reasons, I couldn't create notea bucket so I used an existing one. Logs in my case:

testo101@testo:~/Downloads$ sudo docker logs 6a
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5
PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
    at deserializeAws_restXmlGetObjectCommandError (/app/node_modules/@aws-sdk/client-s3/dist/cjs/protocols/Aws_restXml.js:6184:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /app/node_modules/@aws-sdk/middleware-serde/dist/cjs/deserializerMiddleware.js:6:20
    at async /app/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js:12:24
    at async StandardRetryStrategy.retry (/app/node_modules/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:56:46)
    at async /app/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
    at async StoreS3.getObject (/app/.next/server/pages/index.js:2379:22)
    at async getSettings (/app/.next/server/pages/index.js:6795:44)
    at async handler (/app/.next/server/pages/index.js:2219:18)
    at async handler (/app/.next/server/pages/index.js:6896:17) {
  Code: 'PermanentRedirect',
  Endpoint: 'ilfstesting.s3-us-west-2.amazonaws.com',
  Bucket: 'ilfstesting',
  RequestId: '7193SM52DAAGZEXC',
  HostId: '3TQ0EeNQs3U5gZcjYJMZVdKO1iOQqjDrrJupOLbDaULJqU4xiD6tFT7sNPeqjtBa0XM4SXxz46M=',
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 301,
    requestId: undefined,
    extendedRequestId: '3TQ0EeNQs3U5gZcjYJMZVdKO1iOQqjDrrJupOLbDaULJqU4xiD6tFT7sNPeqjtBa0XM4SXxz46M=',
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}
QingWei-Li commented 3 years ago

@sbkg0002 Please check if STORE_ACCESS_KEY or other env variable is missing.

This has a similar problem https://stackoverflow.com/questions/66731661/aws-cognito-client-sdk-v3-returns-bytelength-of-undefined-when-running-admin-d

QingWei-Li commented 3 years ago

@ilovefreesw You are missing STORE_END_POINT

ilovefreesw commented 3 years ago

@ilovefreesw You are missing STORE_END_POINT

Sorry not I am not much of a technical person. What should I set it to ? 0.0.0.0 ? and in S3 configuration, there is no STORE_END_POINT on the read me page..

sbkg0002 commented 3 years ago

Thanks @QingWei-Li . Using the provided Minio compose + the example .env file - which has STORE_END_POINT, I still get this error.

QingWei-Li commented 3 years ago

@ilovefreesw Are you using MinIO or Amazon S3? If it’s amazon s3, you don’t need to set STORE_FORCE_PATH_STYLE=true

ilovefreesw commented 3 years ago

@ilovefreesw Are you using MinIO or Amazon S3? If it’s amazon s3, you don’t need to set STORE_FORCE_PATH_STYLE=true

Yes I am using S3. So I don't have to set STORE_END_POINT ? right? In my second attempt, I didn't use STORE_FORCE_PATH_STYLE=true and still got the same error.

QingWei-Li commented 3 years ago

@sbkg0002 Sorry .env.example is mssing STORE_FORCE_PATH_STYLE. Are you using MinIO or Amazon S3?

I think I need to add environment variable verification..πŸ˜‚

sbkg0002 commented 3 years ago

I'm using S3 compatible service by Exoscale.

Using this simple compose, it works:

version: '2'

services:
  minio:
    image: minio/minio
    ports:
      - '9000:9000'
    environment:
      - MINIO_ACCESS_KEY="minio"
      - MINIO_SECRET_KEY="minio123"
    entrypoint: sh
    command: -c 'mkdir -p /data/notea && /usr/bin/minio server /data'
    networks:
    - notea

  notea:
    container_name: notea
    image: cinwell/notea
    ports:
      - '3030:3000'
    environment:
      - STORE_ACCESS_KEY="minio"
      - STORE_SECRET_KEY="minio123"
      - STORE_BUCKET=notea
      - 'STORE_END_POINT=http://minio:9000'
      - STORE_FORCE_PATH_STYLE=true
      - PASSWORD=notea
    networks:
      - notea

networks:
  notea: {}
ilovefreesw commented 3 years ago

Also, in the log it says : Endpoint: 'ilfstesting.s3-us-west-2.amazonaws.com' But my region is us-east-1. I am no expert but is this right or some sort of internal bug?

QingWei-Li commented 3 years ago

@ilovefreesw Maybe your key belongs to s3-us-west-2 not us-east-1.

ilovefreesw commented 3 years ago

@ilovefreesw Maybe your key belongs to s3-us-west-2 not us-east-1.

No, I always use us-east-1 whenever I need S3. I have never used us-west-2. I am sure.

ilovefreesw commented 3 years ago

I'm using S3 compatible service by Exoscale.

How that works for you. I get error in that as well.

image

sbkg0002 commented 3 years ago

It doesn't πŸ˜„ I still get the Notea 500 | Internal Server Error. page.

EDIT: @ilovefreesw Via that compose file the Notea is available on port 3030 (since 3000 is used by Grafana on my server)

QingWei-Li commented 3 years ago

@ilovefreesw I have no idea... Maybe you can try to set STORE_END_POINT=ilfstesting.s3-us-east-1.amazonaws.com or just set STORE_REGION=us-west-2

sbkg0002 commented 3 years ago

I tried with and without the region (since that seems to be part of the endpoint), but no juice with this .env.

STORE_ACCESS_KEY=<somthing>
STORE_SECRET_KEY=<somthing>
STORE_BUCKET=notea
STORE_END_POINT=https://sos-de-fra-1.exo.io
STORE_REGION=de-fra-1
PASSWORD=notea
STORE_FORCE_PATH_STYLE=true

I did create the bucket upfront.

QingWei-Li commented 3 years ago

@sbkg0002 What is the latest error log

ilovefreesw commented 3 years ago

@ilovefreesw I have no idea... Maybe you can try to set STORE_END_POINT=ilfstesting.s3-us-east-1.amazonaws.com or just set STORE_REGION=us-west-2

Nope... still it's not going to work :/

image

sbkg0002 commented 3 years ago

@sbkg0002 What is the latest error log

Really the same error:

info  - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5TypeError: Cannot read property 'byteLength' of undefined
    at Object.fromArrayBuffer (/app/node_modules/@aws-sdk/util-buffer-from/dist/cjs/index.js:6:60)
    at castSourceData (/app/node_modules/@aws-sdk/hash-node/dist/cjs/index.js:29:31)
    at Hash.update (/app/node_modules/@aws-sdk/hash-node/dist/cjs/index.js:12:26)
    at hmac (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/credentialDerivation.js:60:10)
    at Object.getSigningKey (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/credentialDerivation.js:32:29)
    at SignatureV4.getSigningKey (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/SignatureV4.js:139:39)
    at SignatureV4.signRequest (/app/node_modules/@aws-sdk/signature-v4/dist/cjs/SignatureV4.js:98:73)
    at async /app/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js:14:22
    at async StandardRetryStrategy.retry (/app/node_modules/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:56:46)
    at async /app/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22 {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

This is with these settings:

STORE_BUCKET=notea
STORE_END_POINT=https://sos-de-fra-1.exo.io
STORE_REGION=de-fra-1
PASSWORD=notea
STORE_FORCE_PATH_STYLE=true
QingWei-Li commented 3 years ago

@sbkg0002 maybe you don't need STORE_FORCE_PATH_STYLE

ilovefreesw commented 3 years ago

Lmao .. it doesn't work on Vercel either πŸ˜‚πŸ˜‚πŸ˜³πŸ˜³

image

QingWei-Li commented 3 years ago

@ilovefreesw https://stackoverflow.com/questions/41071208/permanentredirect-exception-aws-sdk-s3-rails-5

try this

STORE_ACCESS_KEY=[your access key]
STORE_SECRET_KEY=[your secret key]
STORE_BUCKET=ilfstesting
STORE_REGION=us-east-1
STORE_END_POINT=https://s3.us-east-1.amazonaws.com
PASSWORD=123

or try to replace all us-east-1 to us-west-2

ilovefreesw commented 3 years ago

@ilovefreesw https://stackoverflow.com/questions/41071208/permanentredirect-exception-aws-sdk-s3-rails-5

try this

STORE_ACCESS_KEY=[your access key]
STORE_SECRET_KEY=[your secret key]
STORE_BUCKET=ilfstesting
STORE_REGION=us-east-1
STORE_END_POINT=https://s3.us-east-1.amazonaws.com
PASSWORD=123

or try to replace all us-east-1 to us-west-2

It worked by replacing us-east-1 with us-west-2

I'll try to do the same with Docker and will report back.

image

Edit: Tested on Docker and works now there as well.

Correct docker command:

sudo docker run -d \
>   --name notea \
>   -p 3000:3000 \
>   -e STORE_ACCESS_KEY=AKIxxxxxxxxxxQ \
>   -e STORE_SECRET_KEY=Svxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxm \
>   -e STORE_BUCKET=ilfstesting \
>   -e STORE_REGION=us-west-2 \
>   -e STORE_END_POINT=https://s3.us-west-2.amazonaws.com \
>   -e PASSWORD=pass@123 \
>   cinwell/notea

image

sbkg0002 commented 3 years ago

For some reason, this works - sorta: the login page is there, but entering the correct password doesn't do anything; even the log doesn't mention it. Entering the wrong password, gives incorrect password and gets an API_ERR_NEED_LOGIN in the logs.

docker run -it --rm   --name notea   -p 3040:3000   -e STORE_ACCESS_KEY=[...]   -e STOR
E_SECRET_KEY=[...]   -e STORE_BUCKET=notea   -e STORE_REGION=de-fra-1   -e STORE_END_PO
INT=https://sos-de-fra-1.exo.io   -e PASSWORD=pass@123  cinwell/notea

Any ideas?

QingWei-Li commented 3 years ago

@sbkg0002 You mean can't login via http://localhost:3040? It may be a limitation of the browser. However, you need to set COOKIE_SECURE=false if website is not https.

sbkg0002 commented 3 years ago

COOKIE_SECURE=false

I run in on a server, but still the winner πŸ‘