-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathContainerfile
More file actions
45 lines (35 loc) · 1.11 KB
/
Containerfile
File metadata and controls
45 lines (35 loc) · 1.11 KB
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
FROM ubuntu:24.04
# Install Python & GeoDjango dependencies
RUN apt update && \
apt install -y \
libpq-dev \
libproj-dev \
gdal-bin \
python3 \
python3-pip \
python3-venv && \
apt clean
# Create a virtual environment
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PYTHONUNBUFFERED=1
# Install Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
# Copy the application code to the container
COPY src /app
COPY pytest.ini /app/pytest.ini
WORKDIR /app
# Run collectstatic to gather static files
# We pass dummy values for REDIS_URL and SECRET_KEY to ensure settings.py loads without error
RUN REDIS_URL="redis://dummy:6379/0" \
SECRET_KEY="dummy" \
ALLOWED_HOSTS="*" \
python3 manage.py collectstatic --noinput
# Copy gunicorn config
COPY gunicorn.conf.py /app/gunicorn.conf.py
# Expose the port the app runs on
EXPOSE 8000
# Default command
CMD ["sh", "-c", "gunicorn project.wsgi --pythonpath src --workers 3 --config gunicorn.conf.py --bind 0.0.0.0:${PORT:-8000}"]