geomap_2 / Dockerfile
AdityaAdaki
Fix PORT environment variable issue
1265a74
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile
FROM python:3.9
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
wget \
unzip \
gnupg2 \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Install Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
# Install specific ChromeDriver version for Chrome 131
RUN wget -q "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/131.0.6778.88/linux64/chromedriver-linux64.zip" \
&& unzip chromedriver-linux64.zip \
&& mv chromedriver-linux64/chromedriver /usr/local/bin/ \
&& chmod +x /usr/local/bin/chromedriver \
&& rm -rf chromedriver-linux64.zip chromedriver-linux64
# Create necessary directories and set permissions
RUN mkdir -p /app/static/screenshots /app/static/uploads /app/static/masks /app/templates \
&& useradd -m -u 1000 user \
&& chown -R user:user /app
USER user
# Install Python dependencies
COPY --chown=user requirements.txt requirements.txt
RUN pip install --user -r requirements.txt
# Copy application files
COPY --chown=user . .
# Set environment variables
ENV PATH="/home/user/.local/bin:${PATH}"
ENV PYTHONPATH="/home/user/.local/lib/python3.9/site-packages:${PYTHONPATH}"
ENV CHROME_BINARY_LOCATION="/usr/bin/google-chrome"
ENV PORT=7860
# Run the application
CMD ["python", "main.py"]