Skip to content

Commit ca9d996

Browse files
committed
fix debian supervisor
1 parent 24e5b23 commit ca9d996

File tree

8 files changed

+260
-34
lines changed

8 files changed

+260
-34
lines changed

8.4-debian-nginx-prod/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
2929
NGINX_FASTCGI_BUFFER_SIZE='16k' \
3030
NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true
3131

32-
RUN SUPERVISORD_ARCH="$( [ "$(uname -m)" = "aarch64" ] && echo arm64 || echo amd64 )" \
33-
&& curl -L "https://github.com/ochinchina/supervisord/releases/download/v0.6.3/supervisord_static_0.6.3_linux_${SUPERVISORD_ARCH}" -o /usr/local/bin/supervisord \
34-
&& chmod +x /usr/local/bin/supervisord \
35-
&& apt-get update && apt-get install -y --no-install-recommends nginx wget \
32+
RUN apt-get update && apt-get install -y --no-install-recommends supervisor nginx wget \
3633
&& chown -R kool:kool /var/lib/nginx \
3734
&& chmod 770 /var/lib/nginx \
3835
&& ln -sf /dev/stdout /var/log/nginx/access.log \
Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
[program:nginx]
2-
depends_on = php-fpm
3-
command = nginx -g "daemon off;"
4-
stopasgroup = true
5-
stderr_logfile = /dev/stderr
6-
stdout_logfile = /dev/stdout
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
logfile=/dev/null
5+
logfile_maxbytes=0
6+
pidfile=/run/supervisord.pid
77

88
[program:php-fpm]
9-
command = php-fpm
10-
stopasgroup = true
11-
stderr_logfile = /dev/stderr
12-
stdout_logfile = /dev/stdout
9+
command=php-fpm
10+
priority=10
11+
autostart=true
12+
autorestart=true
13+
stopasgroup=true
14+
killasgroup=true
15+
stdout_logfile=/dev/stdout
16+
stdout_logfile_maxbytes=0
17+
stderr_logfile=/dev/stderr
18+
stderr_logfile_maxbytes=0
19+
20+
[program:nginx]
21+
command=nginx -g "daemon off;"
22+
priority=20
23+
autostart=true
24+
autorestart=true
25+
stopasgroup=true
26+
killasgroup=true
27+
stdout_logfile=/dev/stdout
28+
stdout_logfile_maxbytes=0
29+
stderr_logfile=/dev/stderr
30+
stderr_logfile_maxbytes=0

8.4-debian-nginx/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
2929
NGINX_FASTCGI_BUFFER_SIZE='16k' \
3030
NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true
3131

32-
RUN SUPERVISORD_ARCH="$( [ "$(uname -m)" = "aarch64" ] && echo arm64 || echo amd64 )" \
33-
&& curl -L "https://github.com/ochinchina/supervisord/releases/download/v0.6.3/supervisord_static_0.6.3_linux_${SUPERVISORD_ARCH}" -o /usr/local/bin/supervisord \
34-
&& chmod +x /usr/local/bin/supervisord \
35-
&& apt-get update && apt-get install -y --no-install-recommends nginx wget \
32+
RUN apt-get update && apt-get install -y --no-install-recommends supervisor nginx wget \
3633
&& chown -R kool:kool /var/lib/nginx \
3734
&& chmod 770 /var/lib/nginx \
3835
&& ln -sf /dev/stdout /var/log/nginx/access.log \

8.4-debian-nginx/supervisor.conf

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
[program:nginx]
2-
depends_on = php-fpm
3-
command = nginx -g "daemon off;"
4-
stopasgroup = true
5-
stderr_logfile = /dev/stderr
6-
stdout_logfile = /dev/stdout
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
logfile=/dev/null
5+
logfile_maxbytes=0
6+
pidfile=/run/supervisord.pid
77

88
[program:php-fpm]
9-
command = php-fpm
10-
stopasgroup = true
11-
stderr_logfile = /dev/stderr
12-
stdout_logfile = /dev/stdout
9+
command=php-fpm
10+
priority=10
11+
autostart=true
12+
autorestart=true
13+
stopasgroup=true
14+
killasgroup=true
15+
stdout_logfile=/dev/stdout
16+
stdout_logfile_maxbytes=0
17+
stderr_logfile=/dev/stderr
18+
stderr_logfile_maxbytes=0
19+
20+
[program:nginx]
21+
command=nginx -g "daemon off;"
22+
priority=20
23+
autostart=true
24+
autorestart=true
25+
stopasgroup=true
26+
killasgroup=true
27+
stdout_logfile=/dev/stdout
28+
stdout_logfile_maxbytes=0
29+
stderr_logfile=/dev/stderr
30+
stderr_logfile_maxbytes=0

