Spaces:
Paused
Paused
# syntax=docker/dockerfile:1.4 | |
# Step 1: Setup backend environment with Miniconda | |
FROM continuumio/miniconda3:latest AS backend | |
# Install system dependencies for OpenCV | |
RUN apt-get update && apt-get install -y \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 && \ | |
rm -rf /var/lib/apt/lists/* | |
# Create a non-root user for security purposes | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Set the working directory for the backend | |
WORKDIR /api | |
# Copy the environment file and install dependencies | |
COPY --chown=user api/environment.yml ./ | |
# Install the conda environment | |
RUN conda env create -n mgd --file environment.yml && conda clean -a -y | |
# Install additional Python packages via pip after activating conda environment | |
RUN /bin/bash -c "source /opt/conda/etc/profile.d/conda.sh && conda activate mgd && pip install Flask Flask-Cors Flask-Limiter gunicorn" | |
# Copy the backend application code | |
COPY --chown=user api/ . | |
RUN mkdir -p /api/output/generato_paired_paired/images && chown -R user:user /api/output | |
# Expose port 7860 for the backend service | |
EXPOSE 7860 | |
# Set default command to initialize conda, activate the environment, and start the backend model | |
CMD ["bash", "-c", "source /opt/conda/etc/profile.d/conda.sh && conda activate mgd && python app.py --host=0.0.0.0 --port 7860"] | |