diff --git a/.gitignore b/.gitignore index e69de29..84754c5 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,8 @@ +.env +.git +.gitignore +**/.DS_Store +**/node_modules +**/vendor +tmp +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f93f7a9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +FROM alpine:3.22 + +RUN set -eux; \ + apk add --no-cache \ + apache2 apache2-proxy \ + php84 php84-fpm php84-opcache php84-session \ + php84-mysqli php84-pdo php84-pdo_mysql php84-ctype php84-tokenizer php84-xml php84-gd php84-curl php84-mbstring \ + tzdata curl; \ + mkdir -p /run/apache2 /run/php /var/www/html; \ + # Apache → logy do stdout/stderr, ServerName + sed -ri 's|^[#[:space:]]*ErrorLog .*|ErrorLog /dev/stderr|g' /etc/apache2/httpd.conf; \ + sed -ri 's|^[#[:space:]]*CustomLog .*|CustomLog /dev/stdout combined|g' /etc/apache2/httpd.conf; \ + sed -ri 's|#ServerName www.example.com:80|ServerName localhost|g' /etc/apache2/httpd.conf; \ + # PHP-FPM: TCP 127.0.0.1:9000 + sed -ri 's|^listen = .*|listen = 127.0.0.1:9000|g' /etc/php84/php-fpm.d/www.conf; \ + # Production ini (pokud je k dispozici) + if [ -f /etc/php84/php.ini-production ]; then cp /etc/php84/php.ini-production /etc/php84/php.ini; fi; \ + # Alpine default symlink + if [ -d /var/www/localhost/htdocs ]; then rmdir /var/www/localhost/htdocs || true; ln -s /var/www/html /var/www/localhost/htdocs; fi +RUN sed -ri 's|^(LoadModule\s+lbmethod_heartbeat_module\b.*)|# \1|' /etc/apache2/httpd.conf +# Konfigurace Apache pro FPM + DocumentRoot +COPY apache-phpfpm.conf /etc/apache2/conf.d/php-fpm.conf + +# Aplikace +COPY data/www/ /var/www/html/ + +# Jednoduchý healthcheck +HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1 + +LABEL org.opencontainers.image.title="docker-php-alpine" \ + org.opencontainers.image.description="Apache + PHP 8.4 on Alpine (FPM)" \ + org.opencontainers.image.source="https://git.najihu.net/zdenek/docker-php-alpine" \ + org.opencontainers.image.licenses="MIT" + +# Entrypoint spustí FPM a Apache (root → Apache si sám shodí práva) +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh + +EXPOSE 80 +CMD ["/docker-entrypoint.sh"] + diff --git a/apache-phpfpm.conf b/apache-phpfpm.conf new file mode 100644 index 0000000..5c9b4c6 --- /dev/null +++ b/apache-phpfpm.conf @@ -0,0 +1,14 @@ +# JASNĚ definovaný kořen +DocumentRoot "/var/www/html" + + + AllowOverride All + Require all granted + + +# PHP má přednost +DirectoryIndex index.php index.html + +# Předáme FPMu plnou cestu k .php +ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000/var/www/html/$1" + diff --git a/data/www/index.php b/data/www/index.php new file mode 100644 index 0000000..cf60860 --- /dev/null +++ b/data/www/index.php @@ -0,0 +1,3 @@ + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8625952 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + web: + image: git.najihu.net/zdenek/docker-php-alpine:latest + ports: ["8080:80"] + + # volumes: + # - ./data/www:/var/www/html + restart: unless-stopped + diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..3763975 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# NEměním vlastníky – respektuju bind-mounty/práva z hosta + +# PHP-FPM do pozadí (foreground režim) +php-fpm84 -F & + +# Apache jako root (zapíše PID, pak shodí práva podle httpd.conf) +exec /usr/sbin/httpd -D FOREGROUND +