Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ stages:
- latest

variables:
PHP_7_2: 7.2.33
PHP_7_3: 7.3.22
PHP_7_4: 7.4.10
PHP_8_0: 8.0-rc
PHP_8_0: 8.0.2
PHP_7_4: 7.4.15
PHP_7_3: 7.3.27
PHP_7_2: 7.2.34

.build:
stage: build
Expand Down Expand Up @@ -34,6 +34,7 @@ build-next-7-2:
DOCKER_IMAGE_TAG: next-7.2
PHP_BASEIMAGE_VERSION: $PHP_7_2
CACHE_FROM: $CI_REGISTRY_IMAGE:next-7.2
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- next

Expand All @@ -43,6 +44,7 @@ build-master-7-2:
DOCKER_IMAGE_TAG: latest-7.2
PHP_BASEIMAGE_VERSION: $PHP_7_2
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.2
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- master

Expand All @@ -52,6 +54,7 @@ build-tags-7-2:
DOCKER_IMAGE_TAG: $CI_COMMIT_REF_NAME-7.2
PHP_BASEIMAGE_VERSION: $PHP_7_2
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.2
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- tags

Expand All @@ -64,6 +67,7 @@ build-next-7-3:
DOCKER_IMAGE_TAG: next-7.3
PHP_BASEIMAGE_VERSION: $PHP_7_3
CACHE_FROM: $CI_REGISTRY_IMAGE:next-7.3
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- next

Expand All @@ -73,6 +77,7 @@ build-master-7-3:
DOCKER_IMAGE_TAG: latest-7.3
PHP_BASEIMAGE_VERSION: $PHP_7_3
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.3
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- master

Expand All @@ -82,6 +87,7 @@ build-tags-7-3:
DOCKER_IMAGE_TAG: $CI_COMMIT_REF_NAME-7.3
PHP_BASEIMAGE_VERSION: $PHP_7_3
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.3
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- tags

Expand All @@ -94,6 +100,7 @@ build-next-7-4:
DOCKER_IMAGE_TAG: next-7.4
PHP_BASEIMAGE_VERSION: $PHP_7_4
CACHE_FROM: $CI_REGISTRY_IMAGE:next-7.4
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- next

Expand All @@ -103,6 +110,7 @@ build-master-7-4:
DOCKER_IMAGE_TAG: latest-7.4
PHP_BASEIMAGE_VERSION: $PHP_7_4
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.4
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- master

Expand All @@ -112,6 +120,7 @@ build-tags-7-4:
DOCKER_IMAGE_TAG: $CI_COMMIT_REF_NAME-7.4
PHP_BASEIMAGE_VERSION: $PHP_7_4
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.4
PHP_EXTENSIONS: "dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
only:
- tags

Expand All @@ -121,14 +130,31 @@ build-tags-7-4:
build-next-8-0:
extends: .build
variables:
DOCKER_IMAGE_TAG: next-8.0-rc
DOCKER_IMAGE_TAG: next-8.0
PHP_BASEIMAGE_VERSION: $PHP_8_0
XDEBUG_VERSION: master
PHP_EXTENSIONS: "dom exif gd iconv intl mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
CACHE_FROM: $CI_REGISTRY_IMAGE:next-8.0-rc
CACHE_FROM: $CI_REGISTRY_IMAGE:next-8.0
only:
- next

build-master-8-0:
extends: .build
variables:
DOCKER_IMAGE_TAG: latest-8.0
PHP_BASEIMAGE_VERSION: $PHP_8_0
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-8.0
only:
- master

build-tags-8-0:
extends: .build
variables:
DOCKER_IMAGE_TAG: $CI_COMMIT_REF_NAME-8.0
PHP_BASEIMAGE_VERSION: $PHP_8_0
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-8.0
only:
- tags

# Latest
# =========================================

Expand All @@ -137,8 +163,8 @@ build-next-latest:
stage: latest
variables:
DOCKER_IMAGE_TAG: next
PHP_BASEIMAGE_VERSION: $PHP_7_4
CACHE_FROM: $CI_REGISTRY_IMAGE:next-7.4
PHP_BASEIMAGE_VERSION: $PHP_8_0
CACHE_FROM: $CI_REGISTRY_IMAGE:next-8.0
only:
- next

Expand All @@ -147,8 +173,8 @@ build-master-latest:
stage: latest
variables:
DOCKER_IMAGE_TAG: latest
PHP_BASEIMAGE_VERSION: $PHP_7_4
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.4
PHP_BASEIMAGE_VERSION: $PHP_8_0
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-8.0
only:
- master

Expand All @@ -157,7 +183,7 @@ build-tags-latest:
stage: latest
variables:
DOCKER_IMAGE_TAG: $CI_COMMIT_REF_NAME
PHP_BASEIMAGE_VERSION: $PHP_7_4
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-7.4
PHP_BASEIMAGE_VERSION: $PHP_8_0
CACHE_FROM: $CI_REGISTRY_IMAGE:latest-8.0
only:
- tags
16 changes: 5 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_BASEIMAGE_VERSION=7.4.10
ARG PHP_BASEIMAGE_VERSION=8.0.2
FROM php:${PHP_BASEIMAGE_VERSION}-fpm-alpine

LABEL maintainer="Constantine Karnaukhov <genteelknight@gmail.com>"
Expand All @@ -10,8 +10,8 @@ ENV \
# Fix for iconv: https://github.com/docker-library/php/issues/240
LD_PRELOAD="/usr/lib/preloadable_libiconv.so php"

ARG XDEBUG_VERSION=2.9.8
ARG PHP_EXTENSIONS="dom exif gd iconv intl json mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"
ARG XDEBUG_VERSION=3.0.2
ARG PHP_EXTENSIONS="dom exif gd iconv intl mysqli opcache pdo_mysql pdo_sqlite soap xsl zip"

