From a508b88a74ba6796e2bbd56f22c9f178f92235b6 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 31 Jul 2024 19:18:57 +0530 Subject: [PATCH] ci: switch to using openssl-sys Also remove architecture stuff in build process. --- Cargo.lock | 48 +++++++++++++----------- Cargo.toml | 2 +- Dockerfile | 15 ++------ apps/backend/Cargo.toml | 7 +--- apps/backend/ci/build-app.sh | 9 ----- apps/backend/src/miscellaneous.rs | 7 ++-- apps/backend/src/notification.rs | 3 +- apps/backend/src/utils.rs | 2 - docs/includes/backend-config-schema.yaml | 3 -- libs/config/src/lib.rs | 2 - rust-toolchain.toml | 2 +- 11 files changed, 39 insertions(+), 61 deletions(-) delete mode 100755 apps/backend/ci/build-app.sh diff --git a/Cargo.lock b/Cargo.lock index 1a33f08e58..5f7fdffad2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2480,6 +2480,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "hostname" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9c7c7c8ac16c798734b8a24560c1362120597c40d5e1459f09498f8f6c8f2ba" +dependencies = [ + "cfg-if", + "libc", + "windows", +] + [[package]] name = "html5ever" version = "0.27.0" @@ -2919,18 +2930,18 @@ dependencies = [ "email-encoding", "email_address", "fastrand", + "futures-util", + "hostname", "httpdate", "idna", "mime", + "native-tls", "nom", "percent-encoding", "quoted_printable", - "rustls 0.23.11", - "rustls-pemfile 2.1.2", "socket2", "tokio", "url", - "webpki-roots 0.26.3", ] [[package]] @@ -4124,7 +4135,6 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", - "hyper-rustls 0.24.2", "ipnet", "js-sys", "log", @@ -4132,15 +4142,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 0.1.2", "system-configuration", "tokio", - "tokio-rustls 0.24.1", "tokio-util", "tower-service", "url", @@ -4148,7 +4155,6 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.25.4", "winreg 0.50.0", ] @@ -4193,7 +4199,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.4", + "webpki-roots", "winreg 0.50.0", ] @@ -4440,9 +4446,7 @@ version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ - "log", "once_cell", - "ring", "rustls-pki-types", "rustls-webpki 0.102.6", "subtle", @@ -5312,6 +5316,7 @@ dependencies = [ "indexmap 2.2.6", "log", "memchr", + "native-tls", "once_cell", "paste", "percent-encoding", @@ -5329,7 +5334,7 @@ dependencies = [ "tracing", "url", "uuid", - "webpki-roots 0.25.4", + "webpki-roots", ] [[package]] @@ -6411,15 +6416,6 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" -[[package]] -name = "webpki-roots" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "whoami" version = "1.5.1" @@ -6452,6 +6448,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index e4f8f828e4..4fafb6c1a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ sea-orm = { version = "=1.0.0-rc.5", features = [ "debug-print", "postgres-array", "macros", - "runtime-tokio-rustls", + "runtime-tokio-native-tls", "sqlx-postgres", "with-chrono", "with-json", diff --git a/Dockerfile b/Dockerfile index ef38ac8503..19aacdb9db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ RUN moon run frontend:build transactional:build RUN moon docker prune FROM --platform=$BUILDPLATFORM lukemathwalker/cargo-chef AS backend-chef -RUN apt-get update && apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-arm64-cross clang llvm ca-certificates +RUN apt-get update && apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-arm64-cross clang llvm ca-certificates pkg-config make g++ libssl-dev RUN update-ca-certificates WORKDIR app @@ -32,7 +32,6 @@ RUN cargo chef prepare --recipe-path recipe.json FROM backend-chef AS backend-builder # build specific -ARG TARGETARCH ARG BUILD_PROFILE=release # application specific ARG APP_VERSION @@ -41,21 +40,15 @@ ARG DEFAULT_MAL_CLIENT_ID RUN test -n "$APP_VERSION" && \ test -n "$DEFAULT_TMDB_ACCESS_TOKEN" && \ test -n "$DEFAULT_MAL_CLIENT_ID" -ENV RUST_TARGET_TRIPLE_arm64="aarch64-unknown-linux-gnu" -ENV RUST_TARGET_TRIPLE_amd64="x86_64-unknown-linux-gnu" -ENV TARGET_CC="clang" -ENV TARGET_AR="llvm-ar" -ENV CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu" -ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc COPY --from=backend-planner /app/recipe.json recipe.json -RUN rustup target add $(eval "echo \$RUST_TARGET_TRIPLE_$TARGETARCH") -RUN cargo chef cook --profile $BUILD_PROFILE --target $(eval "echo \$RUST_TARGET_TRIPLE_$TARGETARCH") --recipe-path recipe.json +RUN cargo chef cook --profile $BUILD_PROFILE --recipe-path recipe.json COPY . . COPY --from=frontend-builder /app/apps/backend/templates ./apps/backend/templates RUN APP_VERSION=$APP_VERSION \ DEFAULT_TMDB_ACCESS_TOKEN=$DEFAULT_TMDB_ACCESS_TOKEN \ DEFAULT_MAL_CLIENT_ID=$DEFAULT_MAL_CLIENT_ID \ - ./apps/backend/ci/build-app.sh + cargo build --profile ${BUILD_PROFILE} --bin ryot +RUN cp -R /app/target/${BUILD_PROFILE}/ryot /app/ryot FROM $NODE_BASE_IMAGE LABEL org.opencontainers.image.source="https://github.com/IgnisDa/ryot" diff --git a/apps/backend/Cargo.toml b/apps/backend/Cargo.toml index b535988553..a853727ca2 100644 --- a/apps/backend/Cargo.toml +++ b/apps/backend/Cargo.toml @@ -44,11 +44,7 @@ isolang = { version = "=2.4.0", features = ["list_languages"] } itertools = "=0.13.0" jsonwebtoken = { version = "=9.3.0", default-features = false } kinded = "=0.3.0" -lettre = { version = "=0.11.7", features = [ - "rustls-tls", - "smtp-transport", - "builder", -], default-features = false } +lettre = "=0.11.7" markdown = "=1.0.0-alpha.18" mime_guess = "=2.0.5" nanoid = { workspace = true } @@ -60,7 +56,6 @@ regex = "=1.10.5" # FIXME: Upgrade once https://github.com/seanmonstar/reqwest/pull/1620 is merged reqwest = { git = "https://github.com/thomasqueirozb/reqwest", branch = "base_url", features = [ "json", - "rustls-tls", "stream", ], default-features = false } rs-utils = { path = "../../libs/rs-utils" } diff --git a/apps/backend/ci/build-app.sh b/apps/backend/ci/build-app.sh deleted file mode 100755 index 9ef66c9135..0000000000 --- a/apps/backend/ci/build-app.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -euxo pipefail - -export RUST_TARGET_TRIPLE=$(eval "echo \$RUST_TARGET_TRIPLE_$TARGETARCH") - -rustup target add $RUST_TARGET_TRIPLE -cargo build --profile ${BUILD_PROFILE} --bin ryot --target ${RUST_TARGET_TRIPLE} -cp -R /app/target/${RUST_TARGET_TRIPLE}/${BUILD_PROFILE}/ryot /app/ryot diff --git a/apps/backend/src/miscellaneous.rs b/apps/backend/src/miscellaneous.rs index 4167dfcb5f..611eb393f5 100644 --- a/apps/backend/src/miscellaneous.rs +++ b/apps/backend/src/miscellaneous.rs @@ -1,5 +1,6 @@ use std::{ collections::{HashMap, HashSet}, + fmt, fs::File, future::Future, iter::zip, @@ -583,9 +584,9 @@ struct ProgressUpdateCache { manga_chapter_number: Option, } -impl ToString for ProgressUpdateCache { - fn to_string(&self) -> String { - format!("{:#?}", self) +impl fmt::Display for ProgressUpdateCache { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:#?}", self) } } diff --git a/apps/backend/src/notification.rs b/apps/backend/src/notification.rs index 992cfc85a4..1210f2809c 100644 --- a/apps/backend/src/notification.rs +++ b/apps/backend/src/notification.rs @@ -163,9 +163,8 @@ impl NotificationPlatformSpecifics { config.server.smtp.password.to_owned(), ); - let mailer = SmtpTransport::starttls_relay(&config.server.smtp.server) + let mailer = SmtpTransport::relay(&config.server.smtp.server) .unwrap() - .port(config.server.smtp.port) .credentials(credentials) .build(); diff --git a/apps/backend/src/utils.rs b/apps/backend/src/utils.rs index afca45235a..9562794c79 100644 --- a/apps/backend/src/utils.rs +++ b/apps/backend/src/utils.rs @@ -74,7 +74,6 @@ pub struct AppServices { pub media_service: Arc, pub importer_service: Arc, pub exporter_service: Arc, - pub file_storage_service: Arc, pub exercise_service: Arc, } @@ -159,7 +158,6 @@ pub async fn create_app_services( media_service, importer_service, exporter_service, - file_storage_service, exercise_service, } } diff --git a/docs/includes/backend-config-schema.yaml b/docs/includes/backend-config-schema.yaml index d8ce4a928a..ffdff6f777 100644 --- a/docs/includes/backend-config-schema.yaml +++ b/docs/includes/backend-config-schema.yaml @@ -206,9 +206,6 @@ server: # @envvar SERVER_SMTP_PASSWORD password: "" - # @envvar SERVER_SMTP_PORT - port: 587 - # @envvar SERVER_SMTP_SERVER server: "" diff --git a/libs/config/src/lib.rs b/libs/config/src/lib.rs index 390e95f898..daa5fbeb62 100644 --- a/libs/config/src/lib.rs +++ b/libs/config/src/lib.rs @@ -338,8 +338,6 @@ pub struct SchedulerConfig { #[config(rename_all = "snake_case", env_prefix = "SERVER_SMTP_")] pub struct SmtpConfig { pub server: String, - #[setting(default = 587)] - pub port: u16, pub user: String, pub password: String, #[setting(default = "Ryot ")] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7a231182a9..b09cebf85b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] profile = "default" -channel = "1.77.2" +channel = "1.80.0"