cap icon indicating copy to clipboard operation
cap copied to clipboard

Read file permissions in standalone mode

Open jcugmas opened this issue 1 year ago • 3 comments

Hi everyone,

I'm opening this issue because I'm facing to access file permissions error logs using Cap in standalone mode with Docker. I'm building my image using docker compose

cap:
    image: tiago2/cap:latest
    networks:
      - myNetwork
    ports:
      - "3000:3000"
    environment:
      - ADMIN_KEY=abcdefghijkl123456789
    volumes:
      - cap:/usr/src/app/.data

After the image was build and launched, I get the following error log

[asset server] error updating assets cache, trying to load them might fail: EACCES: permission denied, open '.data/assets-cache.json'
    path: ".data/assets-cache.json",
 syscall: "open",
   errno: -13,
    code: "EACCES"

Sometimes it can happen on the file keys.json and if so, the image cannot start.

Is it because I'm using for now a simple named volume ?

Moreover, I don't know if it's related but I have some errors when checking private key on uri /siteverify. Do we agree that the env variable ADMIN_KEY is used as private key ? Because if that so, I'm always getting an error 400 with message "Invalid Secret Key", I have debugged the code by just adding some log and I get

Received secret: [abcdefghijkl123456789]
Received hashed secret: [$argon2id$v=19$m=65536,t=2,p=1$g+olRaovQ/eNnF7itYe+5mh7hPJJu+wvw5hkCTBIpMg$sIDPGwozlyzMGmQYQdA3YNuwdJN1+AyTo+8yiKTsIio]
Stored   hashed secret: [$argon2id$v=19$m=65536,t=2,p=1$tGBXS3qYjRY03zeECGuZv0odVmErCiGoVgPp9Ftn/v8$9zrq3nWbl9QoQU4lEFWrz5aO8DXg0mUh6rj0TmOOOdw]

Am I doing something wrong ?

Thank you

Best regards

Infomration:

  • OS: Fedora 40
  • Docker version: 28.1.1
  • Docker desktop version: 4.41.1

jcugmas avatar May 12 '25 17:05 jcugmas

hi there, thanks for your report! i'll look into the permission denied error.

Do we agree that the env variable ADMIN_KEY is used as private key ?

No. The private key is what you got when you created your key in the dashboard, not the admin key.

tiagozip avatar May 12 '25 17:05 tiagozip

Hi,

Thanks for the quick answer.

Ok I didn't get if for the admin key.

The fact is when the image is launched, I have automatically a key named "test" created so I thought the admin key was used as well as private key. So my question is, for you, what is the best approach for the integration of the docker image in a CI/CD pipeline (gitlab for my case) and setting a known secret key and secret id ? Sorry it's not really the subject of the issue anymore...

Thank you

jcugmas avatar May 12 '25 18:05 jcugmas

this should have been fixed by [email protected]!

The fact is when the image is launched, I have automatically a key named "test" created so I thought the admin key was used as well as private key.

it no longer creates that key now too :)

So my question is, for you, what is the best approach for the integration of the docker image in a CI/CD pipeline (gitlab for my case) and setting a known secret key and secret id ?

I'm not familiar with Gitlab's CI/CD pipeline but it shouldn't be too hard but I recommend using the internal API:

https://github.com/tiagozip/cap/blob/d579c074584216eb1fec726769672e443ca94028/standalone/src/index.js#L163

to manage your keys and then push them to your code. You could also just save and then re-load the storage volume but I don't think that's the ideal option. I plan on adding a proper, documented key management api soon.

tiagozip avatar May 12 '25 18:05 tiagozip

Hi,

Thank you for the answers, I will check how to deal with it for the moment.

For the future, it can be interesting to have the possibility to init a key of our choice via environment variables like ADMIN_KEY, something like TEST_KEY_ID / TEST_KEY_SECRET / TEST_KEY_NAME to avoid dealing with the API and having something easy to set for testing pipelines.

Last question, did you push as well on docker hub ? Because I have still the same error after updating my image but it works when I build the image directly from the tar downloaded on github. Do you plan to add the versions on dockerHub to have the possibility to put a specific tag on a docker compose file for example ?

Thank you

Best regards

jcugmas avatar May 13 '25 07:05 jcugmas

For the future, it can be interesting to have the possibility to init a key of our choice via environment variables like ADMIN_KEY, something like TEST_KEY_ID / TEST_KEY_SECRET / TEST_KEY_NAME to avoid dealing with the API and having something easy to set for testing pipelines.

I think using the internal API is probably the best solution for now as it's simpler, but I'll consider that.

Last question, did you push as well on docker hub ? Because I have still the same error after updating my image but it works when I build the image directly from the tar downloaded on github. Do you plan to add the versions on dockerHub to have the possibility to put a specific tag on a docker compose file for example ?

yes, i had pushed it on docker. i just republished it under tag 1.0.10, can you try again?

tiagozip avatar May 13 '25 18:05 tiagozip

yes, i had pushed it on docker. i just republished it under tag 1.0.10, can you try again?

Yes perfect ! Thank you

Best regards

jcugmas avatar May 14 '25 07:05 jcugmas