fix: resolve axum 0.8 root nesting panic and clean up Dockerfile

This commit is contained in:
Khoa Vo 2026-03-20 22:10:17 +07:00
parent 2a752f4ea9
commit b6e1e0a647
2 changed files with 3 additions and 24 deletions

View file

@ -6,60 +6,39 @@ COPY frontend-vite/ .
ENV NODE_ENV=production
RUN npm run build
# Use a builder with musl support for a truly static binary
FROM rust:1.85-slim AS backend-builder
WORKDIR /app/backend
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
musl-tools \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN rustup target add x86_64-unknown-linux-musl
COPY backend-rust/Cargo.toml backend-rust/Cargo.lock ./
# Pre-fetch dependencies
RUN cargo fetch
COPY backend-rust/ ./
# Build as a static binary
RUN cargo build --release --target x86_64-unknown-linux-musl --bin backend-rust
FROM python:3.11-slim-bookworm
WORKDIR /app
RUN apt-get update && apt-get install -y \
ffmpeg \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir -U "yt-dlp[default]"
# Copy the static binary
COPY --from=backend-builder /app/backend/target/x86_64-unknown-linux-musl/release/backend-rust /app/server
COPY --from=frontend-builder /app/frontend/dist /app/static
# Create directories and set permissions
RUN mkdir -p /tmp/spotify-clone-cache /tmp/spotify-clone-downloads && chmod 777 /tmp/spotify-clone-cache /tmp/spotify-clone-downloads
# Add a debug entrypoint to catch early failures
RUN echo '#!/bin/sh\n\
echo "Starting container debug info..."\n\
uname -a\n\
ls -la /app/server\n\
ldd /app/server || echo "Binary is static or ldd failed"\n\
echo "Executing server..."\n\
exec /app/server' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
ENV PORT=8080
ENV RUST_LOG=info
EXPOSE 8080
RUN chmod +x /app/server
USER 0
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["/app/server"]

View file

@ -34,7 +34,7 @@ async fn main() {
.route("/api/artist/info", get(api::artist_info_handler))
.route("/api/browse", get(api::browse_handler))
.route("/api/recommendations", get(api::recommendations_handler))
.nest_service("/", ServeDir::new("static"))
.fallback_service(ServeDir::new("static"))
.layer(cors)
.with_state(app_state);