rustapi icon indicating copy to clipboard operation
rustapi copied to clipboard

feat: migrate to postgresql

Open opeolluwa opened this issue 1 year ago • 7 comments

@ndelvalle I'm trying to dockerize this to make it easier to setup and run but the code panics,

 => => naming to docker.io/library/rustapi-app                                                                 0.0s 
[+] Running 2/0
 āœ” Container rustapi-database-1  Running                                                                       0.0s 
 āœ” Container rustapi-app-1       Recreated                                                                     0.0s 
Attaching to app-1, database-1
app-1       | thread 'main' panicked at src/settings.rs:7:34:
app-1       | Failed to setup settings: configuration file "config/default" not found
app-1       | note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
app-1 exited with code 101

Can we possibly revamp the application config using yaml like i did here https://github.com/opeolluwa/backend-in-rust/blob/master/02_auth_jwt/src/config.rs or best we use environment variables

opeolluwa avatar Sep 24 '24 15:09 opeolluwa

@opeolluwa yeah I think having to ship config files is not ideal if you want to have a single binary. I think the way to go would be to just use env vars instead of any config file, not even use yaml.

ndelvalle avatar Sep 25 '24 09:09 ndelvalle

Awesome, I know we'd have a port, JWT signing key and database connection. Would that be all or there's more

opeolluwa avatar Sep 25 '24 09:09 opeolluwa

@opeolluwa Regarding the Docker image, I’m not completely sure. Initially, I wanted the project to include lots of features, but now days I’m leaning towards keeping it as simple as possible, is easier to mantain. If we do decide to include Docker, I think we should use the official Rust image tho.

ndelvalle avatar Sep 25 '24 09:09 ndelvalle

Hmmm

opeolluwa avatar Sep 25 '24 09:09 opeolluwa

Awesome, I know we'd have a port, JWT signing key and database connection. Would that be all or there's more

Here is what we use: https://github.com/ndelvalle/rustapi/blob/master/src/settings.rs. I think that even if we don't ship a config file is cool to have a layered config to provide flexibility using https://github.com/mehcode/config-rs or or something similar.

ndelvalle avatar Sep 25 '24 09:09 ndelvalle

The primary reason for docker is because of the database, actually

opeolluwa avatar Sep 25 '24 09:09 opeolluwa

@ndelvalle would you mind docker or I should just use set up PostgreSQL locally

opeolluwa avatar Sep 29 '24 23:09 opeolluwa