Spaces:
Sleeping
Sleeping
File size: 2,187 Bytes
7189a67 0448eaf 7189a67 8257fba 7189a67 bbc2134 7189a67 cacee39 0448eaf 7189a67 0448eaf 7189a67 0448eaf 7189a67 cacee39 7189a67 0448eaf 7189a67 0448eaf 7189a67 0448eaf 7189a67 |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# Use Ubuntu as base image for better compatibility
FROM ubuntu:22.04
# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Update and install essential packages
RUN apt-get update && apt-get install -y \
# Python 3.11 and pip
software-properties-common \
python3.11 \
python3.11-dev \
python3-pip \
python3.11-venv \
# C/C++ compilers and tools
build-essential \
gcc \
g++ \
make \
# Java 17 (full JDK)
openjdk-17-jdk \
# Version control and utilities
git \
curl \
wget \
vim \
# Process monitoring
procps \
htop \
# Clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set Python 3.11 as default python3
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 \
&& update-alternatives --set python3 /usr/bin/python3.11
# Set JAVA_HOME
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH="$JAVA_HOME/bin:$PATH"
# Create app directory
WORKDIR /app
# Create non-root user
RUN useradd -m -u 1000 -s /bin/bash user && \
chown -R user:user /app
# Give user permissions to create temp directories
RUN mkdir -p /tmp/code_workspace && \
chown -R user:user /tmp/code_workspace && \
chmod 755 /tmp/code_workspace
# Switch to non-root user
USER user
# Set user paths
ENV PATH="/home/user/.local/bin:$PATH"
ENV PYTHONPATH="/app:$PYTHONPATH"
# Copy requirements first (for better caching)
COPY --chown=user:user requirements.txt .
# Install Python dependencies
RUN pip3 install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir -r requirements.txt
# Copy application files
COPY --chown=user:user . .
# Verify installations
RUN echo "=== Version Check ===" && \
python3 --version && \
pip3 --version && \
java -version && \
javac -version && \
gcc --version && \
g++ --version
# Expose port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Start the application
CMD ["python3", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |