Skip to content

Commit b433f2c

Browse files
sophia0328qzheng527
authored and
qzheng527
committed
add php-fpm container
Signed-off-by: Gong Sophia <[email protected]>
1 parent 7ba80fe commit b433f2c

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ env:
2626
- DOCKERFILE_DIR=rabbitmq
2727
- DOCKERFILE_DIR=perl
2828
- DOCKERFILE_DIR=php
29+
- DOCKERFILE_DIR=php-fpm
2930
- DOCKERFILE_DIR=postgres
3031
- DOCKERFILE_DIR=python
3132
- DOCKERFILE_DIR=redis

php-fpm/Dockerfile

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM clearlinux:latest AS builder
2+
3+
4+
ARG swupd_args
5+
# Move to latest Clear Linux release to ensure
6+
# that the swupd command line arguments are
7+
# correct
8+
RUN swupd update --no-boot-update $swupd_args
9+
10+
# Grab os-release info from the minimal base image so
11+
# that the new content matches the exact OS version
12+
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
13+
14+
# Install additional content in a target directory
15+
# using the os version from the minimal base
16+
RUN source /os-release && \
17+
mkdir /install_root \
18+
&& swupd os-install -V ${VERSION_ID} \
19+
--path /install_root --statedir /swupd-state \
20+
--bundles=os-core-update,php-basic --no-scripts
21+
22+
# For some Host OS configuration with redirect_dir on,
23+
# extra data are saved on the upper layer when the same
24+
# file exists on different layers. To minimize docker
25+
# image size, remove the overlapped files before copy.
26+
RUN mkdir /os_core_install
27+
COPY --from=clearlinux/os-core:latest / /os_core_install/
28+
RUN cd / && \
29+
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d || true
30+
31+
32+
FROM clearlinux/os-core:latest
33+
34+
COPY --from=builder /install_root /
35+
36+
RUN set -ex \
37+
mkdir -p /var/www/html \
38+
&& cd /usr/share/defaults/php \
39+
&& { \
40+
echo '[global]'; \
41+
echo 'error_log = /proc/self/fd/2'; \
42+
echo; echo '; https://github.com/docker-library/php/pull/725#issuecomment-443540114'; echo 'log_limit = 8192'; \
43+
echo; \
44+
echo '[www]'; \
45+
echo '; if we send this to /proc/self/fd/1, it never appears'; \
46+
echo 'access.log = /proc/self/fd/2'; \
47+
echo; \
48+
echo 'clear_env = no'; \
49+
echo; \
50+
echo '; Ensure worker stdout and stderr are sent to the main error log.'; \
51+
echo 'catch_workers_output = yes'; \
52+
echo 'decorate_workers_output = no'; \
53+
} | tee php-fpm.d/docker.conf \
54+
&& { \
55+
echo '[global]'; \
56+
echo 'daemonize = no'; \
57+
echo; \
58+
echo '[www]'; \
59+
echo 'listen = 9000'; \
60+
} | tee php-fpm.d/zz-docker.conf
61+
62+
WORKDIR /var/www/html
63+
64+
COPY docker-php-entrypoint /usr/local/bin/
65+
RUN chmod +x /usr/local/bin/docker-php-entrypoint
66+
ENTRYPOINT ["docker-php-entrypoint"]
67+
68+
STOPSIGNAL SIGQUIT
69+
70+
EXPOSE 9000
71+
CMD ["php-fpm"]

php-fpm/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
php-fpm
2+
==========
3+
This provides a Clear Linux* php-fpm instance.
4+
5+
Build
6+
-----
7+
```
8+
docker build -t clearlinux/php-fpm .
9+
```
10+
11+
Or just pull it from Dockerhub
12+
---------------------------
13+
```
14+
docker pull clearlinux/php-fpm
15+
```
16+
17+
start a php-fpm instance
18+
-----------------------
19+
```
20+
docker run --name some-php-fpm clearlinux/php-fpm
21+
```
22+
23+
Test
24+
-----------------------
25+
```
26+
docker exec -it some-php-fpm bash
27+
php-fpm -t
28+
```
29+
30+
More typical, php-fpm works with nginx, mariadb, for example in wordpress use case. For details, please refer to clearlinux wordpress micro service.
31+
32+
33+
Extra Build ARGs
34+
----------------
35+
- ``swupd_args`` Specifies [SWUPD](https://github.com/clearlinux/swupd-client/blob/master/docs/swupd.1.rst#options) flags
36+
37+
Default build args in Docker are on: https://docs.docker.com/engine/reference/builder/#arg

php-fpm/docker-php-entrypoint

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# first arg is `-f` or `--some-option`
5+
if [ "${1#-}" != "$1" ]; then
6+
set -- php-fpm "$@"
7+
fi
8+
9+
exec "$@"

0 commit comments

Comments
 (0)