Lightweight image based on Alpine Linux (v3.21), Nginx server v1.26.3-r0 and PHP 8.3 FPM
1.3K
A lightweight, secure, and dynamic container image based on Alpine 3.21, featuring:
| Parameter | Value |
|---|---|
| Base Image | alpine:3.21 |
| Nginx Version | Configurable via ARG |
| PHP Version | PHP 8.3 + extensions |
| Variable | Description | Default |
|---|---|---|
TIMEZONE | System timezone (linked to /etc/localtime) | UTC |
PHP_MEMORY_LIMIT | PHP memory limit applied via FPM and php.ini | 512M |
NGINX_WORKER_PROCESSES | Controls Nginx concurrency | 1 |
REDIRECT_TO_HTTPS | Enables HTTP to HTTPS redirection | no |
AUTOCERT | Auto-generate self-signed SSL if none is found | no |
CERT_WARN_DAYS | Triggers a warning log if cert expires in < N days | 30 |
config/
๐ฝ๏ธ www/ # Web content (index.php, etc.)
๐ฝ๏ธ ssl/ # SSL certs: fullchain.pem, privkey.pem
๐ฝ๏ธ data/ # Optional: databases, uploads
๐ฝ๏ธ warnings/ # Auto-generated logs (e.g., cert-warn.log)
Checks:
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -s -L -o /dev/null -w "%{http_code}" http://localhost | grep -qE "200|403|404"
docker run -d --name my-nginx \
-e TIMEZONE=America/New_York \
-e PHP_MEMORY_LIMIT=512M \
-e REDIRECT_TO_HTTPS=yes \
-e AUTOCERT=yes \
-p 8080:80 -p 8443:443 \
-v $(pwd)/config:/config \
humbertovarona/nginx
Access:
http://localhost:8080https://localhost:8443 (self-signed certificate)version: '3.8'
services:
web:
image: humbertovarona/nginx
container_name: my-nginx
ports:
- "8080:80"
- "8443:443"
environment:
TIMEZONE: America/New_York
PHP_MEMORY_LIMIT: 512M
REDIRECT_TO_HTTPS: yes
AUTOCERT: yes
CERT_WARN_DAYS: 30
volumes:
- ./config:/config
healthcheck:
test: ["CMD-SHELL", "curl -s -L -o /dev/null -w '%{http_code}' http://localhost | grep -qE '200|403|404'"]
interval: 30s
timeout: 5s
retries: 3
MIT โ Use it freely, fork it proudly.
Pull requests, ideas, and bug reports are welcome ๐
HL Varona โ @[email protected]โ
Content type
Image
Digest
sha256:95c640970โฆ
Size
44.4 MB
Last updated
over 1 year ago
docker pull humbertovarona/nginx