fix: static build and debug entrypoint for synology
This commit is contained in:
parent
68353e4e56
commit
2a752f4ea9
1 changed files with 21 additions and 10 deletions
31
Dockerfile
31
Dockerfile
|
|
@ -1,28 +1,31 @@
|
||||||
FROM node:20-slim AS frontend-builder
|
FROM node:20-slim AS frontend-builder
|
||||||
WORKDIR /app/frontend
|
WORKDIR /app/frontend
|
||||||
|
|
||||||
COPY frontend-vite/package*.json ./
|
COPY frontend-vite/package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
COPY frontend-vite/ .
|
COPY frontend-vite/ .
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# Use a builder with musl support for a truly static binary
|
||||||
FROM rust:1.85-slim AS backend-builder
|
FROM rust:1.85-slim AS backend-builder
|
||||||
WORKDIR /app/backend
|
WORKDIR /app/backend
|
||||||
|
|
||||||
# Install build dependencies for Debian
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
libc6-dev \
|
musl-tools \
|
||||||
|
curl \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
COPY backend-rust/Cargo.toml backend-rust/Cargo.lock ./
|
COPY backend-rust/Cargo.toml backend-rust/Cargo.lock ./
|
||||||
|
# Pre-fetch dependencies
|
||||||
RUN cargo fetch
|
RUN cargo fetch
|
||||||
|
|
||||||
COPY backend-rust/ ./
|
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
|
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]"
|
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
|
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
|
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 PORT=8080
|
||||||
ENV RUST_LOG=info
|
ENV RUST_LOG=info
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
RUN chmod +x /app/server
|
|
||||||
|
|
||||||
# Using root for compatibility with Synology permissions, change to USER 1000 if needed for security
|
|
||||||
USER 0
|
USER 0
|
||||||
|
|
||||||
CMD ["/app/server"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue