Skip to content

Commit

Permalink
Set the default memory limit for all versions to 1024MB (#12)
Browse files Browse the repository at this point in the history
* memlimit

* rename memlimit conf to 00 to make sure it can be overriden by client

* up default memory limit to 1024MB

* load memlimit later so it does not get overriden

* fix php 7.1 file
  • Loading branch information
Harry Bragg authored Nov 7, 2017
1 parent c9de4f0 commit 64cf9b8
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 18 deletions.
4 changes: 2 additions & 2 deletions 5.6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ ENV PHPIZE_DEPS autoconf file g++ gcc libc-dev make pkgconf re2c php5-dev php5-p

RUN set -xe \
&& apk add --no-cache \
--virtual .phpize-deps \
$PHPIZE_DEPS \
--virtual .phpize-deps \
$PHPIZE_DEPS \
&& sed -i 's/^exec $PHP -C -n/exec $PHP -C/g' $(which pecl) \
&& pecl channel-update pecl.php.net \
&& pecl install yaml-1.3.1 memcached-2.2.0 \
Expand Down
4 changes: 2 additions & 2 deletions 5.6/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ ENV PHPIZE_DEPS autoconf file g++ gcc libc-dev make pkgconf re2c php5-dev php5-p

RUN set -xe \
&& apk add --no-cache \
--virtual .phpize-deps \
$PHPIZE_DEPS \
--virtual .phpize-deps \
$PHPIZE_DEPS \
&& sed -i 's/^exec $PHP -C -n/exec $PHP -C/g' $(which pecl) \
&& pecl channel-update pecl.php.net \
&& pecl install yaml-1.3.1 memcached-2.2.0 \
Expand Down
2 changes: 1 addition & 1 deletion 5.6/php/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ max_input_time = 60

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 2048M
memory_limit = 1024M

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
Expand Down
8 changes: 8 additions & 0 deletions 5.6/php5.6.bats
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ readonly container="graze/php-alpine:5.6"
[ "$status" -eq 0 ]
[ "$output" = "" ]
}

@test "php should have a memory limit of 1024M" {
run bash -c "docker run --rm ${container} php -i | grep memory_limit"
echo "status: $status"
echo "output: $output"
[ "$status" -eq 0 ]
[ "$output" = "memory_limit => 1024M => 1024M" ]
}
8 changes: 8 additions & 0 deletions 5.6/php5.6_debug.bats
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,11 @@ readonly container="graze/php-alpine:5.6-test"
[ "$status" -eq 0 ]
[ "$output" = "" ]
}

@test "php should have a memory limit of 1024M" {
run bash -c "docker run --rm ${container} php -i | grep memory_limit"
echo "status: $status"
echo "output: $output"
[ "$status" -eq 0 ]
[ "$output" = "memory_limit => 1024M => 1024M" ]
}
6 changes: 3 additions & 3 deletions 7.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ RUN apk add --no-cache \

# install and remove building packages
ENV PHPIZE_DEPS autoconf file g++ gcc libc-dev make pkgconf re2c php7-dev php7-pear \
yaml-dev pcre-dev zlib-dev libmemcached-dev cyrus-sasl-dev
yaml-dev pcre-dev zlib-dev libmemcached-dev cyrus-sasl-dev

RUN set -xe \
&& apk add --no-cache \
--virtual .phpize-deps \
$PHPIZE_DEPS \
--virtual .phpize-deps \
$PHPIZE_DEPS \
&& sed -i 's/^exec $PHP -C -n/exec $PHP -C/g' $(which pecl) \
&& pecl channel-update pecl.php.net \
&& pecl install yaml apcu memcached \
Expand Down
6 changes: 3 additions & 3 deletions 7.0/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ RUN apk add --no-cache \

# install and remove building packages
ENV PHPIZE_DEPS autoconf file g++ gcc libc-dev make pkgconf re2c php7-dev php7-pear \
yaml-dev pcre-dev zlib-dev libmemcached-dev cyrus-sasl-dev
yaml-dev pcre-dev zlib-dev libmemcached-dev cyrus-sasl-dev

RUN set -xe \
&& apk add --no-cache \
--virtual .phpize-deps \
$PHPIZE_DEPS \
--virtual .phpize-deps \
$PHPIZE_DEPS \
&& sed -i 's/^exec $PHP -C -n/exec $PHP -C/g' $(which pecl) \
&& pecl channel-update pecl.php.net \
&& pecl install yaml apcu memcached \
Expand Down
2 changes: 1 addition & 1 deletion 7.0/php/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ max_input_time = 60

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 2048M
memory_limit = 1024M

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
Expand Down
8 changes: 8 additions & 0 deletions 7.0/php7.0.bats
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ readonly container="graze/php-alpine:7.0"
[ "$status" -eq 0 ]
[ "$output" = "" ]
}

