File size: 1,436 Bytes
cb43f68
 
 
71d0025
 
 
 
 
f82cb1a
 
 
 
 
71d0025
 
f82cb1a
 
71d0025
82abdb6
066b72c
2af4768
cb43f68
 
0ff05c8
2af4768
71d0025
1e4386d
2af4768
82abdb6
2af4768
 
1e4386d
 
 
71d0025
dc4cd08
 
 
 
 
71d0025
c0e1751
a2f5c4f
 
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
# 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"]