diff --git a/Dockerfile.blackhole b/Dockerfile.blackhole index e0f0ee1..cad8da2 100644 --- a/Dockerfile.blackhole +++ b/Dockerfile.blackhole @@ -1,22 +1,46 @@ -FROM python:3.9-slim +# Frontend build stage +FROM node:18-slim AS frontend-builder +WORKDIR /app + +# Copy package files first for better caching +COPY client/package*.json ./ +RUN npm install + +# Copy the rest of the client code +COPY client/ ./ + +# Build the frontend first +RUN npm run build + +# Create directory structure for mediainfo images +RUN mkdir -p /app/build/static/images/mediainfo/codec \ + /app/build/static/images/mediainfo/edition \ + /app/build/static/images/mediainfo/resolution -# Metadata labels +# Copy mediainfo images to the correct location and verify +COPY client/src/images/mediainfo/codec/* /app/build/static/images/mediainfo/codec/ +COPY client/src/images/mediainfo/edition/* /app/build/static/images/mediainfo/edition/ +COPY client/src/images/mediainfo/resolution/* /app/build/static/images/mediainfo/resolution/ + +# Python application stage +FROM python:3.9-slim LABEL org.opencontainers.image.source="https://github.com/westsurname/scripts" LABEL org.opencontainers.image.description="Docker image for the blackhole service" ARG SERVICE_NAME=blackhole - -# Set working directory WORKDIR /app -# Copy only the files needed for pip install to maximize cache utilization +# Install Python dependencies first for better caching COPY requirements.txt ./ - -# Install Python dependencies RUN grep -E "#.*($SERVICE_NAME|all)" requirements.txt | awk '{print $0}' > service_requirements.txt && \ pip install --no-cache-dir -r service_requirements.txt -# Copy the rest of the application +# Copy application code COPY . . -CMD ["python", "blackhole_watcher.py"] \ No newline at end of file +# Copy frontend build files +COPY --from=frontend-builder /app/build/* /app/static/ + +ENV PYTHONBUFFERED=1 + +CMD ["python", "blackhole_watcher.py"]