# Install dependencies
RUN apk add --update \
Expand Down Expand Up @@ -65,14 +65,7 @@ RUN apk add --update \
rm -rf /tmp/xdebug && \
docker-php-source delete && \
apk del gcc musl-dev linux-headers libffi-dev augeas-dev make autoconf && \
rm -rf /var/cache/apk/* && \
mkdir -p $COMPOSER_HOME && \
EXPECTED_COMPOSER_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('SHA384', 'composer-setup.php') === '${EXPECTED_COMPOSER_SIGNATURE}') { echo 'Composer.phar Installer verified'; } else { echo 'Composer.phar Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \
php -r "unlink('composer-setup.php');" && \
composer global require hirak/prestissimo
rm -rf /var/cache/apk/*

# tweak php-fpm config
RUN echo "" > /usr/local/etc/php/conf.d/05-php.ini && \
Expand Down Expand Up @@ -116,6 +109,7 @@ RUN mkdir -p /etc/nginx && \
ln -s /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf

# Add spaceonfire
ENV PATH="${PATH}:${COMPOSER_HOME}/bin:${COMPOSER_HOME}/vendor/bin"
COPY ./spaceonfire/ /opt/spaceonfire/
RUN chmod -R +x /opt/spaceonfire/bin/* && /opt/spaceonfire/bin/install.sh

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Docker образ, основанный на Alpine Linux, с установле

| Docker Tag | PHP Version |
| ------------------------------------- | ----------- |
| `latest` / `latest-7.4` / `2.4.2-7.4` | 7.4.10 |
| `latest-7.3` / `2.4.2-7.3` | 7.3.22 |
| `latest-7.2` / `2.4.2-7.2` | 7.2.33 |
| `next-8.0-rc` | 8.0.0-rc |
| `latest` / `latest-8.0` / `2.5.0-8.0` | 8.0.2 |
| `latest-7.4` / `2.5.0-7.4` | 7.4.15 |
| `latest-7.3` / `2.5.0-7.3` | 7.3.27 |
| `latest-7.2` / `2.5.0-7.2` | 7.2.34 |

## Быстрый старт

Expand Down
3 changes: 2 additions & 1 deletion docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
| `DOMAIN` | Укажите свой домен, чтобы добавить настройку RewriteDomain в конфиг ssmtp |
| `SSMTP_DEFAULT_FROM` | Укажите email, с которого должная отправляться почта по-умолчанию |
| `ENABLE_XDEBUG` | Укажите "1", включить расширение Xdebug |
| `XDEBUG_REMOTE_HOST` | Укажите свой IP адрес для `xdebug.remote_host`. [Подробнее про Xdebug](./xdebug.md) |
| `XDEBUG_REMOTE_HOST` | Укажите свой IP адрес для `xdebug.client_host`. [Подробнее про Xdebug](./xdebug.md) |
| `XDEBUG_IDEKEY` | Укажите свой IDE key для `xdebug.idekey`. [Подробнее про Xdebug](./xdebug.md) |
| `COMPOSER_VERSION` | Выберите мажорную версию Composer (`v1` или `v2`, по-умолчанию `v1`) |
70 changes: 41 additions & 29 deletions spaceonfire/bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

# Set custom webroot
if [ ! -z "$WEBROOT" ]; then
if [ -n "$WEBROOT" ]; then
sed -i "s#root /var/www/html;#root ${WEBROOT};#g" /etc/nginx/sites-available/default.conf
else
WEBROOT=/var/www/html
fi

# Recreate nginx user with passed UID and GID
if [ ! -z "$PUID" ]; then
if [ -n "$PUID" ]; then
if [ -z "$PGID" ]; then
PGID=${PUID}
fi
Expand All @@ -21,34 +21,46 @@ if [ ! -z "$PUID" ]; then
fi

# Setup access rights for nginx group
setfacl -RL -m g:nginx:rwx $COMPOSER_HOME >> /dev/null 2>&1
{
setfacl -RLm g:nginx:rwx "$COMPOSER_HOME"
setfacl -RLdm g:nginx:rwx "$COMPOSER_HOME"
setfacl -RLm g:nginx:rwx /opt/spaceonfire/composer/v1
setfacl -RLdm g:nginx:rwx /opt/spaceonfire/composer/v1
setfacl -RLm g:nginx:rwx /opt/spaceonfire/composer/v2
setfacl -RLdm g:nginx:rwx /opt/spaceonfire/composer/v2
} >>/dev/null 2>&1

if [[ "$SKIP_SETFACL" != "1" ]]; then
setfacl -RL -m g:nginx:rwx /var/www/html/ >> /dev/null 2>&1
setfacl -RLdm g:nginx:rwx /var/www/html/ >>/dev/null 2>&1
fi

# Copy default index.html
if [ $(ls $WEBROOT/index.{php,htm,html} 2>/dev/null | wc -l) -eq 0 ]; then
cp -f /opt/spaceonfire/html/index.html $WEBROOT
fi

if [ ! -z "$SOF_PRESET" ]; then
if [ -n "$SOF_PRESET" ]; then
/opt/spaceonfire/bin/select-preset.sh $SOF_PRESET
fi

if [ -n "$COMPOSER_VERSION" ]; then
/opt/spaceonfire/bin/select-composer.sh $COMPOSER_VERSION
fi

/opt/spaceonfire/bin/ssmtp-setup.php

# Set Nginx read timeout
if [[ -z "$NGINX_READ_TIMEOUT" ]] && [[ "$APPLICATION_ENV" != "production" ]]; then
NGINX_READ_TIMEOUT=9999
fi

if [[ ! -z "$NGINX_READ_TIMEOUT" ]]; then
if [[ -n "$NGINX_READ_TIMEOUT" ]]; then
FastCgiParamsFile="/etc/nginx/fastcgi_params"
if ! grep -q fastcgi_read_timeout "$FastCgiParamsFile"; then
{
echo ""
echo "fastcgi_read_timeout $NGINX_READ_TIMEOUT;"
} >> $FastCgiParamsFile
} >>$FastCgiParamsFile
fi
fi

Expand All @@ -59,21 +71,21 @@ if [[ $lastlinephpconf == *"php_flag[display_errors]"* ]]; then
fi

# Display PHP error's or not
if [[ "$ERRORS" != "1" ]] ; then
echo "php_flag[display_errors] = off" >> /usr/local/etc/php-fpm.conf
if [[ "$ERRORS" != "1" ]]; then
echo "php_flag[display_errors] = off" >>/usr/local/etc/php-fpm.conf
else
echo "php_flag[display_errors] = on" >> /usr/local/etc/php-fpm.conf
echo "php_flag[display_errors] = on" >>/usr/local/etc/php-fpm.conf
fi

# Display Version Details or not
if [[ "$HIDE_NGINX_HEADERS" == "0" ]] ; then
if [[ "$HIDE_NGINX_HEADERS" == "0" ]]; then
sed -i "s/server_tokens off;/server_tokens on;/g" /etc/nginx/nginx.conf
else
sed -i "s/expose_php = On/expose_php = Off/g" /usr/local/etc/php-fpm.conf
fi

# Pass real-ip to logs when behind ELB, etc
if [[ "$REAL_IP_HEADER" == "1" ]] ; then
if [[ "$REAL_IP_HEADER" == "1" ]]; then
vhosts=('/etc/nginx/sites-available/default.conf' '/etc/nginx/sites-available/default-ssl.conf')
for vhost in vhosts; do
sed -i "s/#real_ip_header X-Forwarded-For;/real_ip_header X-Forwarded-For;/" $vhost
Expand All @@ -85,30 +97,30 @@ if [[ "$REAL_IP_HEADER" == "1" ]] ; then
fi

#Display errors in docker logs
if [ ! -z "$PHP_ERRORS_STDERR" ]; then
echo "log_errors = On" >> /usr/local/etc/php/conf.d/docker-vars.ini
echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/docker-vars.ini
if [ -n "$PHP_ERRORS_STDERR" ]; then
echo "log_errors = On" >>/usr/local/etc/php/conf.d/docker-vars.ini
echo "error_log = /dev/stderr" >>/usr/local/etc/php/conf.d/docker-vars.ini
fi

# Increase the memory_limit
if [ ! -z "$PHP_MEM_LIMIT" ]; then
if [ -n "$PHP_MEM_LIMIT" ]; then
sed -i "s/memory_limit = 128M/memory_limit = ${PHP_MEM_LIMIT}M/g" /usr/local/etc/php/conf.d/docker-vars.ini
fi

# Increase the post_max_size
if [ ! -z "$PHP_POST_MAX_SIZE" ]; then
if [ -n "$PHP_POST_MAX_SIZE" ]; then
sed -i "s/post_max_size = 100M/post_max_size = ${PHP_POST_MAX_SIZE}M/g" /usr/local/etc/php/conf.d/docker-vars.ini
fi

# Increase the upload_max_filesize
if [ ! -z "$PHP_UPLOAD_MAX_FILESIZE" ]; then
if [ -n "$PHP_UPLOAD_MAX_FILESIZE" ]; then
sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /usr/local/etc/php/conf.d/docker-vars.ini
fi

# Enable xdebug only
if [ "$APPLICATION_ENV" != "production" ]; then
XdebugFile='/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini'
if [[ "$ENABLE_XDEBUG" == "1" ]] ; then
if [[ "$ENABLE_XDEBUG" == "1" ]]; then
if [ -f $XdebugFile ]; then
echo "Xdebug enabled"
else
Expand All @@ -120,7 +132,7 @@ if [ "$APPLICATION_ENV" != "production" ]; then
if [ -f $XdebugFile ]; then
# Get default route ip if not set
if [ -z "$XDEBUG_REMOTE_HOST" ]; then
XDEBUG_REMOTE_HOST=$(ip route|awk '/default/ { print $3 }')
XDEBUG_REMOTE_HOST=$(ip route | awk '/default/ { print $3 }')
fi

# See if file contains xdebug text.
Expand All @@ -129,15 +141,14 @@ if [ "$APPLICATION_ENV" != "production" ]; then
else
{
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)"
echo "xdebug.remote_enable=1"
echo "xdebug.remote_autostart=1"
echo "xdebug.remote_connect_back=0"
echo "xdebug.remote_host=${XDEBUG_REMOTE_HOST}"
echo "xdebug.mode=debug"
echo "xdebug.start_with_request=1"
echo "xdebug.idekey=${XDEBUG_IDEKEY:-docker}"
echo "xdebug.client_host=${XDEBUG_REMOTE_HOST}"
echo "xdebug.var_display_max_depth=-1"
echo "xdebug.var_display_max_children=-1"
echo "xdebug.var_display_max_data=-1"
} > $XdebugFile
} >$XdebugFile
fi
fi
fi
Expand All @@ -150,12 +161,13 @@ if [ "$APPLICATION_ENV" != "production" ]; then
fi

# Run custom scripts
if [[ "$RUN_SCRIPTS" == "1" ]] ; then
if [[ "$RUN_SCRIPTS" == "1" ]]; then
if [ -d "/var/www/html/scripts/" ]; then
# make scripts executable incase they aren't
chmod -Rf 750 /var/www/html/scripts/*; sync;
# make scripts executable in case they aren't
chmod -Rf 750 /var/www/html/scripts/*
sync
# run scripts in number order
for i in /var/www/html/scripts/*; do $i ; done
for i in /var/www/html/scripts/*; do $i; done
else
echo "Can't find script directory"
fi
Expand Down
Loading