Spaces:
Paused
Paused
File size: 1,328 Bytes
bed9a40 4b8674c bed9a40 c69f75c ff79bde c69f75c bed9a40 7369bce bed9a40 c69f75c eb4abb8 |
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 |
# 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"]
|