20 Commits

Author SHA1 Message Date
Deon George
627b48852a Changes to Permission settings, to enable NGINX to read public dirs 2021-06-30 16:11:38 +10:00
Deon George
4d86334839 Change cache configuration, ensure items in public dont have +x 2021-06-24 23:34:54 +10:00
Deon George
9600a556ad Fix trigger to the right branch 2021-06-15 22:36:13 +10:00
Deon George
afe65b2618 Fix ommissions in previous commit 2021-06-09 12:34:43 +10:00
Deon George
1111afcb5f Changed NO_NGINX to NGINX_START, added REDIS/MEMCACHED startup 2021-06-09 12:12:06 +10:00
Deon George
45d16b63cb Added memcached to php 2021-06-09 11:37:15 +10:00
Deon George
d6de32b198 We also need --post301 for redirects 2021-05-27 10:11:35 +10:00
Deon George
ac0cda2818 Try with trigger token 2021-05-27 10:01:25 +10:00
Deon George
38bd78f594 Added -L to curl for redirects 2021-05-27 09:50:30 +10:00
Deon George
2e1edc3966 docker image uses apk not apt 2021-05-27 09:48:03 +10:00
Deon George
0c0f172782 Alternative attempt to trigger next branch builds 2021-05-27 09:44:36 +10:00
Deon George
f81815e789 Alternative attempt to trigger next branch builds 2021-05-27 09:30:34 +10:00
Deon George
8d8da2f5ad Increase PHP default memory limit to 256M 2021-05-27 09:06:49 +10:00
Deon George
8d34685aaa Changed dev to local, since laravel uses local for non-production deployments 2021-05-24 15:39:07 +10:00
Deon George
3868365626 Revert "Go back to PHP 8.0.3"
This reverts commit f505457e9b.
2021-05-04 11:31:21 +10:00
Deon George
f505457e9b Go back to PHP 8.0.3 2021-05-04 11:14:39 +10:00
Deon George
1667116257 Try trigger of ext after successful build 2021-05-04 10:05:12 +10:00
Deon George
e047287407 Enabled specifying additional queues to run locally 2021-05-04 09:41:22 +10:00
Deon George
c4de84d51a Add LOCAL_QUEUE process for jobs on the 'hostname' queue 2021-03-25 14:13:54 +11:00
Deon George
f2602bd98a Update to PHP 8.0 2021-03-03 13:53:44 +11:00
4 changed files with 63 additions and 21 deletions

View File

@@ -7,7 +7,7 @@ stages:
variables:
BRANCH: mp
VERSION: 7.4-fpm-${BRANCH}
VERSION: 8.0-fpm-${BRANCH}
CACHETAG: build-${BRANCH}
DOCKER_HOST: tcp://docker:2375
@@ -33,10 +33,11 @@ x86_64:build:
stage: build
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || echo "true"
- ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || true
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} .
- docker push ${CI_REGISTRY_IMAGE}:${VERSION}
- docker push ${CI_REGISTRY_IMAGE}:${CACHETAG}
- apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=plus ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
tags:
- docker
- x86_64
@@ -47,8 +48,8 @@ x86_64:build-test:
stage: build-test
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || echo "true"
- docker build --file Dockerfile.phptest --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION}-test .
- ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || true
- docker build --file Dockerfile.phptest --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION}-test .
- docker push ${CI_REGISTRY_IMAGE}:${VERSION}-test
tags:
- docker

View File

@@ -1,7 +1,7 @@
# NAME leenooks/php
# VERSION 7.4-fpm-mp
# VERSION 8.0-fpm-mp
FROM php:7.4-fpm
FROM php:8.0-fpm
RUN apt-get update && apt-get install -y openssh-server unzip git msmtp nginx wait-for-it \
&& rm /etc/nginx/sites-enabled/default \
@@ -18,7 +18,7 @@ COPY sshd_config.patch /tmp/
RUN (cd / && patch -p0 ) < /tmp/sshd_config.patch && rm /tmp/sshd_config.patch
COPY msmtprc /etc/
RUN sed -i -e 's#^;sendmail_path =#sendmail_path = "/usr/bin/msmtp -t"#' /usr/local/etc/php/php.ini
RUN sed -i -e 's#^;sendmail_path =#sendmail_path = "/usr/bin/msmtp -t"#' /usr/local/etc/php/php.ini && sed -i -e 's#^memory_limit = 128M#memory_limit = 256M#' /usr/local/etc/php/php.ini
EXPOSE 22/tcp
@@ -34,7 +34,18 @@ RUN apt-get update && apt-get install -y openssh-server libpq5 libpq-dev unzip g
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Enable phpredis
RUN pecl install -o -f igbinary && pecl install -o -f redis && docker-php-ext-enable redis igbinary && rm -rf /tmp/*
RUN apt-get update && apt-get install -y redis \
&& pecl install -o -f igbinary && pecl install -o -f redis && docker-php-ext-enable redis igbinary \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Enable phpmemcache
RUN apt-get update && apt-get install -y memcached libmemcachedutil2 zlib1g-dev libmemcached-dev \
&& pecl install -o -f memcached && docker-php-ext-enable memcached \
&& apt-get -y purge zlib1g-dev libmemcached-dev \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY init /sbin/
RUN chmod 550 /sbin/init && chown 0:0 /sbin/init

View File

@@ -1,7 +1,7 @@
# NAME leenooks/php
# VERSION 7.4-fpm-test
# VERSION 8.0-fpm-test
FROM registry.leenooks.net/leenooks/php:7.4-fpm-mp
FROM registry.leenooks.net/leenooks/php:8.0-fpm-mp
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

52
init
View File

@@ -5,8 +5,16 @@ role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-live}
php=${PHP_DIR:-/var/www/html}
composer=${COMPOSER_DIR:-/var/www/.composer}
NO_NGINX=${NO_NGINX:-TRUE}
NGINX_START=${NGINX_START:-TRUE}
SSH_START=${SSH_START:-FALSE}
REDIS_START=${REDIS_START:-FALSE}
MEMCACHED_START=${MEMCACHED_START:-FALSE}
# To run a local queue, running jobs from the queue "hostname"
LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE}
# Optional additional queues to run for
#LOCAL_QUEUES=
function mp() {
set +e
@@ -18,18 +26,29 @@ function mp() {
function nginx_start() {
# Start NGINX
if [ -x /usr/sbin/nginx -a "${NO_NGINX}" != "TRUE" ]; then
if [ -x /usr/sbin/nginx -a "${NGINX_START}" == "TRUE" ]; then
echo "* Starting NGINX..."
start-stop-daemon --start --pidfile /var/run/nginx.pid --exec /usr/sbin/nginx -- -g 'daemon on; master_process on;'
fi
}
# General Setup
if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then
if [ -x /usr/sbin/sshd -a "${SSH_START}" == "TRUE" ]; then
echo "* Starting SSH..."
[ ! -d /var/run/sshd ] && mkdir /var/run/sshd
start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22
fi
if [ -x /usr/bin/redis-server -a "${REDIS_START}" == "TRUE" ]; then
echo "* Starting REDIS..."
start-stop-daemon --start --quiet --oknodo --umask 007 --pidfile /var/run/redis-server.pid --chuid redis:redis --exec /usr/bin/redis-server -- /etc/redis/redis.conf
fi
if [ -x /usr/bin/memcached -a "${MEMCACHED_START}" == "TRUE" ]; then
echo "* Starting MEMCACHED..."
start-stop-daemon --start --quiet --exec "/usr/share/memcached/scripts/start-memcached" -- /etc/memcached.conf /var/run/memcached.pid
fi
# Laravel Specific
if [ "${role}" = "app" -a -e artisan ]; then
if [ ! -e ${php}/.env ]; then
@@ -41,13 +60,15 @@ if [ "${role}" = "app" -a -e artisan ]; then
# Only adjust perms if this is an external mountpoint
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
if [ -n "${FORCE_PERMS}" -o "${env}" != "dev" -a -z "${SKIP_PERM}" ]; then
if [ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ]; then
echo "* Setting Permissions..."
# Make sure our permissions are appropraite
find ${php} -type f -exec chmod 640 {} \;
find ${php} -type d -exec chmod 750 {} \;
find ${php}/public -type f -exec chmod 644 {} \;
find ${php}/public -type d -exec chmod 755 {} \;
chmod o+rx ${php}
chmod -R o+rx ${php}/public
chmod a+rx ${php}/artisan
chown -R lamp:www-data ${php}
chown -R www-data:www-data ${php}/storage ${php}/bootstrap ${php}/composer.*
[ -e ${php}/vendor ] && chown -R www-data:www-data ${php}/vendor
@@ -57,28 +78,30 @@ if [ "${role}" = "app" -a -e artisan ]; then
if [ "${env}" != "local" -a -r "artisan" ]; then
# See if we need to refresh our dependancies
if [[ -r composer.json && ( -e .composer.refresh || ! -d vendor ) ]]; then
echo "* Composer installing dependancies..."
rm -f ${php}/bootstrap/cache/*.php
if [ "${env}" != "dev" ]; then
if [ "${env}" != "local" ]; then
NODEV="--no-dev"
fi
mp=$(mp ${composer})
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
[ -n "${FORCE_PERMS}" -o "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chown -R www-data:www-data ${composer}
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chown -R www-data:www-data ${composer}
[ ! -d ${php}/vendor ] && mkdir -m 750 ${php}/vendor && chown www-data:www-data ${php}/vendor
[ -n "${FORCE_PERMS}" -o "${env}" != "dev" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
fi
su www-data -s /bin/sh -c "composer install --optimize-autoloader ${NODEV}" && ( test -e .composer.refresh && rm -f .composer.refresh )
[ -n "${FORCE_PERMS}" -o "${env}" != "dev" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
fi
if [ -e .lumen ]; then
echo "* Lumen detected..."
else
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan config:cache && php artisan route:cache && php artisan view:cache)"
su www-data -s /bin/sh -c "(php artisan optimize && php artisan view:cache)"
fi
if [ -r .migrate ]; then
@@ -106,6 +129,13 @@ if [ "${role}" = "app" -a -e artisan ]; then
nginx_start
if [ "${LOCAL_QUEUE}" = "TRUE" ]; then
echo "* Starting local queue for [$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}}] with job timeout of [${WORK_TIMEOUT:-90}], trying [${WORK_TRIES:-1}] times..."
su www-data -s /bin/sh -c "
(while true; do php ${PHP_OPTIONS} artisan queue:work --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} --queue=$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}; done) &
"
fi
exec /usr/local/bin/docker-php-entrypoint "$@"
elif [ "$role" = "queue" -a -e artisan ]; then
@@ -115,7 +145,7 @@ elif [ "$role" = "queue" -a -e artisan ]; then
fi
QUEUE_CMD=work
if [ "${env}" == "dev" ]; then
if [ "${env}" == "local" ]; then
QUEUE_CMD=listen
fi