File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 3333 ( pkgs . lib . hasSuffix "\. css" path ) ||
3434 ( pkgs . lib . hasSuffix "\. js" path ) ||
3535 ( pkgs . lib . hasSuffix "\. svg" path ) ||
36+ ( pkgs . lib . hasSuffix "\. sqlite3" path ) ||
3637 ( craneLib . filterCargoSources path type )
3738 ;
3839 } ;
5556 cp -pr --reflink=auto -- ${ ui } ui/dist
5657 '' ;
5758 } ) ;
59+
60+ docker = pkgs . dockerTools . buildLayeredImage {
61+ name = "sqlite-studio" ;
62+ tag = "latest" ;
63+ created = "now" ;
64+ config . Cmd = [ "${ bin } /bin/sqlite-studio" "preview" "--address=0.0.0.0:3030" ] ;
65+ config . Expose = "3030" ;
66+ } ;
5867 in
5968 {
6069 packages = {
6170 default = bin ;
71+ docker = docker ;
6272 } ;
6373
6474 devShells . default = pkgs . mkShell {
Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ use tokio_rusqlite::{Connection, OpenFlags};
66use warp:: Filter ;
77
88const ROWS_PER_PAGE : i32 = 50 ;
9+ const SAMPLE_DB : & [ u8 ] = include_bytes ! ( "../sample.sqlite3" ) ;
910
1011/// Web based SQLite database browser.
1112#[ derive( Parser , Debug ) ]
1213struct Args {
13- /// Path to the sqlite database file.
14+ /// Path to the sqlite database file. [use the path "preview" if you don't have an sqlite db at
15+ /// hand, a sample db will be created for you]
1416 database : String ,
1517
1618 /// The address to bind to.
@@ -30,7 +32,12 @@ async fn main() -> color_eyre::Result<()> {
3032 . init ( ) ;
3133
3234 let args = Args :: parse ( ) ;
33- let db = TheDB :: open ( args. database ) . await ?;
35+ let db = if args. database == "preview" {
36+ tokio:: fs:: write ( "sample.db" , SAMPLE_DB ) . await ?;
37+ TheDB :: open ( "sample.db" . to_string ( ) ) . await ?
38+ } else {
39+ TheDB :: open ( args. database ) . await ?
40+ } ;
3441
3542 let cors = warp:: cors ( )
3643 . allow_any_origin ( )
You can’t perform that action at this time.
0 commit comments