Spaces:
Sleeping
Sleeping
File size: 1,712 Bytes
d086f83 100a6dd d086f83 100a6dd d086f83 100a6dd d086f83 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # Stage 1: Build the Python backend (switching to Debian-based image)
FROM python:3.11-slim AS backend-builder
WORKDIR /app
# Install build tools using apt-get
RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/*
COPY requirements.api.txt .
RUN pip install --no-cache-dir -r requirements.api.txt
COPY chess_engine/ ./chess_engine
COPY main.py .
COPY app.py .
# Stage 2: Final image (switching to Debian-based image)
FROM python:3.11-slim
# Install Node.js, npm, Stockfish, and dos2unix using apt-get
RUN apt-get update && \
apt-get install -y --no-install-recommends curl dos2unix && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y --no-install-recommends nodejs stockfish && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the installed Python dependencies
COPY --from=backend-builder /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/
COPY --from=backend-builder /app/chess_engine ./chess_engine
COPY --from=backend-builder /app/main.py .
COPY --from=backend-builder /app/app.py .
# Copy frontend files
COPY web/ ./web/
# Build the frontend
WORKDIR /app/web
RUN npm install
# Add environment variable to skip TypeScript errors during build
ENV TSC_COMPILE_ON_ERROR=true
RUN npm run build
# Copy the built frontend files to the location expected by the backend
WORKDIR /app
RUN mkdir -p ./dist
RUN cp -r /app/web/dist/* ./dist/
# Copy the entrypoint script and ensure it's executable
COPY docker-entrypoint.sh .
RUN dos2unix docker-entrypoint.sh && \
chmod +x docker-entrypoint.sh
# Expose the ports
EXPOSE 8000
EXPOSE 5173
ENTRYPOINT ["./docker-entrypoint.sh"] |