from-alpine-to-debian.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# From Alpine to Debian: Migration Guide
2+
3+
This document outlines the key differences between the Alpine and Debian variants of the kooldev/php Docker images.
4+
5+
## Quick Comparison
6+
7+
| Feature | Alpine | Debian |
8+
|---------|--------|--------|
9+
| Base Image | `php:8.x-fpm-alpine` | `php:8.x-fpm` (Debian) |
10+
| Image Size | Smaller (~150MB) | Larger (~400MB) |
11+
| Package Manager | `apk` | `apt-get` |
12+
| Shell | `sh` (BusyBox) | `bash` |
13+
| Privilege Drop | `su-exec` | `gosu` |
14+
| Supervisord | ochinchina/supervisord (Go static binary) | Official supervisor package (Python) |
15+
| Architecture | amd64 only (nginx variants) | amd64 + arm64 |
16+
| glibc | musl libc | glibc |
17+
18+
## When to Use Debian
19+
20+
Choose the Debian variant when:
21+
22+
- **ARM64/Apple Silicon support is needed** - The Debian variant has native multi-arch support
23+
- **Compatibility issues with Alpine** - Some PHP extensions or native libraries may have issues with musl libc
24+
- **Debugging needs** - Debian includes more debugging tools out of the box
25+
- **Familiarity** - Teams more familiar with Debian/Ubuntu environments
26+
27+
## When to Use Alpine
28+
29+
Choose the Alpine variant when:
30+
31+
- **Minimal image size is critical** - Alpine images are significantly smaller
32+
- **Security through minimalism** - Smaller attack surface with fewer packages
33+
- **amd64-only deployments** - No need for ARM64 support
34+
35+
## Key Differences in Detail
36+
37+
### 1. Supervisord Implementation
38+
39+
**Alpine** uses [ochinchina/supervisord](https://github.com/ochinchina/supervisord), a Go-based reimplementation:
40+
41+
```ini
42+
# Alpine supervisor.conf
43+
[program:nginx]
44+
depends_on = php-fpm
45+
command = nginx -g "daemon off;"
46+
stopasgroup = true
47+
stderr_logfile = /dev/stderr
48+
stdout_logfile = /dev/stdout
49+
50+
[program:php-fpm]
51+
command = php-fpm
52+
stopasgroup = true
53+
stderr_logfile = /dev/stderr
54+
stdout_logfile = /dev/stdout
55+
```
56+
57+
**Debian** uses the official Python-based supervisord package:
58+
59+
```ini
60+
# Debian supervisor.conf
61+
[supervisord]
62+
nodaemon=true
63+
user=root
64+
logfile=/dev/null
65+
logfile_maxbytes=0
66+
pidfile=/run/supervisord.pid
67+
68+
[program:php-fpm]
69+
command=php-fpm
70+
priority=10
71+
autostart=true
72+
autorestart=true
73+
stopasgroup=true
74+
killasgroup=true
75+
stdout_logfile=/dev/stdout
76+
stdout_logfile_maxbytes=0
77+
stderr_logfile=/dev/stderr
78+
stderr_logfile_maxbytes=0
79+
80+
[program:nginx]
81+
command=nginx -g "daemon off;"
82+
priority=20
83+
autostart=true
84+
autorestart=true
85+
stopasgroup=true
86+
killasgroup=true
87+
stdout_logfile=/dev/stdout
88+
stdout_logfile_maxbytes=0
89+
stderr_logfile=/dev/stderr
90+
stderr_logfile_maxbytes=0
91+
```
92+
93+
**Key differences:**
94+
- Alpine uses `depends_on` for process ordering
95+
- Debian uses `priority` (lower number starts first)
96+
- Debian requires a `[supervisord]` section with `nodaemon=true`
97+
- Debian needs `stdout_logfile_maxbytes=0` to disable log rotation for stdout/stderr
98+
99+
### 2. Entrypoint Script
100+
101+
**Alpine** uses `sh` shell with `su-exec`:
102+
103+
```bash
104+
#!/bin/sh
105+
# ...
106+
exec su-exec kool "$@"
107+
```
108+
109+
**Debian** uses `bash` with `gosu`:
110+
111+
```bash
112+
#!/bin/bash
113+
# ...
114+
exec gosu kool "$@"
115+
```
116+
117+
### 3. Package Installation
118+
119+
**Alpine:**
120+
```dockerfile
121+
RUN apk add --no-cache nginx \
122+
&& apk add --no-cache --virtual .build-deps ... \
123+
&& apk del .build-deps
124+
```
125+
126+
**Debian:**
127+
```dockerfile
128+
RUN apt-get update \
129+
&& apt-get install -y --no-install-recommends nginx \
130+
&& rm -rf /var/lib/apt/lists/*
131+
```
132+
133+
### 4. nginx Directory Structure
134+
135+
**Alpine:**
136+
```dockerfile
137+
chmod 770 /var/lib/nginx/tmp
138+
```
139+
140+
**Debian:**
141+
```dockerfile
142+
chmod 770 /var/lib/nginx
143+
```
144+
145+
## Migration Steps
146+
147+
To migrate from Alpine to Debian:
148+
149+
1. **Update your image tag:**
150+
```yaml
151+
# docker-compose.yml
152+
# From:
153+
image: kooldev/php:8.4-nginx
154+
# To:
155+
image: kooldev/php:8.4-debian-nginx
156+
```
157+
158+
2. **Custom supervisor configs:** If you've customized the supervisor configuration, update to use `priority` instead of `depends_on`
159+
160+
3. **Shell scripts:** Update any scripts that rely on Alpine-specific paths or BusyBox commands
161+
162+
4. **Test thoroughly:** The glibc vs musl difference can cause subtle behavior changes in some applications
163+
164+
## Available Debian Image Tags
165+
166+
- `kooldev/php:8.4-debian` - Base FPM image
167+
- `kooldev/php:8.4-debian-prod` - Production FPM image (no dev tools)
168+
- `kooldev/php:8.4-debian-nginx` - FPM + Nginx with supervisord
169+
- `kooldev/php:8.4-debian-nginx-prod` - Production FPM + Nginx

fwd-template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@
562562
},
563563
{
564564
"name": "supervisor.conf",
565-
"path": "template/supervisor-conf"
565+
"path": "template/supervisor-conf-debian"
566566
}
567567
]
568568
},
@@ -589,7 +589,7 @@
589589
},
590590
{
591591
"name": "supervisor.conf",
592-
"path": "template/supervisor-conf"
592+
"path": "template/supervisor-conf-debian"
593593
}
594594
]
595595
}

template/Dockerfile-debian-nginx.blade.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
NGINX_FASTCGI_BUFFER_SIZE='16k' \
3030
NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true
3131

32-
RUN SUPERVISORD_ARCH="$( [ "$(uname -m)" = "aarch64" ] && echo arm64 || echo amd64 )" \
33-
&& curl -L "https://github.com/ochinchina/supervisord/releases/download/v0.6.3/supervisord_static_0.6.3_linux_${SUPERVISORD_ARCH}" -o /usr/local/bin/supervisord \
34-
&& chmod +x /usr/local/bin/supervisord \
35-
&& apt-get update && apt-get install -y --no-install-recommends nginx wget \
32+
RUN apt-get update && apt-get install -y --no-install-recommends supervisor nginx wget \
3633
&& chown -R kool:kool /var/lib/nginx \
3734
&& chmod 770 /var/lib/nginx \
3835
&& ln -sf /dev/stdout /var/log/nginx/access.log \
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
logfile=/dev/null
5+
logfile_maxbytes=0
6+
pidfile=/run/supervisord.pid
7+
8+
[program:php-fpm]
9+
command=php-fpm
10+
priority=10
11+
autostart=true
12+
autorestart=true
13+
stopasgroup=true
14+
killasgroup=true
15+
stdout_logfile=/dev/stdout
16+
stdout_logfile_maxbytes=0
17+
stderr_logfile=/dev/stderr
18+
stderr_logfile_maxbytes=0
19+
20+
[program:nginx]
21+
command=nginx -g "daemon off;"
22+
priority=20
23+
autostart=true
24+
autorestart=true
25+
stopasgroup=true
26+
killasgroup=true
27+
stdout_logfile=/dev/stdout
28+
stdout_logfile_maxbytes=0
29+
stderr_logfile=/dev/stderr
30+
stderr_logfile_maxbytes=0

0 commit comments

Comments
 (0)