colpali-backend-api / Dockerfile
vk98's picture
Use simpler Dockerfile without venv
04bb55c
raw
history blame
2.27 kB
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
nodejs \
npm \
git \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install pnpm globally
RUN npm install -g pnpm
# Create user for HF Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy files
COPY --chown=user embedding_api.py .
COPY --chown=user requirements_embedding.txt .
COPY --chown=user hono-proxy ./hono-proxy
COPY --chown=user vespa-certs ./vespa-certs
# Install Python dependencies
RUN pip install --user --no-cache-dir -r requirements_embedding.txt
# Install Node dependencies
WORKDIR $HOME/app/hono-proxy
RUN pnpm install
# Setup Vespa certificates
RUN mkdir -p $HOME/.vespa/il-infra.colpali-server.default && \
cp ../vespa-certs/* $HOME/.vespa/il-infra.colpali-server.default/
# Create startup script
WORKDIR $HOME/app
RUN echo '#!/bin/bash' > start.sh && \
echo 'echo "Starting services..."' >> start.sh && \
echo 'echo "Python version: $(python --version)"' >> start.sh && \
echo 'echo "Node version: $(node --version)"' >> start.sh && \
echo '' >> start.sh && \
echo '# Start embedding API' >> start.sh && \
echo 'python embedding_api.py &' >> start.sh && \
echo 'EMBED_PID=$!' >> start.sh && \
echo 'echo "Started embedding API with PID: $EMBED_PID"' >> start.sh && \
echo '' >> start.sh && \
echo '# Wait for embedding API' >> start.sh && \
echo 'sleep 5' >> start.sh && \
echo '' >> start.sh && \
echo '# Check if embedding API is running' >> start.sh && \
echo 'if curl -f http://localhost:8001/health; then' >> start.sh && \
echo ' echo "Embedding API is healthy"' >> start.sh && \
echo 'else' >> start.sh && \
echo ' echo "Embedding API health check failed"' >> start.sh && \
echo 'fi' >> start.sh && \
echo '' >> start.sh && \
echo '# Start Hono proxy' >> start.sh && \
echo 'cd hono-proxy' >> start.sh && \
echo 'PORT=7860 CORS_ORIGIN="*" EMBEDDING_API_URL="http://localhost:8001" VESPA_ENDPOINT="https://f5acf536.ed2ceb09.z.vespa-app.cloud" npx tsx src/index.ts' >> start.sh && \
chmod +x start.sh
EXPOSE 7860
CMD ["./start.sh"]