From 6fbdb1db80171ce3792d479ad37a215e070f0284 Mon Sep 17 00:00:00 2001 From: Szepesi Tibor Date: Sun, 17 Nov 2024 16:26:06 +0100 Subject: [PATCH 1/3] Use postgres for iam --- Cargo.lock | 133 ++++++++++++++++++++++++++++++++++++------ Cargo.toml | 2 +- compose.yaml | 37 ++++++------ test-utils/src/iam.rs | 2 +- 4 files changed, 136 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5946a740..bb13b46d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -832,6 +832,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "educe" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "either" version = "1.13.0" @@ -845,12 +857,32 @@ dependencies = [ name = "entity" version = "0.1.0" dependencies = [ - "sea-orm", + "sea-orm 0.12.15", "serde", "serde_repr", "uuid", ] +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1332,7 +1364,7 @@ dependencies = [ [[package]] name = "iam-common" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam#46d8874f8c07f2b135d74b1e2b0aa0fea1fbed12" +source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" dependencies = [ "anyhow", "axum", @@ -1348,7 +1380,7 @@ dependencies = [ "mime", "rand", "rust-argon2", - "sea-orm", + "sea-orm 1.0.1", "serde", "serde_json", "tracing", @@ -1358,15 +1390,16 @@ dependencies = [ [[package]] name = "iam-entity" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam#46d8874f8c07f2b135d74b1e2b0aa0fea1fbed12" +source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" dependencies = [ - "sea-orm", + "chrono", + "sea-orm 1.0.1", ] [[package]] name = "iam-macros" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam#46d8874f8c07f2b135d74b1e2b0aa0fea1fbed12" +source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" dependencies = [ "proc-macro2", "quote", @@ -1648,7 +1681,7 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libiam" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam#46d8874f8c07f2b135d74b1e2b0aa0fea1fbed12" +source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" dependencies = [ "anyhow", "async-trait", @@ -1657,7 +1690,7 @@ dependencies = [ "iam-entity", "jsonwebtoken", "reqwest", - "sea-orm", + "sea-orm 1.0.1", "serde", "serde_json", "thiserror", @@ -1749,7 +1782,7 @@ dependencies = [ "rand", "rand_chacha", "reqwest", - "sea-orm", + "sea-orm 0.12.15", "serde", "serde_json", "serde_with", @@ -2640,18 +2673,41 @@ dependencies = [ "futures", "log", "ouroboros", - "sea-orm-macros", - "sea-query", - "sea-query-binder", + "sea-orm-macros 0.12.15", + "sea-query 0.30.7", + "sea-query-binder 0.5.0", "serde", "sqlx", - "strum", + "strum 0.25.0", "thiserror", "tracing", "url", "uuid", ] +[[package]] +name = "sea-orm" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea1fee0cf8528dbe6eda29d5798afc522a63b75e44c5b15721e6e64af9c7cc4b" +dependencies = [ + "async-stream", + "async-trait", + "chrono", + "futures", + "log", + "ouroboros", + "sea-orm-macros 1.0.1", + "sea-query 0.31.1", + "sea-query-binder 0.6.0", + "serde", + "sqlx", + "strum 0.26.3", + "thiserror", + "tracing", + "url", +] + [[package]] name = "sea-orm-cli" version = "0.12.15" @@ -2683,6 +2739,20 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sea-orm-macros" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8737b566799ed0444f278d13c300c4c6f1a91782f60ff5825a591852d5502030" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "sea-bae", + "syn 2.0.72", + "unicode-ident", +] + [[package]] name = "sea-orm-migration" version = "0.12.15" @@ -2693,7 +2763,7 @@ dependencies = [ "clap", "dotenvy", "futures", - "sea-orm", + "sea-orm 0.12.15", "sea-orm-cli", "sea-schema", "tracing", @@ -2714,6 +2784,18 @@ dependencies = [ "uuid", ] +[[package]] +name = "sea-query" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4fd043b8117af233e221f73e3ea8dfbc8e8c3c928017c474296db45c649105c" +dependencies = [ + "chrono", + "educe", + "inherent", + "ordered-float 3.9.2", +] + [[package]] name = "sea-query-binder" version = "0.5.0" @@ -2721,11 +2803,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36bbb68df92e820e4d5aeb17b4acd5cc8b5d18b2c36a4dd6f4626aabfa7ab1b9" dependencies = [ "chrono", - "sea-query", + "sea-query 0.30.7", "sqlx", "uuid", ] +[[package]] +name = "sea-query-binder" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754965d4aee6145bec25d0898e5c931e6c22859789ce62fd85a42a15ed5a8ce3" +dependencies = [ + "chrono", + "sea-query 0.31.1", + "sqlx", +] + [[package]] name = "sea-query-derive" version = "0.4.1" @@ -2746,7 +2839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30d148608012d25222442d1ebbfafd1228dbc5221baf4ec35596494e27a2394e" dependencies = [ "futures", - "sea-query", + "sea-query 0.30.7", "sea-schema-derive", ] @@ -3315,6 +3408,12 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" + [[package]] name = "subtle" version = "2.6.1" @@ -3383,7 +3482,7 @@ dependencies = [ "matverseny-backend", "migration", "reqwest", - "sea-orm", + "sea-orm 0.12.15", "serde", "serde_json", "serial_test", diff --git a/Cargo.toml b/Cargo.toml index b801f544..80448daa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.108" tokio = { version = "1.33.0", features = ["rt-multi-thread", "parking_lot", "macros"] } uuid = { version = "1.5.0", features = ["v4", "fast-rng", "serde"] } -libiam = { git = "https://github.com/Verseghy/iam", package = "libiam" } +libiam = { git = "https://github.com/Verseghy/iam", package = "libiam", branch = "smrtrfszm/use-postgres" } dotenvy = "0.15.7" matverseny-backend = { path = "./backend" } test-utils = { path = "./test-utils" } diff --git a/compose.yaml b/compose.yaml index a2a1d35a..79c4497c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -17,9 +17,9 @@ services: iam: pull_policy: always - image: ghcr.io/verseghy/iam + image: ghcr.io/verseghy/iam:v2 environment: - DATABASE_URL: mysql://iam:secret@iam-database:3306/iam + DATABASE_URL: postgres://iam:secret@iam-database:5432/iam ports: - 3001:3001 depends_on: @@ -27,26 +27,25 @@ services: condition: service_completed_successfully iam-database: - image: docker.io/mysql:8.0 + image: docker.io/postgres:16 environment: - MYSQL_DATABASE: iam - MYSQL_USER: iam - MYSQL_PASSWORD: secret - MYSQL_ALLOW_EMPTY_PASSWORD: yes - TZ: Europe/Budapest + POSTGRES_USER: iam + POSTGRES_PASSWORD: secret + POSTGRES_DB: iam ports: - - 3306:3306 - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1"] - interval: 1s - timeout: 1s - retries: 100 + - 5433:5432 + # healthcheck: + # test: ["CMD", "pg_isready", "-U", "iam"] + # interval: 10s + # timeout: 45s + # retries: 10 iam-migration: pull_policy: always - image: ghcr.io/verseghy/iam-migration + image: ghcr.io/verseghy/iam-migration:v2 environment: - DATABASE_URL: mysql://iam:secret@iam-database:3306/iam - depends_on: - iam-database: - condition: service_healthy + DATABASE_URL: postgres://iam:secret@iam-database:5432/iam + command: ["./iam-migration", "--verbose"] + # depends_on: + # iam-database: + # condition: service_healthy diff --git a/test-utils/src/iam.rs b/test-utils/src/iam.rs index 54ffb325..b5016a15 100644 --- a/test-utils/src/iam.rs +++ b/test-utils/src/iam.rs @@ -45,7 +45,7 @@ pub async fn get_db() -> &'static libiam::testing::Database { tokio::sync::OnceCell::const_new(); DB.get_or_init(|| async { - libiam::testing::Database::connect("mysql://iam:secret@127.0.0.1:3306/iam").await + libiam::testing::Database::connect("postgres://iam:secret@127.0.0.1:5433/iam").await }) .await } From d42ba28a59ad96187f5a49c33de2a176edb05f3c Mon Sep 17 00:00:00 2001 From: Szepesi Tibor Date: Sun, 17 Nov 2024 17:16:39 +0100 Subject: [PATCH 2/3] Use v3 images --- compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 79c4497c..bd01d139 100644 --- a/compose.yaml +++ b/compose.yaml @@ -17,7 +17,7 @@ services: iam: pull_policy: always - image: ghcr.io/verseghy/iam:v2 + image: ghcr.io/verseghy/iam:v3 environment: DATABASE_URL: postgres://iam:secret@iam-database:5432/iam ports: @@ -42,7 +42,7 @@ services: iam-migration: pull_policy: always - image: ghcr.io/verseghy/iam-migration:v2 + image: ghcr.io/verseghy/iam-migration:v3 environment: DATABASE_URL: postgres://iam:secret@iam-database:5432/iam command: ["./iam-migration", "--verbose"] From 10f5db33e1e19cca48eb6f97dc3acdd156702765 Mon Sep 17 00:00:00 2001 From: Szepesi Tibor Date: Sun, 17 Nov 2024 17:18:50 +0100 Subject: [PATCH 3/3] Use master branch of iam repo --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb13b46d..181b53bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1364,7 +1364,7 @@ dependencies = [ [[package]] name = "iam-common" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" +source = "git+https://github.com/Verseghy/iam#f3e15e614dff6354934e15e2b8f2fe6652fa4a06" dependencies = [ "anyhow", "axum", @@ -1390,7 +1390,7 @@ dependencies = [ [[package]] name = "iam-entity" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" +source = "git+https://github.com/Verseghy/iam#f3e15e614dff6354934e15e2b8f2fe6652fa4a06" dependencies = [ "chrono", "sea-orm 1.0.1", @@ -1399,7 +1399,7 @@ dependencies = [ [[package]] name = "iam-macros" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" +source = "git+https://github.com/Verseghy/iam#f3e15e614dff6354934e15e2b8f2fe6652fa4a06" dependencies = [ "proc-macro2", "quote", @@ -1681,7 +1681,7 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libiam" version = "0.1.0" -source = "git+https://github.com/Verseghy/iam?branch=smrtrfszm/use-postgres#7e53d792b7856af0e380c7daaefc3266a3803c79" +source = "git+https://github.com/Verseghy/iam#f3e15e614dff6354934e15e2b8f2fe6652fa4a06" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 80448daa..b801f544 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.108" tokio = { version = "1.33.0", features = ["rt-multi-thread", "parking_lot", "macros"] } uuid = { version = "1.5.0", features = ["v4", "fast-rng", "serde"] } -libiam = { git = "https://github.com/Verseghy/iam", package = "libiam", branch = "smrtrfszm/use-postgres" } +libiam = { git = "https://github.com/Verseghy/iam", package = "libiam" } dotenvy = "0.15.7" matverseny-backend = { path = "./backend" } test-utils = { path = "./test-utils" }