second-state / microservice-rust-mysql

A template project for building a database-driven microservice in Rust and run it in the WasmEdge sandbox.
Apache License 2.0
350 stars 54 forks source link

docs: write a guide for setting up the docker+wasm on linux #19

Open hydai opened 1 year ago

hydai commented 1 year ago

We can install docker desktop on macOS and Windows easily. However, it's unclear when you try to set up the environment on Linux. We should provide a guide for this.

kmboyle commented 8 months ago

I was not able to get the Microservices template up and running via an Ubuntu VM on macOS darwin aarch64. I ran into a couple issues with docker compose (my buildkit platform shows linux/arm64). I also tried to manually build and run the Microservices in the VM, but having trouble connecting to the mysql server. Would love to see some docs on how, if possible, to get this running on a Linux VM on macOS. Keep up the great work, love what you all are doing.
Thanks!

kmboyle commented 8 months ago

Long story, but I finally got it to work (building and running it locally without Docker). For anyone who encounters this error: mask too long when connecting to mysql, this may help. I found that this library mysql_common was throwing the error mask too long as it was attempting to handle SHA-1 encoding. In mysql I found that when I created a new user, the default plugin mechanism was caching_sha2_password. I found the plugin mechanism with select user, authentication_string, plugin, host from mysql.user;

I ended up modifying the users plugin mechanism to mysql_native_password, and then I was able to run curl http://localhost:8080/init successfully.

I am not entirely clear on the security impacts of doing this, so review documentation carefully.

juntao commented 8 months ago

Thanks! I remember seeing this problem as well. The mysql-common crate does seem problematic for certain versions of MySQL (esp newer version).

For production use cases in the cloud, we are connecting from WasmEdge to a MySQL instance (eg AWS RDS) with TLS. You can see an example here:

https://github.com/WasmEdge/wasmedge-db-examples/tree/main/mysql_async