colpali-backend-api / Dockerfile
vk98's picture
Fix Dockerfile syntax error and update Vespa endpoint
f98308d
raw
history blame
1.95 kB
FROM node:20-slim
# Install Python and system dependencies
RUN apt-get update && apt-get install -y \
python3.11 \
python3-pip \
python3.11-venv \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user (required by HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set working directory
WORKDIR $HOME/app
# Copy backend files only
COPY --chown=user embedding_api.py $HOME/app/
COPY --chown=user requirements_embedding.txt $HOME/app/
COPY --chown=user hono-proxy $HOME/app/hono-proxy
# Create Python virtual environment
RUN python3.11 -m venv $HOME/venv
ENV PATH="$HOME/venv/bin:$PATH"
# Install Python dependencies for embedding API
RUN pip install --upgrade pip
RUN pip install -r requirements_embedding.txt
# Install pnpm and Node dependencies for Hono proxy
RUN npm install -g pnpm
WORKDIR $HOME/app/hono-proxy
RUN pnpm install
# Copy Vespa certificates (these need to be included in the repo)
RUN mkdir -p $HOME/.vespa/il-infra.colpali-server.default
COPY --chown=user vespa-certs/* $HOME/.vespa/il-infra.colpali-server.default/ || true
# Create startup script for backend services only
WORKDIR $HOME/app
RUN printf '#!/bin/bash\n\
\n\
# Start embedding API on port 8001\n\
echo "Starting ColPali embedding API on port 8001..."\n\
python embedding_api.py &\n\
EMBED_PID=$!\n\
\n\
# Wait for embedding API to be ready\n\
sleep 10\n\
\n\
# Start Hono proxy on HF Spaces port 7860\n\
echo "Starting Hono proxy on port 7860..."\n\
cd hono-proxy && PORT=7860 CORS_ORIGIN="*" EMBEDDING_API_URL="http://localhost:8001" VESPA_ENDPOINT="https://f5acf536.ed2ceb09.z.vespa-app.cloud" npx tsx src/index.ts\n\
\n\
# If Hono exits, kill embedding service\n\
kill $EMBED_PID\n' > start-backend.sh
RUN chmod +x start-backend.sh
# Expose HF Spaces port (Hono proxy will run on this)
EXPOSE 7860
# Run the startup script
CMD ["./start-backend.sh"]