feat: Split into API and Streamlit builds
All checks were successful
armco-org/visual-search-engine/pipeline/head This commit looks good
All checks were successful
armco-org/visual-search-engine/pipeline/head This commit looks good
- Add Dockerfile.api for backend API service (port 8081) - Add Dockerfile.streamlit for Streamlit UI (port 3000) - Update Jenkinsfile to build two images: visualsearch and visualsearch-stl
This commit is contained in:
61
Dockerfile.api
Normal file
61
Dockerfile.api
Normal file
@@ -0,0 +1,61 @@
|
||||
# Reverse Image Search API
|
||||
# Multi-stage build for optimized image size
|
||||
|
||||
FROM python:3.11-slim as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements and install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir --user -r requirements.txt
|
||||
|
||||
# Production stage
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install runtime dependencies (libgomp for OpenMP parallelism)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libgomp1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# FAISS uses OpenMP for parallel search - set threads for Xeon
|
||||
ENV OMP_NUM_THREADS=8
|
||||
|
||||
# Copy installed packages from builder
|
||||
COPY --from=builder /root/.local /root/.local
|
||||
ENV PATH=/root/.local/bin:$PATH
|
||||
|
||||
# Copy application code
|
||||
COPY api/ ./api/
|
||||
COPY config.py .
|
||||
COPY reverse_icon_search.py .
|
||||
COPY run_api_server.py .
|
||||
|
||||
# Copy pre-built index and filenames for inference
|
||||
COPY index.faiss .
|
||||
COPY filenames.pkl .
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p uploads logs
|
||||
|
||||
# Environment variables
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV API_PORT=8081
|
||||
ENV DEBUG=false
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8081
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8081/api/health')" || exit 1
|
||||
|
||||
# Run the application
|
||||
CMD ["python", "run_api_server.py"]
|
||||
60
Dockerfile.streamlit
Normal file
60
Dockerfile.streamlit
Normal file
@@ -0,0 +1,60 @@
|
||||
# Reverse Image Search Streamlit UI
|
||||
# Multi-stage build for optimized image size
|
||||
|
||||
FROM python:3.11-slim as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements and install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir --user -r requirements.txt
|
||||
|
||||
# Production stage
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install runtime dependencies (libgomp for OpenMP parallelism)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libgomp1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# FAISS uses OpenMP for parallel search - set threads for Xeon
|
||||
ENV OMP_NUM_THREADS=8
|
||||
|
||||
# Copy installed packages from builder
|
||||
COPY --from=builder /root/.local /root/.local
|
||||
ENV PATH=/root/.local/bin:$PATH
|
||||
|
||||
# Copy application code
|
||||
COPY config.py .
|
||||
COPY reverse_icon_search.py .
|
||||
COPY main_streamlit.py .
|
||||
|
||||
# Copy pre-built index and filenames for inference
|
||||
COPY index.faiss .
|
||||
COPY filenames.pkl .
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p uploads logs
|
||||
|
||||
# Environment variables
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV STREAMLIT_SERVER_PORT=3000
|
||||
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:3000/_stcore/health')" || exit 1
|
||||
|
||||
# Run Streamlit
|
||||
CMD ["streamlit", "run", "main_streamlit.py", "--server.port=3000", "--server.address=0.0.0.0"]
|
||||
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
@@ -4,6 +4,7 @@ kanikoPipeline(
|
||||
repoName: 'visual-search-engine',
|
||||
branch: env.BRANCH_NAME ?: 'main',
|
||||
builds: [
|
||||
[imageName: 'visual-search-engine', dockerfile: 'Dockerfile']
|
||||
[imageName: 'visualsearch', dockerfile: 'Dockerfile.api'],
|
||||
[imageName: 'visualsearch-stl', dockerfile: 'Dockerfile.streamlit']
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user