Skip to content

Commit 3f1cc3c

Browse files
committed
Fix #48
1 parent 6e4f42e commit 3f1cc3c

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

Dockerfile

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,31 @@ COPY --from=builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions
1818
COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
1919
COPY --from=builder /app /var/www/html
2020

21-
# NGINX configuration is here intentionally
22-
RUN apk add --no-cache nginx \
23-
&& mkdir -p /var/www/html/tmp \
24-
&& chown -R nobody:nobody /var/www/html \
25-
&& chmod -R 777 /var/www/html \
26-
&& mkdir -p /run/nginx \
27-
&& echo 'server { \
28-
listen 80; \
29-
root /var/www/html; \
30-
index index.php; \
31-
location / { \
32-
try_files $uri $uri/ /index.php?$query_string; \
33-
} \
34-
location ~ \.php$ { \
35-
fastcgi_pass 127.0.0.1:9000; \
36-
fastcgi_index index.php; \
37-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; \
38-
include fastcgi_params; \
39-
} \
40-
}' > /etc/nginx/http.d/default.conf
41-
42-
EXPOSE 80
43-
44-
CMD php-fpm -D && nginx -g 'daemon off;'
21+
RUN apk add --no-cache nginx gettext \
22+
&& mkdir -p /var/www/html/tmp /run/nginx /var/cache/nginx /var/log/nginx \
23+
&& chmod -R 777 /var/www/html /run/nginx /var/cache/nginx /var/log/nginx \
24+
&& sed -i 's|^listen = .*|listen = 127.0.0.1:9000|' /usr/local/etc/php-fpm.d/www.conf
25+
26+
ENV PCA_NGINX_PORT=8080
27+
28+
# NGINX config template
29+
RUN printf 'server {\n\
30+
listen ${PCA_NGINX_PORT};\n\
31+
root /var/www/html;\n\
32+
index index.php;\n\
33+
location / {\n\
34+
try_files $uri $uri/ /index.php$is_args$args;\n\
35+
}\n\
36+
location ~ \\.php$ {\n\
37+
fastcgi_pass 127.0.0.1:9000;\n\
38+
fastcgi_index index.php;\n\
39+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n\
40+
include fastcgi_params;\n\
41+
}\n\
42+
}\n' > /etc/nginx/http.d/default.conf.template
43+
44+
EXPOSE 8080
45+
46+
CMD envsubst '${PCA_NGINX_PORT}' < /etc/nginx/http.d/default.conf.template > /etc/nginx/http.d/default.conf \
47+
&& php-fpm -D \
48+
&& nginx -g 'daemon off;'

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ Memcached:
8484
- `PCA_MEMCACHED_0_PORT` Optional when the default port is used.
8585
- `PCA_MEMCACHED_0_PATH` Unix domain socket (optional).
8686

87-
PHP:
87+
Other:
88+
8889
- `PCA_PHP_MEMORY_LIMIT` In case you need to increase the PHP memory limit in Docker.
90+
- `PCA_NGINX_PORT` In case you need to change NGINX port in Docker.
8991

9092
Open the [config](https://github.com/RobiNN1/phpCacheAdmin/blob/master/config.dist.php) file for more info.
9193

@@ -98,7 +100,7 @@ A Docker image is also available: https://hub.docker.com/r/robinn/phpcacheadmin
98100
Run with a single command:
99101

100102
```bash
101-
docker run -p 8080:80 -d --name phpcacheadmin -e "PCA_REDIS_0_HOST=redis_host" -e "PCA_REDIS_0_PORT=6379" -e "PCA_MEMCACHED_0_HOST=memcached_host" -e "PCA_MEMCACHED_0_PORT=11211" robinn/phpcacheadmin
103+
docker run -p 8080:8080 -d --name phpcacheadmin -e "PCA_REDIS_0_HOST=redis_host" -e "PCA_REDIS_0_PORT=6379" -e "PCA_MEMCACHED_0_HOST=memcached_host" -e "PCA_MEMCACHED_0_PORT=11211" robinn/phpcacheadmin
102104
```
103105

104106
Or use it in **docker-compose.yml**
@@ -108,7 +110,7 @@ services:
108110
phpcacheadmin:
109111
image: robinn/phpcacheadmin
110112
ports:
111-
- "8080:80"
113+
- "8080:8080"
112114
#volumes:
113115
# If you want to use config.php instead of ENV variables
114116
# - "./config.php:/var/www/html/config.php"

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
phpcacheadmin:
33
build: .
44
ports:
5-
- "8080:80"
5+
- "8080:8080"
66
volumes:
77
- "./:/var/www/html/"
88
environment:

0 commit comments

Comments
 (0)