From 0b048eb8b0359cce1445a45e07fff7d4b8611029 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Mon, 25 Oct 2021 21:28:22 +0200 Subject: [PATCH] Layed groundwork for microservice split --- .cargo/config | 3 - Cargo.lock | 401 ++++++++++++------ Cargo.toml | 54 +-- Dockerfile | 23 +- Rb.yaml | 2 +- .env => blog/.env | 2 +- blog/Cargo.toml | 16 + diesel.toml => blog/diesel.toml | 0 {migrations => blog/migrations}/.gitkeep | 0 .../down.sql | 0 .../up.sql | 0 .../2021-08-20-110251_users-and-auth/down.sql | 0 .../2021-08-20-110251_users-and-auth/up.sql | 0 .../2021-09-13-143540_sections/down.sql | 0 .../2021-09-13-143540_sections/up.sql | 0 blog/src/lib.rs | 0 {src => blog/src}/main.rs | 0 {src => blog/src}/posts.rs | 0 blog/src/schema.rs | 0 {src => blog/src}/sections.rs | 0 common/Cargo.toml | 49 +++ {src => common/src}/auth/jwt.rs | 0 {src => common/src}/auth/mod.rs | 0 {src => common/src}/auth/pass.rs | 0 {src => common/src}/db/mod.rs | 0 {src => common/src}/db/posts.rs | 0 {src => common/src}/db/sections.rs | 0 {src => common/src}/db/tokens.rs | 0 {src => common/src}/db/users.rs | 0 {src => common/src}/errors.rs | 0 {src => common/src}/guards.rs | 0 common/src/lib.rs | 8 + {src => common/src}/schema.rs | 0 {tests => common/tests}/admin.py | 0 docker-compose.test.yml | 27 -- docker-compose.yml | 22 +- docker/Dockerfile.builder | 28 -- gw/.env | 2 + gw/Cargo.lock | 7 + gw/Cargo.toml | 18 + {src => gw}/admin.rs | 0 gw/diesel.toml | 5 + gw/src/main.rs | 4 + gw/src/schema.rs | 49 +++ 44 files changed, 461 insertions(+), 259 deletions(-) delete mode 100644 .cargo/config rename .env => blog/.env (56%) create mode 100644 blog/Cargo.toml rename diesel.toml => blog/diesel.toml (100%) rename {migrations => blog/migrations}/.gitkeep (100%) rename {migrations => blog/migrations}/00000000000000_diesel_initial_setup/down.sql (100%) rename {migrations => blog/migrations}/00000000000000_diesel_initial_setup/up.sql (100%) rename {migrations => blog/migrations}/2021-08-20-110251_users-and-auth/down.sql (100%) rename {migrations => blog/migrations}/2021-08-20-110251_users-and-auth/up.sql (100%) rename {migrations => blog/migrations}/2021-09-13-143540_sections/down.sql (100%) rename {migrations => blog/migrations}/2021-09-13-143540_sections/up.sql (100%) create mode 100644 blog/src/lib.rs rename {src => blog/src}/main.rs (100%) rename {src => blog/src}/posts.rs (100%) create mode 100644 blog/src/schema.rs rename {src => blog/src}/sections.rs (100%) create mode 100644 common/Cargo.toml rename {src => common/src}/auth/jwt.rs (100%) rename {src => common/src}/auth/mod.rs (100%) rename {src => common/src}/auth/pass.rs (100%) rename {src => common/src}/db/mod.rs (100%) rename {src => common/src}/db/posts.rs (100%) rename {src => common/src}/db/sections.rs (100%) rename {src => common/src}/db/tokens.rs (100%) rename {src => common/src}/db/users.rs (100%) rename {src => common/src}/errors.rs (100%) rename {src => common/src}/guards.rs (100%) create mode 100644 common/src/lib.rs rename {src => common/src}/schema.rs (100%) rename {tests => common/tests}/admin.py (100%) delete mode 100644 docker-compose.test.yml delete mode 100644 docker/Dockerfile.builder create mode 100644 gw/.env create mode 100644 gw/Cargo.lock create mode 100644 gw/Cargo.toml rename {src => gw}/admin.rs (100%) create mode 100644 gw/diesel.toml create mode 100644 gw/src/main.rs create mode 100644 gw/src/schema.rs diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index b086373..0000000 --- a/.cargo/config +++ /dev/null @@ -1,3 +0,0 @@ -# vim: ft=toml -[build] -target-dir = "out/target" diff --git a/Cargo.lock b/Cargo.lock index b42398b..546bfad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "arrayref" version = "0.3.6" @@ -116,11 +125,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blog" +version = "0.1.0" + [[package]] name = "bumpalo" -version = "3.7.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" [[package]] name = "byteorder" @@ -130,15 +143,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cc" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" [[package]] name = "cfg-if" @@ -156,7 +169,7 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time 0.1.44", + "time 0.1.43", "winapi", ] @@ -185,9 +198,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.1.5" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" dependencies = [ "libc", ] @@ -247,9 +260,9 @@ dependencies = [ [[package]] name = "diesel" -version = "1.4.7" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba51ca66f57261fd17cadf8b73e4775cc307d0521d855de3f5de91a8f074e0e" +checksum = "b28135ecf6b7d446b43e27e225622a038cc4e2930a1022f51cdb97ada19b8e4d" dependencies = [ "bitflags", "byteorder", @@ -310,9 +323,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "encoding_rs" -version = "0.8.28" +version = "0.8.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" dependencies = [ "cfg-if", ] @@ -355,9 +368,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "futures" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b" +checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" dependencies = [ "futures-channel", "futures-core", @@ -370,9 +383,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ "futures-core", "futures-sink", @@ -380,15 +393,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" [[package]] name = "futures-executor" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c" +checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" dependencies = [ "futures-core", "futures-task", @@ -397,15 +410,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" [[package]] name = "futures-macro" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" dependencies = [ "autocfg", "proc-macro-hack", @@ -416,21 +429,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" [[package]] name = "futures-task" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" [[package]] name = "futures-util" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" dependencies = [ "autocfg", "futures-channel", @@ -489,9 +502,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" -version = "0.3.3" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" dependencies = [ "bytes", "fnv", @@ -533,9 +546,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" dependencies = [ "bytes", "fnv", @@ -544,9 +557,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" dependencies = [ "bytes", "http", @@ -555,9 +568,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "httpdate" @@ -567,9 +580,9 @@ checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" [[package]] name = "hyper" -version = "0.14.11" +version = "0.14.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b61cf2d1aebcf6e6352c97b81dc2244ca29194be1b276f5d8ad5c6330fffb11" +checksum = "2b91bb1f221b6ea1f1e4371216b70f40748774c2fb5971b450c07773fb92d26b" dependencies = [ "bytes", "futures-channel", @@ -608,18 +621,18 @@ checksum = "3094308123a0e9fd59659ce45e22de9f53fc1d2ac6e1feb9fef988e4f76cad77" [[package]] name = "instant" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", ] [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "jwt" @@ -644,9 +657,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.99" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +checksum = "869d572136620d55835903746bcb5cdc54cb2851fd0aeec53220b4bb65ef3013" [[package]] name = "libmimalloc-sys" @@ -665,9 +678,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" dependencies = [ "scopeguard", ] @@ -683,15 +696,26 @@ dependencies = [ [[package]] name = "loom" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2111607c723d7857e0d8299d5ce7a0bf4b844d3e44f8de136b13da513eaf8fc4" +checksum = "b2b9df80a3804094bf49bb29881d18f6f05048db72127e84e09c26fc7c2324f5" dependencies = [ "cfg-if", "generator", "scoped-tls", "serde", "serde_json", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", ] [[package]] @@ -738,9 +762,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mio" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ "libc", "log", @@ -844,9 +868,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.66" +version = "0.9.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1996d2d305e561b70d1ee0c53f1542833f4e1ac6ce9a6708b6ff2738ca67dc82" +checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058" dependencies = [ "autocfg", "cc", @@ -857,9 +881,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", @@ -868,9 +892,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ "cfg-if", "instant", @@ -923,15 +947,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "pq-sys" @@ -956,9 +980,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70" dependencies = [ "unicode-xid", ] @@ -978,9 +1002,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" dependencies = [ "proc-macro2", ] @@ -1036,6 +1060,35 @@ dependencies = [ "rand_core", ] +[[package]] +name = "rb" +version = "0.1.0" +dependencies = [ + "base64", + "chrono", + "diesel", + "diesel_migrations", + "figment", + "hmac", + "jwt", + "mimalloc", + "openssl", + "rand", + "rocket", + "rocket_sync_db_pools", + "rust-argon2", + "serde", + "sha2", + "uuid", +] + +[[package]] +name = "rb-gw" +version = "0.1.0" +dependencies = [ + "rb", +] + [[package]] name = "redox_syscall" version = "0.2.10" @@ -1065,6 +1118,30 @@ dependencies = [ "syn", ] +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -1210,28 +1287,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" -[[package]] -name = "rusty-bever" -version = "0.1.0" -dependencies = [ - "base64", - "chrono", - "diesel", - "diesel_migrations", - "figment", - "hmac", - "jwt", - "mimalloc", - "openssl", - "rand", - "rocket", - "rocket_sync_db_pools", - "rust-argon2", - "serde", - "sha2", - "uuid", -] - [[package]] name = "ryu" version = "1.0.5" @@ -1276,18 +1331,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.127" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.127" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1296,9 +1351,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", @@ -1307,12 +1362,12 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.18" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039ba818c784248423789eec090aab9fb566c7b94d6ebbfa1814a9fd52c8afb2" +checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" dependencies = [ "dtoa", - "linked-hash-map", + "indexmap", "serde", "yaml-rust", ] @@ -1325,9 +1380,9 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" [[package]] name = "sha2" -version = "0.9.5" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", "cfg-if", @@ -1336,6 +1391,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1347,21 +1411,21 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "socket2" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" dependencies = [ "libc", "winapi", @@ -1457,9 +1521,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.74" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" dependencies = [ "proc-macro2", "quote", @@ -1481,13 +1545,21 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.44" +name = "thread_local" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +dependencies = [ + "once_cell", +] + +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "wasi", "winapi", ] @@ -1531,9 +1603,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cf844b23c6131f624accf65ce0e4e9956a8bb329400ea5bcc26ae3a5c20b0b" +checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" dependencies = [ "autocfg", "bytes", @@ -1550,9 +1622,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" +checksum = "b2dd85aeaba7b68df939bd357c6afb36c87951be9e80bf9c859f2fc3e9fca0fd" dependencies = [ "proc-macro2", "quote", @@ -1572,9 +1644,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" +checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" dependencies = [ "bytes", "futures-core", @@ -1601,24 +1673,79 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.26" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ "cfg-if", "pin-project-lite", + "tracing-attributes", "tracing-core", ] [[package]] -name = "tracing-core" -version = "0.1.19" +name = "tracing-attributes" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ca517f43f0fb96e0c3072ed5c275fe5eece87e8cb52f4a77b69226d3b1c9df8" +checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -1637,9 +1764,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "ubyte" @@ -1705,15 +1832,15 @@ dependencies = [ [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.75" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1721,9 +1848,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.75" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", @@ -1736,9 +1863,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.75" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1746,9 +1873,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.75" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -1759,9 +1886,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.75" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "winapi" diff --git a/Cargo.toml b/Cargo.toml index 53cc5fd..d108a8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,49 +1,7 @@ -[package] -name = "rusty-bever" -version = "0.1.0" -authors = ["Jef Roosens "] -edition = "2018" +[workspace] +members = [ + "common", + "gw", + "blog", +] -[[bin]] -name = "rbd" -path = "src/main.rs" - -[features] -web = [] -docs = [] -static = ["web", "docs"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# Backend web framework -rocket = { version = "0.5.0-rc.1", features = [ "json", "uuid" ] } -# Used to provide Rocket routes with database connections -rocket_sync_db_pools = { version = "0.1.0-rc.1", default_features = false, features = [ "diesel_postgres_pool" ] } -# Used to (de)serialize JSON -serde = { version = "1.0.127", features = [ "derive" ] } -# ORM -diesel = { version = "1.4.7", features = ["postgres", "uuidv07", "chrono"] } -diesel_migrations = "1.4.0" -# To properly compile libpq statically -openssl = "0.10.36" -# For password hashing & verification -rust-argon2 = "0.8.3" -rand = "0.8.4" -uuid = { version = "0.8.2", features = ["serde"] } -# Authentification -jwt = "0.14.0" -hmac = "*" -sha2 = "*" -# Timestamps for JWT tokens -chrono = { version = "*", features = [ "serde" ] } -# Encoding of refresh tokens -base64 = "0.13.0" -# Reading in configuration files -figment = { version = "*", features = [ "yaml" ] } -mimalloc = { version = "0.1.26", default_features = false } - -[profile.release] -lto = "fat" -panic = "abort" -codegen-units = 1 diff --git a/Dockerfile b/Dockerfile index 72638d3..5f2326d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:1.2 # Build frontend files FROM node:16 AS fbuilder @@ -22,7 +23,8 @@ RUN apk update && \ postgresql \ postgresql-dev \ openssl-dev \ - build-base + build-base \ + curl bash WORKDIR /usr/src/app @@ -32,7 +34,12 @@ COPY src/ ./src COPY migrations/ ./migrations COPY Cargo.toml Cargo.lock ./ -RUN cargo build --release && \ +RUN \ + --mount=type=cache,target=/usr/src/app/out \ + --mount=type=cache,target=/root/.cargo \ + cargo build --release && \ + mkdir bin && \ + cp out/target/release/rbd bin && \ cargo doc --no-deps # Build dumb-init @@ -40,17 +47,19 @@ RUN curl -sSL "https://github.com/Yelp/dumb-init/archive/refs/tags/v$DI_VER.tar. tar -xzf - && \ cd "dumb-init-$DI_VER" && \ make build && \ - mv dumb-init .. + mv dumb-init ../bin FROM alpine:3.14.2 -RUN mkdir -p /var/www/html +RUN apk add --no-cache openssl libpq postgresql-dev && \ + mkdir -p /var/www/html COPY --from=fbuilder /usr/src/app/dist /var/www/html/site -COPY --from=builder /usr/src/app/out/target/doc /var/www/html/doc -COPY --from=builder /usr/src/app/out/target/release/rbd /usr/bin/rbd -COPY --from=builder /usr/src/app/dumb-init /usr/bin/dumb-init +# COPY --from=builder /usr/src/app/out/target/doc /var/www/html/doc +COPY --from=builder /usr/src/app/bin/* /usr/bin/ + +WORKDIR / ENTRYPOINT [ "dumb-init", "--" ] CMD [ "/usr/bin/rbd" ] diff --git a/Rb.yaml b/Rb.yaml index db78338..845bc55 100644 --- a/Rb.yaml +++ b/Rb.yaml @@ -40,4 +40,4 @@ release: databases: postgres_rb: - url: "postgres://rb:rb@localhost:5432/rb" + url: "postgres://rb:rb@db:5432/rb" diff --git a/.env b/blog/.env similarity index 56% rename from .env rename to blog/.env index 9cacc63..ae5a3dd 100644 --- a/.env +++ b/blog/.env @@ -1,2 +1,2 @@ # This file is used by diesel to find the development database -DATABASE_URL=postgres://rb:rb@localhost/rb +DATABASE_URL=postgres://rb:rb@localhost:5433/rb diff --git a/blog/Cargo.toml b/blog/Cargo.toml new file mode 100644 index 0000000..0292740 --- /dev/null +++ b/blog/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "blog" +version = "0.1.0" +edition = "2018" + +[lib] +name = "rb_blog" +path = "src/lib.rs" + +[[bin]] +name = "rb-blog" +path = "src/main.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/diesel.toml b/blog/diesel.toml similarity index 100% rename from diesel.toml rename to blog/diesel.toml diff --git a/migrations/.gitkeep b/blog/migrations/.gitkeep similarity index 100% rename from migrations/.gitkeep rename to blog/migrations/.gitkeep diff --git a/migrations/00000000000000_diesel_initial_setup/down.sql b/blog/migrations/00000000000000_diesel_initial_setup/down.sql similarity index 100% rename from migrations/00000000000000_diesel_initial_setup/down.sql rename to blog/migrations/00000000000000_diesel_initial_setup/down.sql diff --git a/migrations/00000000000000_diesel_initial_setup/up.sql b/blog/migrations/00000000000000_diesel_initial_setup/up.sql similarity index 100% rename from migrations/00000000000000_diesel_initial_setup/up.sql rename to blog/migrations/00000000000000_diesel_initial_setup/up.sql diff --git a/migrations/2021-08-20-110251_users-and-auth/down.sql b/blog/migrations/2021-08-20-110251_users-and-auth/down.sql similarity index 100% rename from migrations/2021-08-20-110251_users-and-auth/down.sql rename to blog/migrations/2021-08-20-110251_users-and-auth/down.sql diff --git a/migrations/2021-08-20-110251_users-and-auth/up.sql b/blog/migrations/2021-08-20-110251_users-and-auth/up.sql similarity index 100% rename from migrations/2021-08-20-110251_users-and-auth/up.sql rename to blog/migrations/2021-08-20-110251_users-and-auth/up.sql diff --git a/migrations/2021-09-13-143540_sections/down.sql b/blog/migrations/2021-09-13-143540_sections/down.sql similarity index 100% rename from migrations/2021-09-13-143540_sections/down.sql rename to blog/migrations/2021-09-13-143540_sections/down.sql diff --git a/migrations/2021-09-13-143540_sections/up.sql b/blog/migrations/2021-09-13-143540_sections/up.sql similarity index 100% rename from migrations/2021-09-13-143540_sections/up.sql rename to blog/migrations/2021-09-13-143540_sections/up.sql diff --git a/blog/src/lib.rs b/blog/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/blog/src/main.rs similarity index 100% rename from src/main.rs rename to blog/src/main.rs diff --git a/src/posts.rs b/blog/src/posts.rs similarity index 100% rename from src/posts.rs rename to blog/src/posts.rs diff --git a/blog/src/schema.rs b/blog/src/schema.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/sections.rs b/blog/src/sections.rs similarity index 100% rename from src/sections.rs rename to blog/src/sections.rs diff --git a/common/Cargo.toml b/common/Cargo.toml new file mode 100644 index 0000000..920246e --- /dev/null +++ b/common/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "rb" +version = "0.1.0" +authors = ["Jef Roosens "] +edition = "2018" + +[lib] +name = "rb" +path = "src/lib.rs" + +# [features] +# web = [] +# docs = [] +# static = ["web", "docs"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# Backend web framework +rocket = { version = "0.5.0-rc.1", features = [ "json", "uuid" ] } +# Used to provide Rocket routes with database connections +rocket_sync_db_pools = { version = "0.1.0-rc.1", default_features = false, features = [ "diesel_postgres_pool" ] } +# Used to (de)serialize JSON +serde = { version = "1.0.127", features = [ "derive" ] } +# ORM +diesel = { version = "1.4.7", features = ["postgres", "uuidv07", "chrono"] } +diesel_migrations = "1.4.0" +# To properly compile libpq statically +openssl = "0.10.36" +# For password hashing & verification +rust-argon2 = "0.8.3" +rand = "0.8.4" +uuid = { version = "0.8.2", features = ["serde"] } +# Authentification +jwt = "0.14.0" +hmac = "*" +sha2 = "*" +# Timestamps for JWT tokens +chrono = { version = "*", features = [ "serde" ] } +# Encoding of refresh tokens +base64 = "0.13.0" +# Reading in configuration files +figment = { version = "*", features = [ "yaml" ] } +mimalloc = { version = "0.1.26", default_features = false } + +# [profile.release] +# lto = "fat" +# panic = "abort" +# codegen-units = 1 diff --git a/src/auth/jwt.rs b/common/src/auth/jwt.rs similarity index 100% rename from src/auth/jwt.rs rename to common/src/auth/jwt.rs diff --git a/src/auth/mod.rs b/common/src/auth/mod.rs similarity index 100% rename from src/auth/mod.rs rename to common/src/auth/mod.rs diff --git a/src/auth/pass.rs b/common/src/auth/pass.rs similarity index 100% rename from src/auth/pass.rs rename to common/src/auth/pass.rs diff --git a/src/db/mod.rs b/common/src/db/mod.rs similarity index 100% rename from src/db/mod.rs rename to common/src/db/mod.rs diff --git a/src/db/posts.rs b/common/src/db/posts.rs similarity index 100% rename from src/db/posts.rs rename to common/src/db/posts.rs diff --git a/src/db/sections.rs b/common/src/db/sections.rs similarity index 100% rename from src/db/sections.rs rename to common/src/db/sections.rs diff --git a/src/db/tokens.rs b/common/src/db/tokens.rs similarity index 100% rename from src/db/tokens.rs rename to common/src/db/tokens.rs diff --git a/src/db/users.rs b/common/src/db/users.rs similarity index 100% rename from src/db/users.rs rename to common/src/db/users.rs diff --git a/src/errors.rs b/common/src/errors.rs similarity index 100% rename from src/errors.rs rename to common/src/errors.rs diff --git a/src/guards.rs b/common/src/guards.rs similarity index 100% rename from src/guards.rs rename to common/src/guards.rs diff --git a/common/src/lib.rs b/common/src/lib.rs new file mode 100644 index 0000000..0bcba72 --- /dev/null +++ b/common/src/lib.rs @@ -0,0 +1,8 @@ +#[macro_use] +extern crate diesel; + +pub mod auth; +pub mod db; +pub mod errors; +pub mod guards; +pub(crate) mod schema; diff --git a/src/schema.rs b/common/src/schema.rs similarity index 100% rename from src/schema.rs rename to common/src/schema.rs diff --git a/tests/admin.py b/common/tests/admin.py similarity index 100% rename from tests/admin.py rename to common/tests/admin.py diff --git a/docker-compose.test.yml b/docker-compose.test.yml deleted file mode 100644 index 84f8657..0000000 --- a/docker-compose.test.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: '3' - -services: - app: - build: - context: '.' - dockerfile: 'docker/test/Dockerfile' - - image: 'rb-builder:1.54' - command: "${CMD}" - - working_dir: "/usr/src/app" - - volumes: - - '$PWD:/usr/src/app' - - 'cache:/usr/src/app/out' - - db: - image: 'postgres:13-alpine' - - environment: - - 'POSTGRES_DB=rb' - - 'POSTGRES_USER=rb' - - 'POSTGRES_PASSWORD=rb' - -volumes: - cache: diff --git a/docker-compose.yml b/docker-compose.yml index 522fe33..9b6e6c2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,18 +2,26 @@ version: '3' services: - db: - image: 'postgres:13-alpine' + db-gw: + image: 'postgres:14-alpine' restart: 'always' environment: - - 'POSTGRES_DB=rb' - 'POSTGRES_USER=rb' - 'POSTGRES_PASSWORD=rb' ports: - '5432:5432' - volumes: - - 'db-data:/var/lib/postgresql/data' + # volumes: + # - 'db-data:/var/lib/postgresql/data' + db-blog: + image: 'postgres:14-alpine' + restart: 'always' -volumes: - db-data: + environment: + - 'POSTGRES_USER=rb' + - 'POSTGRES_PASSWORD=rb' + ports: + - '5433:5432' + +# volumes: +# db-data: diff --git a/docker/Dockerfile.builder b/docker/Dockerfile.builder deleted file mode 100644 index 5c87d30..0000000 --- a/docker/Dockerfile.builder +++ /dev/null @@ -1,28 +0,0 @@ -# vim: ft=dockerfile -FROM rust:1.54 - -ENV PREFIX="/usr/src/out/prefix" \ - CC="musl-gcc -fPIC -pie -static" \ - LD_LIBRARY_PATH="$PREFIX" \ - PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" \ - PATH="/usr/local/bin:/root/.cargo/bin:$PATH" - -WORKDIR /usr/src/app - -RUN groupadd -g 1000 builder && \ - useradd -u 1000 -g 1000 builder && \ - mkdir -p "$PREFIX" && \ - chown -R builder:builder /usr/src/app && \ - apt update && \ - apt install -y --no-install-recommends \ - musl-dev \ - musl-tools \ - libpq-dev \ - libssl-dev && \ - rustup target add x86_64-unknown-linux-musl && \ - echo "$PREFIX/lib" >> /etc/ld-musl-x86_64.path - - -USER builder - -CMD ["cargo", "test"] diff --git a/gw/.env b/gw/.env new file mode 100644 index 0000000..1ed17a2 --- /dev/null +++ b/gw/.env @@ -0,0 +1,2 @@ +# This file is used by diesel to find the development database +DATABASE_URL=postgres://rb:rb@localhost:5432/rb diff --git a/gw/Cargo.lock b/gw/Cargo.lock new file mode 100644 index 0000000..90d82b8 --- /dev/null +++ b/gw/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "rb-gw" +version = "0.1.0" diff --git a/gw/Cargo.toml b/gw/Cargo.toml new file mode 100644 index 0000000..99852d4 --- /dev/null +++ b/gw/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "rb-gw" +version = "0.1.0" +edition = "2018" + +[lib] +name = "rb_gw" +path = "src/lib.rs" + +[[bin]] +name = "rb-gw" +path = "src/main.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +rb = { path = "../common" } diff --git a/src/admin.rs b/gw/admin.rs similarity index 100% rename from src/admin.rs rename to gw/admin.rs diff --git a/gw/diesel.toml b/gw/diesel.toml new file mode 100644 index 0000000..92267c8 --- /dev/null +++ b/gw/diesel.toml @@ -0,0 +1,5 @@ +# For documentation on how to configure this file, +# see diesel.rs/guides/configuring-diesel-cli + +[print_schema] +file = "src/schema.rs" diff --git a/gw/src/main.rs b/gw/src/main.rs new file mode 100644 index 0000000..a4f2e4f --- /dev/null +++ b/gw/src/main.rs @@ -0,0 +1,4 @@ +fn main() +{ + println!("Hello, world!"); +} diff --git a/gw/src/schema.rs b/gw/src/schema.rs new file mode 100644 index 0000000..d8b585e --- /dev/null +++ b/gw/src/schema.rs @@ -0,0 +1,49 @@ +table! { + posts (id) { + id -> Uuid, + section_id -> Uuid, + title -> Nullable, + publish_date -> Date, + content -> Text, + } +} + +table! { + refresh_tokens (token) { + token -> Bytea, + user_id -> Uuid, + expires_at -> Timestamp, + last_used_at -> Nullable, + } +} + +table! { + sections (id) { + id -> Uuid, + title -> Varchar, + shortname -> Varchar, + description -> Nullable, + is_default -> Bool, + has_titles -> Bool, + } +} + +table! { + users (id) { + id -> Uuid, + username -> Varchar, + password -> Text, + blocked -> Bool, + admin -> Bool, + } +} + +joinable!(posts -> sections (section_id)); +joinable!(refresh_tokens -> users (user_id)); + +allow_tables_to_appear_in_same_query!( + posts, + refresh_tokens, + sections, + users, +);