This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
FROM rust:slim-bookworm AS build
|
||||
|
||||
# Create larger temporary swap file for extreme memory optimization
|
||||
RUN dd if=/dev/zero of=/tmp/swapfile bs=1M count=2048 && \
|
||||
RUN dd if=/dev/zero of=/tmp/swapfile bs=1M count=4096 && \
|
||||
chmod 600 /tmp/swapfile && \
|
||||
mkswap /tmp/swapfile && \
|
||||
swapon /tmp/swapfile || true && \
|
||||
# Set swappiness to use swap more aggressively
|
||||
echo 60 > /proc/sys/vm/swappiness || true
|
||||
echo 80 > /proc/sys/vm/swappiness || true
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && \
|
||||
@@ -44,6 +44,9 @@ ENV CARGO_NET_TIMEOUT=60
|
||||
ENV CARGO_HTTP_TIMEOUT=60
|
||||
ENV CARGO_HTTP_LOW_SPEED_LIMIT=10
|
||||
ENV RUSTC_FORCE_INCREMENTAL=0
|
||||
# Additional memory optimization for Redis connection pool compilation
|
||||
ENV CARGO_BUILD_JOBS=1
|
||||
ENV RUSTFLAGS="-C opt-level=s -C target-cpu=generic"
|
||||
# Build dependencies only with extreme memory conservation
|
||||
RUN cargo build --release && \
|
||||
# Force cleanup of intermediate files to free memory
|
||||
@@ -59,6 +62,8 @@ COPY ./src ./src
|
||||
|
||||
# Build for release with aggressive memory cleanup
|
||||
RUN cargo build --release && \
|
||||
# Verify the binary was created
|
||||
ls -la target/release/quoter && \
|
||||
# Immediately strip the binary to save space
|
||||
strip target/release/quoter || true && \
|
||||
# Clean up swap file
|
||||
|
||||
Reference in New Issue
Block a user