Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
627b48852a | ||
|
4d86334839 | ||
|
9600a556ad | ||
|
afe65b2618 | ||
|
1111afcb5f | ||
|
45d16b63cb | ||
|
d6de32b198 | ||
|
ac0cda2818 | ||
|
38bd78f594 | ||
|
2e1edc3966 | ||
|
0c0f172782 | ||
|
f81815e789 | ||
|
8d8da2f5ad | ||
|
8d34685aaa | ||
|
3868365626 | ||
|
f505457e9b | ||
|
1667116257 | ||
|
e047287407 | ||
|
c4de84d51a | ||
|
f2602bd98a |
@@ -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
|
||||
|
19
Dockerfile
19
Dockerfile
@@ -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
|
||||
|
@@ -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
52
init
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user