Skip to content

Commit 7f38b21

Browse files
authored
Merge pull request #5 from Tinywan/feature/s6-overlay
Feature/s6 overlay
2 parents 92e0e1a + 71690cd commit 7f38b21

4 files changed

Lines changed: 39 additions & 10 deletions

File tree

Dockerfile

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
FROM php:8.3.30-cli-alpine
1+
FROM php:8.4.17-cli-alpine
2+
ARG S6_OVERLAY_VERSION=3.2.1.0
23

34
LABEL Maintainer="ShaoBo Wan (Tinywan) <756684177@qq.com>" \
4-
Description="Webman Lightweight container with PHP 8.4.16 based on Alpine Linux."
5+
Description="Webman Lightweight container with PHP 8.4.16 based on Alpine Linux with S6 Overlay."
56

67
# Use Alibaba Cloud mirror for faster downloads
78
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories
89

910
# Install runtime dependencies only (build deps will be installed and removed later)
10-
RUN apk add --no-cache curl ca-certificates tzdata supervisor
11+
RUN apk add --no-cache curl ca-certificates tzdata
1112

1213
COPY ./extension /tmp/extension
1314
WORKDIR /tmp/extension
@@ -24,22 +25,35 @@ RUN apk add --no-cache --virtual .build-deps \
2425
&& rm -rf /var/cache/apk /tmp/* /root/.pearrc /usr/local/include/php \
2526
&& mkdir -p /var/cache/apk
2627

27-
# Add Composer (with cache cleanup)
28+
# Add Composer (with cache cleanup, no plugins/scripts)
2829
RUN curl -sS https://getcomposer.org/installer | php \
2930
&& mv composer.phar /usr/local/bin/composer \
30-
&& rm -rf /root/.composer/cache
31+
&& composer --version \
32+
&& rm -rf /root/.composer/cache /tmp/*
3133

3234
# Configure PHP
3335
COPY config/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini
3436

35-
# Configure supervisord
36-
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
37-
3837
# Setup document root
3938
RUN mkdir -p /app
4039

40+
# Add entrypoint script for auto composer install
41+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
42+
RUN chmod +x /usr/local/bin/entrypoint.sh
43+
44+
# Install S6 Overlay v3 (download, extract, cleanup in one layer)
45+
RUN apk add --no-cache curl \
46+
&& curl -fsSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz -o /tmp/s6-overlay-noarch.tar.xz \
47+
&& tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \
48+
&& curl -fsSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz -o /tmp/s6-overlay-x86_64.tar.xz \
49+
&& tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz \
50+
&& rm -f /tmp/s6-overlay-*.tar.xz \
51+
&& apk del curl
52+
53+
# Use S6 Overlay as init system with environment to override services
4154
VOLUME /app
4255
WORKDIR /app
4356
EXPOSE 8787
4457

45-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
58+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
59+
CMD ["php", "start.php","start"]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Build
77

88
```
9-
docker build -t tinywan/docker-php-webman:8.4.16 .
9+
docker build -t tinywan/docker-php-webman:8.4.15-cli-alpine .
1010
```
1111
## Usage
1212

@@ -22,6 +22,7 @@ docker run --rm -it -p 8787:8787 -v /home/www/webman:/app tinywan/docker-php-web
2222

2323
```
2424
docker run --rm -it -p 8787:8787 -v e:/dnmp/www/webman:/app tinywan/docker-php-webman
25+
docker run --rm -it -p 8780:8787 -v e:/dnmp/www/webman/video.webman.tinywan.com:/app tinywan/docker-php-webman:8.4.15-cli-alpine
2526
```
2627

2728
Test Run

entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
set -e
3+
4+
cd /app
5+
6+
# Auto install dependencies if vendor/autoload.php not exists
7+
if [ ! -f vendor/autoload.php ]; then
8+
echo "Composer dependencies not found, installing..."
9+
composer install --no-interaction --no-scripts --no-plugins
10+
fi
11+
12+
# Execute s6-overlay init then the command
13+
exec /init "$@"

extension/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,4 +682,5 @@ fi
682682

683683
# Cleanup build artifacts and caches
684684
echo "---------- Cleanup ----------"
685+
rm -rf /tmp/* /var/cache/apk/* /root/.pearrc /usr/local/include/php /root/.cache/pecl
685686
docker-php-source delete

0 commit comments

Comments
 (0)