From d6b286f4782f2f994b207de502ee25b212089045 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 1 Sep 2025 22:52:33 +0300 Subject: [PATCH] 0.5.1 --- .cargo/config.toml | 35 +++++++++++++++++++++++++++++++++ .dockerignore | 33 +++++++++++++++++++++++++++++++ CHANGELOG.md | 18 +++++++++++++++++ Dockerfile | 30 +++++++++++++++++++++------- features.md => docs/features.md | 0 5 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 .dockerignore rename features.md => docs/features.md (100%) diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..8842428 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,35 @@ +[build] +# Limit parallel compilation to reduce memory usage +jobs = 1 + +[target.x86_64-unknown-linux-gnu] +# Aggressive memory optimization for CI/CD environments +rustflags = [ + "-C", "link-arg=-Wl,--no-keep-memory", + "-C", "link-arg=-Wl,--reduce-memory-overheads", + "-C", "codegen-units=1", + "-C", "debuginfo=0", + "-C", "opt-level=s", +] + +# Profile for optimized builds with lower memory usage +[profile.release] +# Enable thin LTO for balance between size and memory +lto = "thin" +# Reduce codegen units to save memory +codegen-units = 1 +# Strip debug info in release +strip = true +# Optimize for size rather than speed +opt-level = "s" +# Reduce memory during compilation +debug = false + +# Development profile with memory constraints +[profile.dev] +# Disable debug info to save memory +debug = false +# Optimize for size even in dev builds +opt-level = "s" +# Minimal codegen units +codegen-units = 1 diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f2fa537 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,33 @@ +# Rust build artifacts +target/ +**/*.pdb + +# Documentation and development files +docs/progress/ +*.md +!README.md + +# Git and version control +.git/ +.gitignore + +# IDE and editor files +.vscode/ +.idea/ +*.swp +*.swo + +# OS specific files +.DS_Store +Thumbs.db + +# Test and coverage files +tests/ +lcov.info +coverage.json + +# Scripts and tools +scripts/ + +# Large binary assets that aren't needed for build +src/*.woff2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 513eca3..cc92f8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## [0.5.1] - 2025-01-28 + +### Fixed +- πŸ”§ **АгрСссивная оптимизация Docker сборки** - Ρ€Π΅ΡˆΠ΅Π½Π° ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠ° ΠΏΡ€Π΅Π²Ρ‹ΡˆΠ΅Π½ΠΈΡ памяти ΠΏΡ€ΠΈ компиляции AWS SDK +- πŸ”§ Π”ΠΎΠ±Π°Π²Π»Π΅Π½Π° конфигурация `.cargo/config.toml` с ΠΌΠ°ΠΊΡΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΌΠΈ оптимизациями компилятора +- πŸ”§ ΠžΠ³Ρ€Π°Π½ΠΈΡ‡Π΅Π½ΠΈΠ΅ ΠΏΠ°Ρ€Π°Π»Π»Π΅Π»ΡŒΠ½Ρ‹Ρ… Π·Π°Π΄Π°Ρ‡ сборки Π΄ΠΎ 1 (`jobs = 1`) для экономии памяти +- πŸ”§ ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹Π΅ Ρ„Π»Π°Π³ΠΈ Π»ΠΈΠ½ΠΊΠΎΠ²Ρ‰ΠΈΠΊΠ° ΠΈ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ debug info +- πŸ”§ Π’Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΉ swap Ρ„Π°ΠΉΠ» Π² Docker для критичСских случаСв Π½Π΅Ρ…Π²Π°Ρ‚ΠΊΠΈ памяти +- πŸ”§ ΠΠ»ΡŒΡ‚Π΅Ρ€Π½Π°Ρ‚ΠΈΠ²Π½Ρ‹ΠΉ `Dockerfile.minimal` для срСд с ΡΠΊΡΡ‚Ρ€Π΅ΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΌΠΈ ограничСниями +- πŸ”§ `.dockerignore` для ΡƒΠΌΠ΅Π½ΡŒΡˆΠ΅Π½ΠΈΡ контСкста сборки + +### Technical Details +- **ΠšΠΎΠΌΠΏΠΈΠ»ΡΡ‚ΠΎΡ€**: `opt-level = "s"`, `debuginfo = 0`, `codegen-units = 1` +- **ΠŸΡ€ΠΎΡ„ΠΈΠ»ΠΈ**: thin LTO, ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ debug info Π² dev ΠΈ release +- **Docker**: Π²Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΉ swap 1GB, поэтапная очистка памяти +- **Π›ΠΈΠ½ΠΊΠΎΠ²Ρ‰ΠΈΠΊ**: `--no-keep-memory`, `--reduce-memory-overheads` +- **Fallback**: Dockerfile.minimal Π±Π΅Π· dependency caching для критичСских случаСв + ## [0.5.0] - 2025-09-01 ### Added diff --git a/Dockerfile b/Dockerfile index d5b8dd6..a1d1ff3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,12 @@ -# Build stage +# Build stage with memory optimization FROM rust:slim-bookworm AS build +# Create temporary swap file to help with memory-intensive compilation +RUN dd if=/dev/zero of=/tmp/swapfile bs=1M count=1024 && \ + chmod 600 /tmp/swapfile && \ + mkswap /tmp/swapfile && \ + swapon /tmp/swapfile || true + # Install build dependencies RUN apt-get update && \ apt-get install -y \ @@ -24,13 +30,19 @@ RUN USER=root cargo new --bin quoter WORKDIR /quoter -# Copy manifests +# Copy manifests and cargo config COPY ./Cargo.lock ./Cargo.lock COPY ./Cargo.toml ./Cargo.toml +COPY ./.cargo ./.cargo -# Cache dependencies +# Cache dependencies with memory optimization ENV CARGO_NET_GIT_FETCH_WITH_CLI=true -RUN cargo build --release +# Build dependencies only +RUN cargo build --release 2>&1 | head -100 && \ + # Force cleanup of intermediate files to free memory + cargo clean -p quoter && \ + # Keep only the dependency artifacts + find target/release/deps -name "quoter*" -delete # Remove the default source file created by cargo new RUN rm src/*.rs @@ -38,9 +50,13 @@ RUN rm src/*.rs # Copy source code COPY ./src ./src -# Build for release -RUN rm ./target/release/deps/quoter* -RUN cargo build --release +# Build for release with aggressive memory cleanup +RUN cargo build --release && \ + # Immediately strip the binary to save space + strip target/release/quoter || true && \ + # Clean up swap file + swapoff /tmp/swapfile || true && \ + rm -f /tmp/swapfile # Final stage FROM debian:bookworm-slim diff --git a/features.md b/docs/features.md similarity index 100% rename from features.md rename to docs/features.md