cozy / cozy-drive

Cozy Drive Web App for Cozy Cloud
GNU Affero General Public License v3.0
168 stars 63 forks source link

Difficulties to setup the dev environment #2903

Open Peltoche opened 1 year ago

Peltoche commented 1 year ago

Hi :wave:

I have some difficulties to setup my dev environment. I have installed couchdb locally and it run well:

 curl --silent -XGET http://admin:password@127.0.0.1:5984/                                                                             ✔ 
{"couchdb":"Welcome","version":"3.2.2","git_sha":"d5b746b7c","uuid":"a93d5b2525abe571944e0a5315af21bc","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

Now I try unsuccessfully to start the docker image cozy-app-dev as it's described in the documenttion. I just added the COUCHDB_URL config because I'm running a couchdb V3 so I don't have the party mode enabled and I can't find any other way to setup the user/password for couchdb.

docker run --rm -it --env COUCHDB_URL=http://admin:password@localhost:5984/ --net=host -v "$(pwd)/build/drive":/data/cozy-app/drive cozy/cozy-app-dev

the output gives me:

checking that localhost:8080 is free... ok
waiting for couchdb...ok
checking couchdb on http://admin:password@localhost:5984/... failed
error: couchdb v1 is running on http://admin:password@localhost:5984/
error: you need couchdb version >= 2
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

As you can see in one of the call above my couchdb version is "3.2.2" so it should be ok but it still fail.

I have found the error location: https://github.com/cozy/cozy-stack/blob/master/scripts/cozy-app-dev.sh#L140 but I don't see what could fails. All I know is that if I enter an invalid user/password it give the same output but I'm pretty sure of my credentials as I'm connected with it and I tried directly with the curl.

Crash-- commented 1 year ago

Thanks for creating the issue.

@nono, since it seems related to cozy-app-dev, do you have any idea?

@Peltoche internally we don't use the cozy-app-dev image, we rely on a manual installation https://docs.cozy.io/en/cozy-stack/INSTALL/ . We need to reflect that in our external documentation.

Peltoche commented 1 year ago

I did tried this too but I didn't find a way to run the local code and make it available into the instance

Crash-- commented 1 year ago

https://docs.cozy.io/en/cozy-stack/cli/cozy-stack_serve/

cozy-stack serve --appdir drive:/path/to/drive/build/drive

Like that, the slug drive will be served to the instances from the build/drive directory

nono commented 1 year ago

Hi,

the cozy-app-dev docker image has a CouchDB. You don't need to have CouchDB installed before running it. And, in fact, it was not tested to use an external CouchDB.

Peltoche commented 1 year ago

https://docs.cozy.io/en/cozy-stack/cli/cozy-stack_serve/

Still have issues...

Folder with cozy-drive:

yarn watch:drive:browser

(I have exported the env variable NODE_OPTIONS=--openssl-legacy-provider for fixing #2902)

Folder with cozy-stack:

cozy-stack serve --dev --config $HOME/.config/cozy/config.yaml --mailhog --fs-url=file://localhost${PWD}/storage --konnectors-cmd ${PWD}/scripts/konnector-node-run.sh --appdir drive2:$HOME/Cozy/cozy-drive/build/drive

Error 1:

If I don't add the --dev option it don't find the admin-passphrase file even if it's created and valid.

Error 2:

When a reach http://drive2.cozy.localhost:8080/ I have a blank page. I found out that the url *.cozy.localhost was not resolved so I added 127.0.0.1 cozy.localhost inside /etc/hosts and it seems to solve the issue

Error 3:

When a reload the page I still have an blank page with the following issue:

Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”).
Uncaught EvalError: call to eval() blocked by CSP
Crash-- commented 1 year ago

add --disable-csp to cozy-stack serve when working with watch / start command

Peltoche commented 1 year ago

the cozy-app-dev docker image has a CouchDB. You don't need to have CouchDB installed before running it. And, in fact, it was not tested to use an external CouchDB.

I tried without an external couchdb but it blocks at waiting for couchdb.... I have tried with and without --net=host and with and without the 127.0.0.1 cozy.localhost inside /etc/hosts

Peltoche commented 1 year ago

add --disable-csp to cozy-stack serve when working with watch / start command

Curiously even with the --disable-csp flag I still have the same error.

My logs:

cozy-stack serve --dev --disable-csp --config $HOME/.config/cozy/config.yaml --mailhog --fs-url=file://localhost${PWD}/storage --konnectors-cmd ${PWD}/scripts/konnector-node-run.sh --appdir drive:$HOME/Cozy/cozy-drive/build/drive 
                           !! DEVELOPMENT RELEASE !!
You are running a development release which may deactivate some very important
security features. Please do not use this binary as your production server.

INFO[0000] Started in-memory broker for 21 workers type  nspace=jobs
Ready and waiting for connections:
  http server major started on "localhost:8080"
  http server admin started on "localhost:6060"
time=2023-04-18T14:36:58+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/   bytes_out=1653
time=2023-04-18T14:36:58+02:00  status=200  method=GET  host=cozy.localhost:8080    uri=/assets/styles/theme.faa4e12bdc.css bytes_out=34
time=2023-04-18T14:36:58+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/app/drive.js   bytes_out=7196552
time=2023-04-18T14:36:59+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/vendors/drive.js   bytes_out=51638673
time=2023-04-18T14:36:59+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/apple-touch-icon.png   bytes_out=464
time=2023-04-18T14:36:59+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/favicon-16x16.png  bytes_out=297
time=2023-04-18T14:37:03+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/   bytes_out=1653
time=2023-04-18T14:37:03+02:00  status=200  method=GET  host=cozy.localhost:8080    uri=/assets/styles/theme.faa4e12bdc.css bytes_out=34
time=2023-04-18T14:37:04+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/app/drive.js   bytes_out=7196552
time=2023-04-18T14:37:04+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/vendors/drive.js   bytes_out=51638673
time=2023-04-18T14:37:05+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/apple-touch-icon.png   bytes_out=464
time=2023-04-18T14:37:05+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/favicon-16x16.png  bytes_out=297
time=2023-04-18T14:45:59+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/   bytes_out=1653
time=2023-04-18T14:45:59+02:00  status=200  method=GET  host=cozy.localhost:8080    uri=/assets/styles/theme.faa4e12bdc.css bytes_out=34
time=2023-04-18T14:45:59+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/app/drive.js   bytes_out=7196552
time=2023-04-18T14:46:00+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/vendors/drive.js   bytes_out=51638673
time=2023-04-18T14:46:00+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/apple-touch-icon.png   bytes_out=464
time=2023-04-18T14:46:00+02:00  status=200  method=GET  host=drive.cozy.localhost:8080  uri=/favicon-16x16.png  bytes_out=297