-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.prod
More file actions
69 lines (56 loc) · 1.6 KB
/
Copy pathDockerfile.prod
File metadata and controls
69 lines (56 loc) · 1.6 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
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
FROM python:slim
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gdal-bin \
libgdal-dev \
python3-dev \
gcc \
build-essential \
libpq-dev \
libgeos-dev \
proj-bin \
proj-data \
libproj-dev \
libxml2-dev \
libxslt-dev \
libffi-dev \
zlib1g-dev \
libjpeg-dev \
tzdata \
gettext \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Set timezone
ENV TZ=Europe/Vienna
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONPATH=/usr/src/app
ENV DJANGO_SETTINGS_MODULE=isrfield.settings
# Create non-root user
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Set work directory
WORKDIR /usr/src/app
# Install Python dependencies
COPY ./requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy project files
COPY ./app/ .
# Copy and set up entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Create necessary directories and set ownership
RUN mkdir -p /usr/src/app/media /usr/src/app/staticfiles && \
chown -R appuser:appuser /usr/src/app
# Set entrypoint (will run as root, then switch to appuser)
ENTRYPOINT ["/entrypoint.sh"]
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health/ || exit 1
# Start Django
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]