BridgeMentor / Dockerfile
SushantGautam's picture
Fix Dockerfile working directory and permissions setup to ensure proper access to application files
82abdb6
# Use official Python image
FROM python:3.11-slim
# Set environment variables early to reduce duplication
ENV INSIDEDOCKER=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
default-libmysqlclient-dev \
build-essential \
pkg-config \
openssh-client \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Install Python dependencies (cached if requirements.txt doesn't change)
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt
# Copy project files (done after installing dependencies to utilize cache)
COPY . .
# Set permissions (do this *after* copying files)
RUN chmod -R 777 /app
# Setup SSH known_hosts (only runs if above layers change)
RUN mkdir -p /root/.ssh && \
ssh-keyscan -H 192.250.235.27 >> /root/.ssh/known_hosts
# Output IP address for debugging
RUN echo "----------------------------------------" && \
echo "🌍 Public IP of Docker host (from inside container):" && \
curl -s ifconfig.me && \
echo "\n----------------------------------------"
# Default CMD (use Gunicorn in production)
CMD ["/bin/bash", "-c", "python manage.py collectstatic --noinput && gunicorn BridgeMentor.wsgi:application --bind 0.0.0.0:7860 --timeout 30 --workers 2"]
# CMD ["python", "manage.py", "runserver", "7860", "--verbosity", "2", "--noreload"]