diff --git a/Dockerfile b/Dockerfile index c754456..863d03d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# Stage 1: Build Frontend -FROM node:20-alpine AS frontend-builder +# Build stage with explicit platform for Synology NAS compatibility +FROM --platform=linux/amd64 node:20-alpine AS frontend-builder WORKDIR /app/frontend COPY frontend-vite/package*.json ./ @@ -9,8 +9,8 @@ COPY frontend-vite/ . ENV NODE_ENV=production RUN npm run build -# Stage 2: Build Backend (Rust) -FROM rust:1.85-alpine AS backend-builder +# Build Backend (Rust) +FROM --platform=linux/amd64 rust:1.85-alpine AS backend-builder WORKDIR /app/backend RUN apk add --no-cache musl-dev openssl-dev perl @@ -21,8 +21,8 @@ RUN cargo fetch COPY backend-rust/ ./ RUN cargo build --release --bin backend-rust -# Stage 3: Final Runtime -FROM python:3.11-slim-bookworm +# Final Runtime - using debian base for better amd64 compatibility on Synology +FROM --platform=linux/amd64 python:3.11-slim-bookworm WORKDIR /app @@ -32,16 +32,11 @@ RUN apt-get update && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* -# Install yt-dlp RUN pip install --no-cache-dir -U "yt-dlp[default]" -# Copy backend binary COPY --from=backend-builder /app/backend/target/release/backend-rust /app/server - -# Copy frontend build COPY --from=frontend-builder /app/frontend/dist /app/static -# Create cache directories RUN mkdir -p /tmp/spotify-clone-cache /tmp/spotify-clone-downloads && chmod 777 /tmp/spotify-clone-cache /tmp/spotify-clone-downloads ENV PORT=8080 @@ -49,4 +44,6 @@ ENV RUST_LOG=info EXPOSE 8080 +USER 1000 + CMD ["/app/server"] diff --git a/docker-compose.yml b/docker-compose.yml index 2f53c9f..ad4c0ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,10 @@ services: spotify-clone: image: git.khoavo.myds.me/vndangkhoa/spotify-clone:v3 container_name: spotify-clone + build: + context: . + dockerfile: Dockerfile + platform: linux/amd64 restart: unless-stopped ports: - "3110:8080"