From b18b94ef502eded5e999ad79419c2085fb97b608 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Jan 2026 15:14:15 +0000 Subject: [PATCH 1/5] =?UTF-8?q?Dockerfile=E3=81=A8Cargo.toml=E3=81=AE?= =?UTF-8?q?=E6=9C=80=E9=81=A9=E5=8C=96=E3=80=81=E4=B8=8D=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82=E3=81=AE=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=81=A8=E3=83=93=E3=83=AB=E3=83=89=E8=A8=AD=E5=AE=9A=E3=81=AE?= =?UTF-8?q?=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cargo/config.toml | 2 ++ Cargo.toml | 15 ++++++++++----- Dockerfile | 24 +++++++++++++++++------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index cdbb109..52a909a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,7 @@ [target.x86_64-unknown-linux-musl] +linker = "clang" rustflags = ["-C", "link-arg=-fuse-ld=mold"] [target.aarch64-unknown-linux-musl] +linker = "clang" rustflags = ["-C", "link-arg=-fuse-ld=mold"] \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f733014..061c0ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,18 +10,14 @@ serde = { version = "1", features = ["derive"] } serde_json = "1" uuid = { version = "1", features = ["v4", "serde"] } chrono = { version = "0.4", features = ["serde"] } -sea-orm = { version = "1.1.19", features = ["sqlx-mysql", "runtime-tokio-rustls", "macros", "debug-print"] } +sea-orm = { version = "1.1.19", features = ["sqlx-mysql", "runtime-tokio-rustls", "macros"] } sea-orm-migration = "1.1.19" dotenvy = "0.15" -thiserror = "2.0.17" -anyhow = "1" -validator = "0.20.0" jsonwebtoken = { version = "10.2.0", features = ["rust_crypto"] } hex = "0.4.3" sha2 = "0.10.9" futures = "0.3.31" ulid = "1.2.1" -serde_with = "3.15.1" tracing-subscriber = "0.3.20" tracing = "0.1.41" bitflags = "2.10.0" @@ -29,3 +25,12 @@ utoipa = { version = "5", features = ["axum_extras", "chrono", "uuid"] } tower-http = { version = "0.6", features = ["cors"] } tower = "0.4" + +[profile.release] +lto = "thin" +codegen-units = 16 +opt-level = 2 + +[profile.dev] +opt-level = 0 +debug = 0 diff --git a/Dockerfile b/Dockerfile index ff944fd..becad64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,29 @@ + FROM rust:1-alpine AS builder +RUN apk add --no-cache musl-dev mold clang build-base + WORKDIR /usr/src/app -COPY . . +COPY .cargo .cargo -RUN apk add --no-cache musl-dev mold clang build-base +COPY Cargo.toml Cargo.lock ./ +RUN mkdir src && echo "fn main() {}" > src/main.rs -RUN cargo fix --bin "UniQUE-API" +RUN --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cargo/git \ + cargo build --release -j $(nproc) -RUN cargo build --release +RUN rm -rf src -FROM alpine:latest +COPY . . +RUN touch src/main.rs -WORKDIR /root/ +RUN --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cargo/git \ + cargo build --release -j $(nproc) +FROM alpine:latest +WORKDIR /root/ COPY --from=builder /usr/src/app/target/release/UniQUE-API . - CMD ["./UniQUE-API"] \ No newline at end of file From 79ff353dbc4c6f520fb1b738960c582e07aa61d5 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Jan 2026 15:41:45 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E4=BE=9D?= =?UTF-8?q?=E5=AD=98=E9=96=A2=E4=BF=82=E3=81=AE=E5=89=8A=E9=99=A4=E3=81=A8?= =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82=E3=81=AE=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=B3=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 166 +++-------------------------------------------------- 1 file changed, 7 insertions(+), 159 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df95e86..5084af4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,6 @@ version = 4 name = "UniQUE-API" version = "1.0.0-alpha.16" dependencies = [ - "anyhow", "axum", "bitflags", "chrono", @@ -18,9 +17,7 @@ dependencies = [ "sea-orm-migration", "serde", "serde_json", - "serde_with", "sha2", - "thiserror", "tokio", "tower 0.4.13", "tower-http", @@ -29,7 +26,6 @@ dependencies = [ "ulid", "utoipa", "uuid", - "validator", ] [[package]] @@ -123,12 +119,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "anyhow" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" - [[package]] name = "arrayvec" version = "0.7.6" @@ -563,18 +553,8 @@ version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ - "darling_core 0.20.11", - "darling_macro 0.20.11", -] - -[[package]] -name = "darling" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" -dependencies = [ - "darling_core 0.21.3", - "darling_macro 0.21.3", + "darling_core", + "darling_macro", ] [[package]] @@ -590,38 +570,13 @@ dependencies = [ "syn 2.0.113", ] -[[package]] -name = "darling_core" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.113", -] - [[package]] name = "darling_macro" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ - "darling_core 0.20.11", - "quote", - "syn 2.0.113", -] - -[[package]] -name = "darling_macro" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" -dependencies = [ - "darling_core 0.21.3", + "darling_core", "quote", "syn 2.0.113", ] @@ -698,12 +653,6 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" -[[package]] -name = "dyn-clone" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" - [[package]] name = "ecdsa" version = "0.16.9" @@ -1305,17 +1254,6 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.12.1" @@ -1941,26 +1879,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "ref-cast" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.113", -] - [[package]] name = "regex" version = "1.12.2" @@ -2143,30 +2061,6 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" -[[package]] -name = "schemars" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - -[[package]] -name = "schemars" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e910108742c57a770f492731f99be216a52fadd361b06c8fb59d74ccc267d2" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -2301,7 +2195,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bae0cbad6ab996955664982739354128c58d16e126114fe88c2a493642502aab" dependencies = [ - "darling 0.20.11", + "darling", "heck 0.4.1", "proc-macro2", "quote", @@ -2424,37 +2318,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "3.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" -dependencies = [ - "base64", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.12.1", - "schemars 0.9.0", - "schemars 1.2.0", - "serde_core", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52a8e3ca0ca629121f70ab50f95249e5a6f925cc0f6ffe8256c45b728875706c" -dependencies = [ - "darling 0.21.3", - "proc-macro2", - "quote", - "syn 2.0.113", -] - [[package]] name = "sha1" version = "0.10.6" @@ -2597,7 +2460,7 @@ dependencies = [ "futures-util", "hashbrown 0.15.5", "hashlink", - "indexmap 2.12.1", + "indexmap", "log", "memchr", "once_cell", @@ -2996,7 +2859,7 @@ version = "0.23.10+spec-1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" dependencies = [ - "indexmap 2.12.1", + "indexmap", "toml_datetime", "toml_parser", "winnow", @@ -3211,7 +3074,7 @@ version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fcc29c80c21c31608227e0912b2d7fddba57ad76b606890627ba8ee7964e993" dependencies = [ - "indexmap 2.12.1", + "indexmap", "serde", "serde_json", "utoipa-gen", @@ -3242,21 +3105,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "validator" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43fb22e1a008ece370ce08a3e9e4447a910e92621bb49b85d6e48a45397e7cfa" -dependencies = [ - "idna", - "once_cell", - "regex", - "serde", - "serde_derive", - "serde_json", - "url", -] - [[package]] name = "valuable" version = "0.1.1" From c6de0b380c28658b0ef929311b4acd29a53489cd Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Jan 2026 16:13:34 +0000 Subject: [PATCH 3/5] =?UTF-8?q?.dockerignore=E3=81=AE=E8=BF=BD=E5=8A=A0:?= =?UTF-8?q?=20=E4=B8=8D=E8=A6=81=E3=81=AA=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92Docker=E3=83=93=E3=83=AB=E3=83=89=E3=81=8B?= =?UTF-8?q?=E3=82=89=E9=99=A4=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..df27000 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +target +Dockerfile +.dockerignore From 14f1ef5277be4095739f2b6a5433f15ffa681152 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Jan 2026 16:28:19 +0000 Subject: [PATCH 4/5] =?UTF-8?q?Dockerfile=E3=81=AE=E6=9C=80=E9=81=A9?= =?UTF-8?q?=E5=8C=96:=20=E4=B8=8D=E8=A6=81=E3=81=AACOPY=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=E3=81=97=E3=80=81=E3=83=93=E3=83=AB?= =?UTF-8?q?=E3=83=89=E3=83=97=E3=83=AD=E3=82=BB=E3=82=B9=E3=82=92=E6=94=B9?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index becad64..c1ee99d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ - FROM rust:1-alpine AS builder RUN apk add --no-cache musl-dev mold clang build-base @@ -6,12 +5,13 @@ RUN apk add --no-cache musl-dev mold clang build-base WORKDIR /usr/src/app COPY .cargo .cargo - COPY Cargo.toml Cargo.lock ./ + RUN mkdir src && echo "fn main() {}" > src/main.rs RUN --mount=type=cache,target=/root/.cargo/registry \ --mount=type=cache,target=/root/.cargo/git \ + --mount=type=cache,target=/usr/src/app/target \ cargo build --release -j $(nproc) RUN rm -rf src @@ -21,9 +21,11 @@ RUN touch src/main.rs RUN --mount=type=cache,target=/root/.cargo/registry \ --mount=type=cache,target=/root/.cargo/git \ - cargo build --release -j $(nproc) + --mount=type=cache,target=/usr/src/app/target \ + cargo build --release -j $(nproc) && \ + cp target/release/UniQUE-API /usr/local/bin/ FROM alpine:latest WORKDIR /root/ -COPY --from=builder /usr/src/app/target/release/UniQUE-API . +COPY --from=builder /usr/local/bin/UniQUE-API . CMD ["./UniQUE-API"] \ No newline at end of file From 88ecc510e0ae537dba27680a028cfcb7a842e3e6 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 31 Jan 2026 17:00:36 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=AA=E3=83=AA=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE?= =?UTF-8?q?LTO=E8=A8=AD=E5=AE=9A=E3=82=92=E3=80=8Cthin=E3=80=8D=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=80=8Cfalse=E3=80=8D=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 061c0ca..88fe756 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ tower-http = { version = "0.6", features = ["cors"] } tower = "0.4" [profile.release] -lto = "thin" +lto = false codegen-units = 16 opt-level = 2