-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (67 loc) · 2.45 KB
/
Copy pathDockerfile
File metadata and controls
88 lines (67 loc) · 2.45 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# ===============================
# Stage 1: Build Python part
# ===============================
FROM python:3.12-slim AS builder
WORKDIR /build
# Install system build dependencies (required for ARM & C-extension packages)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
libffi-dev \
libssl-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip & install Poetry
RUN pip install --upgrade pip setuptools wheel && pip install poetry
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-root
COPY . .
RUN poetry run python3 main.py --env prod
# ===============================
# Stage 2: Apache + PHP runtime
# ===============================
FROM php:8.4-apache
# Install cron and cleanup
RUN apt-get update && apt-get install -y --no-install-recommends cron \
&& rm -rf /var/lib/apt/lists/*
# Enable Apache rewrite module
RUN a2enmod rewrite
# Suppress Apache ServerName warning globally
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Create app directories
RUN mkdir -p /var/www/crondns/data /var/www/crondns/lib /var/www/crondns/public /var/www/crondns/templates \
/var/lib/php/sessions
WORKDIR /var/www/crondns
# Copy built Python artifacts
COPY --from=builder /build/dist/ /var/www/crondns/
# Configure Apache site
COPY apache-crondns.conf /etc/apache2/sites-available/crondns.conf
RUN a2dissite 000-default.conf && a2ensite crondns.conf
# Permissions
RUN chown -R www-data:www-data /var/www/crondns /var/lib/php/sessions \
&& chmod -R 775 /var/www/crondns
# Add cron job — files in /etc/cron.d/ are auto-loaded by the cron daemon
COPY crondns.cron /etc/cron.d/crondns
RUN chmod 0644 /etc/cron.d/crondns
# ===============================
# PHP Custom Configuration
# ===============================
RUN { \
echo "display_errors=On"; \
echo "display_startup_errors=On"; \
echo "error_reporting=32767"; \
echo "output_buffering=4096"; \
echo "session.save_path=/var/lib/php/sessions"; \
echo "zlib.output_compression=Off"; \
} > /usr/local/etc/php/conf.d/custom.ini
RUN { \
echo "opcache.enable=1"; \
echo "opcache.memory_consumption=128"; \
echo "opcache.revalidate_freq=2"; \
echo "opcache.validate_timestamps=On"; \
} > /usr/local/etc/php/conf.d/opcache.ini
EXPOSE 80
# Entrypoint
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]