diff --git a/Dockerfile b/Dockerfile index 3367860..68c25bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,31 @@ FROM node:20-slim AS frontend-builder WORKDIR /app/frontend - COPY frontend-vite/package*.json ./ RUN npm ci - 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 -# Install build dependencies for Debian RUN apt-get update && apt-get install -y \ pkg-config \ libssl-dev \ - libc6-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/ ./ -RUN cargo build --release --bin 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 @@ -36,19 +39,27 @@ RUN apt-get update && apt-get install -y \ RUN pip install --no-cache-dir -U "yt-dlp[default]" -COPY --from=backend-builder /app/backend/target/release/backend-rust /app/server +# 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 - -# Using root for compatibility with Synology permissions, change to USER 1000 if needed for security USER 0 -CMD ["/app/server"] +ENTRYPOINT ["/app/entrypoint.sh"]