@test "php should have a memory limit of 1024M" {
run bash -c "docker run --rm ${container} php -i | grep memory_limit"
echo "status: $status"
echo "output: $output"
[ "$status" -eq 0 ]
[ "$output" = "memory_limit => 1024M => 1024M" ]
}
8 changes: 8 additions & 0 deletions 7.0/php7.0_debug.bats
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,11 @@ readonly container="graze/php-alpine:7.0-test"
[ "$status" -eq 0 ]
[ "$output" = "" ]
}

@test "php should have a memory limit of 1024M" {
run bash -c "docker run --rm ${container} php -i | grep memory_limit"
echo "status: $status"
echo "output: $output"
[ "$status" -eq 0 ]
[ "$output" = "memory_limit => 1024M => 1024M" ]
}
6 changes: 4 additions & 2 deletions 7.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ ENV PHPIZE_DEPS autoconf file g++ gcc libc-dev make pkgconf re2c php7-dev php7-p

RUN set -xe \
&& apk add --no-cache --repository "http://dl-cdn.alpinelinux.org/alpine/edge/testing" \
--virtual .phpize-deps \
$PHPIZE_DEPS \
--virtual .phpize-deps \
$PHPIZE_DEPS \
&& sed -i 's/^exec $PHP -C -n/exec $PHP -C/g' $(which pecl) \
&& pecl channel-update pecl.php.net \
&& pecl install yaml \
Expand All @@ -64,6 +64,8 @@ RUN set -xe \
&& rm -rf /tmp/* \
&& apk del .phpize-deps

COPY php/conf.d/00_memlimit.ini /etc/php7/conf.d/00_memlimit.ini

WORKDIR /srv

ARG BUILD_DATE
Expand Down
6 changes: 4 additions & 2 deletions 7.1/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ ENV PHPIZE_DEPS autoconf file g++ gcc libc-dev make pkgconf re2c php7-dev php7-p

RUN set -xe \
&& apk add --no-cache --repository "http://dl-cdn.alpinelinux.org/alpine/edge/testing" \
--virtual .phpize-deps \
$PHPIZE_DEPS \
--virtual .phpize-deps \
$PHPIZE_DEPS \
&& sed -i 's/^exec $PHP -C -n/exec $PHP -C/g' $(which pecl) \
&& pecl channel-update pecl.php.net \
&& pecl install yaml \
Expand All @@ -65,6 +65,8 @@ RUN set -xe \
&& rm -rf /tmp/* \
&& apk del .phpize-deps

COPY php/conf.d/00_memlimit.ini /etc/php7/conf.d/00_memlimit.ini

WORKDIR /srv

ARG BUILD_DATE
Expand Down
3 changes: 3 additions & 0 deletions 7.1/php/conf.d/00_memlimit.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 1024M
8 changes: 8 additions & 0 deletions 7.1/php7.1.bats
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ readonly container="graze/php-alpine:7.1"
[ "$status" -eq 0 ]
[ "$output" = "" ]
}

@test "php should have a memory limit of 1024M" {
run bash -c "docker run --rm ${container} php -i | grep memory_limit"
echo "status: $status"
echo "output: $output"
[ "$status" -eq 0 ]
[ "$output" = "memory_limit => 1024M => 1024M" ]
}
8 changes: 8 additions & 0 deletions 7.1/php7.1_debug.bats
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,11 @@ readonly container="graze/php-alpine:7.1-test"
[ "$status" -eq 0 ]
[ "$output" = "" ]
}

@test "php should have a memory limit of 1024M" {
run bash -c "docker run --rm ${container} php -i | grep memory_limit"
echo "status: $status"
echo "output: $output"
[ "$status" -eq 0 ]
[ "$output" = "memory_limit => 1024M => 1024M" ]
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ deploy: deploy-5.6 deploy-7.0 deploy-7.1

build-%: cache ?=--pull --no-cache
build-%: ## build a generic image
docker build $(build_args) ${cache} -t graze/php-alpine:$* $*/.
docker build $(build_args) ${cache} -t graze/php-alpine:$*-test -f $*/Dockerfile.debug $*/.
docker build ${build_args} ${cache} -t graze/php-alpine:$* $*/.
docker build ${build_args} ${cache} -t graze/php-alpine:$*-test -f $*/Dockerfile.debug $*/.

clean-%: ## Clean up the images
docker rmi $$(docker images -q graze/php-alpine:$**) || echo "no images"
Expand Down

0 comments on commit 64cf9b8

Please sign in to comment.