-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (50 loc) · 2.22 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (50 loc) · 2.22 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
# ============================================
# Dockerfile: PHP Backend (CodeIgniter 4)
# Deploy on Railway
# ============================================
FROM php:8.2-apache AS base
# ---- System Dependencies ----
RUN apt-get update && apt-get install -y \
libpq-dev \
libicu-dev \
libcurl4-openssl-dev \
libzip-dev \
unzip \
git \
&& rm -rf /var/lib/apt/lists/*
# ---- PHP Extensions ----
RUN docker-php-ext-install pdo pgsql pdo_pgsql curl zip intl
# ---- Apache Config ----
# MPM fix happens at runtime in docker-entrypoint.sh
RUN a2enmod rewrite headers
# Raise PHP limits to allow 100MB+ PDF uploads natively
RUN echo "upload_max_filesize = 100M\npost_max_size = 100M\nmemory_limit = 512M\nmax_execution_time = 300\nmax_input_time = 300" > /usr/local/etc/php/conf.d/uploads.ini
# Set document root to CodeIgniter's public folder
ENV APACHE_DOCUMENT_ROOT=/var/www/html/backend/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \
/etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \
/etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Allow .htaccess overrides
RUN sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
# Listen on PORT env variable (Railway sets this) - substituted at runtime
# Remove default port config, will be set at container start
RUN echo "" > /etc/apache2/ports.conf
# ---- Install Composer ----
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# ---- Copy PHP Backend ----
WORKDIR /var/www/html/backend
COPY backend/composer.json backend/composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-interaction --ignore-platform-reqs
COPY backend/ .
# Make writable directory writable
RUN mkdir -p writable/cache writable/logs writable/session writable/uploads writable/debugbar \
&& chmod -R 777 writable
# ---- Entrypoint script ----
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# ---- Environment defaults ----
ENV CI_ENVIRONMENT=production
# Expose port and start Apache via entrypoint
EXPOSE ${PORT:-8080}
CMD ["/usr/local/bin/docker-entrypoint.sh"]