rust-web-starter icon indicating copy to clipboard operation
rust-web-starter copied to clipboard

Docker prod build

Open ghotiphud opened this issue 8 years ago • 2 comments

See comments here: https://www.reddit.com/r/rust/comments/6u27xp/my_dockerized_rocket_diesel_and_react_starter/

Multi-stage build + diesel embed_migrations!() (http://docs.diesel.rs/diesel/macro.embed_migrations.html) is probably the way to go.

Alpine + musl??

ghotiphud avatar Aug 16 '17 23:08 ghotiphud

@ghotiphud link to embed_migrations is now broken.

Also, an example as to how to use embed_migrations would be super useful if you already have a clue how to ! It's not easy yet to find anything on the web about how to use that properly

nmrshll avatar Dec 26 '18 21:12 nmrshll

Well, here's the updated link: https://docs.rs/diesel/0.16.0/diesel/macro.embed_migrations.html

The basic usage is

embed_migrations!("../migrations/sqlite");

fn main() {
    let connection = establish_connection();

    // This will run the necessary migrations.
    embedded_migrations::run(&connection);

    // By default the output is thrown out. If you want to redirect it to stdout, you
    // should call embedded_migrations::run_with_output.
    embedded_migrations::run_with_output(&connection, &mut std::io::stdout());
}

which as far as I know, basically does an include_str!() (https://doc.rust-lang.org/std/macro.include_str.html) for all the files in your migrations directory.

ghotiphud avatar Jan 07 '19 18:01 ghotiphud