Compare commits

...

41 Commits
db2 ... master

Author SHA1 Message Date
d62cc85c97 schedule:work now doesnt exit immediately, add wait_for_db for queue
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 3m24s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 12m8s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Create Docker Image / Build Docker Test Image (x86_64) (push) Successful in 54s
Create Docker Image / Final Docker Test Image Manifest (push) Successful in 10s
2024-09-24 23:21:05 +10:00
b665751711 Minor optimisation to init
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 3m48s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 12m28s
Create Docker Image / Final Docker Image Manifest (push) Successful in 11s
Create Docker Image / Build Docker Test Image (x86_64) (push) Successful in 55s
Create Docker Image / Final Docker Test Image Manifest (push) Successful in 10s
2024-08-24 22:17:17 +10:00
f86ce8e8a8 Added intl module
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 4m4s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 14m11s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Create Docker Image / Build Docker Test Image (x86_64) (push) Successful in 58s
Create Docker Image / Final Docker Test Image Manifest (push) Successful in 10s
2024-07-03 22:00:43 +10:00
0cf1719488 Added gitea CI/CD configuration
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 3m0s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 8m32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 11s
Create Docker Image / Build Docker Test Image (x86_64) (push) Successful in 49s
Create Docker Image / Final Docker Test Image Manifest (push) Successful in 11s
2024-04-07 20:47:00 +10:00
853f0b69d1 Ensure pecl cleans temp 2024-01-22 17:48:27 +11:00
74ffc27e6c Updated to php 8.3 2024-01-22 16:00:18 +11:00
232037d3ad Fix memcached pid dir and ownership 2024-01-09 20:18:50 +11:00
98210c41a9 Move npm to base image 2024-01-08 22:49:54 +11:00
cd26c07099 Update CI now that alpine has been merged into master 2024-01-08 21:15:39 +11:00
3056a63348 Enable armv7l build 2023-10-15 21:19:11 +11:00
4a1d0e8e56 Added /sbin/init-container execution if exists, for child images 2023-09-04 18:58:02 +10:00
d778b2599a Only trigger child builds if AUTO_BUILD defined 2023-07-01 00:02:29 +10:00
f5e4c8e300 HTTP_PROXY can now be defined with a variable 2023-06-30 23:55:32 +10:00
Deon George
4ac8e00528 Sed should be -i -e, not -ie 2023-06-26 20:14:14 +10:00
Deon George
59064cc03e Change msmtprc to use default email nobody@ 2023-05-04 20:21:20 +10:00
Deon George
6cd78fc2ad msmtprc was missing. updated msmtprc 2023-04-27 21:58:09 +10:00
Deon George
fca7560fa8 xdebug needs linux-headers 2023-04-05 23:14:31 +10:00
Deon George
0c0d80472b Minor tweak to gitlab-ci 2023-04-05 23:09:08 +10:00
Deon George
999a5e5bf6 Change our build cache to build-cache\ 2023-02-11 09:39:10 +11:00
Deon George
31a2b03d89 Laravel APP_ENV should default to production, not live 2023-02-11 09:39:10 +11:00
Deon George
12431f6c2e Disable armv7l builds and arm64 test builds 2023-02-11 09:39:09 +11:00
Deon George
e266319386 Set COMPOSER_HOME and define VOLUMEs 2023-02-11 09:39:09 +11:00
Deon George
d7b97dfce7 Change our cache key to better cache across architectures, and trigger child builds 2023-02-11 09:39:09 +11:00
Deon George
c56a9e6a53 Split out .gitlab-ci to separate files, added arm64 2023-02-11 09:39:08 +11:00
Deon George
88503c81a2 Change to use alpine, and try multi-arch building 2023-02-11 09:39:08 +11:00
Deon George
80a8203985 Test image was still building off of php 8.0 2023-01-30 23:21:01 +11:00
Deon George
2ce07e2c9a Added ZSTD 2022-10-21 09:29:00 +11:00
Deon George
26c30cb5cb Update php to 8.1 2022-07-30 10:55:41 +10:00
Deon George
a0a0c7e1e2 Added bcmath and intl modules 2022-06-26 11:42:56 +10:00
Deon George
546ebcc610 Enable migration to be ignored, even if we have to migrate 2022-02-06 15:10:24 +11:00
Deon George
6d37d4ae78 Change php memory to 512, and execution limit to 300 2022-01-20 16:23:24 +11:00
Deon George
4e50257a63 Change to stable-dind, gitlab-ci was failing on docker:dind 2022-01-06 01:01:49 +11:00
Deon George
d3b84db0e9 Update nginx-app, disabling fastcgi_buffer, gzip configuration and default timeout 600s 2022-01-05 17:31:12 +11:00
Deon George
8cf481d733 Installing npm results in systemd affecting our /sbin/init 2021-12-16 00:00:10 +11:00
Deon George
6da5ac5983 Need to remove nginx-core otherwise there are dependancy issues adding db modules 2021-12-09 23:10:45 +11:00
Deon George
3302b0d6d4 Fix run passport:keys when they already exist 2021-12-09 22:42:30 +11:00
Deon George
b1a333ea4d Use bash instead of sh 2021-07-19 00:48:50 +10:00
Deon George
06c6152085 Turn off -e when running init-php.sh 2021-07-18 23:47:31 +10:00
Deon George
194a6cfa99 Add init-php.sh execution if it exists 2021-07-17 23:11:55 +10:00
Deon George
471e5df45c Add zlib and ssl to mongo 2021-07-07 23:28:58 +10:00
Deon George
fa61e00cf0 Correct test dockerfile 2021-07-06 16:17:36 +10:00
13 changed files with 488 additions and 360 deletions

View File

@ -0,0 +1,190 @@
name: Create Docker Image
run-name: ${{ gitea.actor }} Building Docker Image 🐳
on: [push]
env:
VERSION: 8.3-fpm
DOCKER_HOST: tcp://127.0.0.1:2375
jobs:
build:
strategy:
matrix:
arch:
- x86_64
- arm64
name: Build Docker Image
runs-on: docker-${{ matrix.arch }}
container:
image: docker:dind
privileged: true
env:
ARCH: ${{ matrix.arch }}
VERSIONARCH: ${{ env.VERSION }}-${{ env.ARCH }}
steps:
- name: Environment Setup
run: |
# If we have a proxy use it
if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# Some pre-reqs
apk add git curl nodejs
# Start docker
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
## Some debugging info
# docker info && docker version
# env|sort
- name: Registry FQDN Setup
id: registry
run: |
registry=${{ github.server_url }}
echo "registry=${registry##http*://}" >> "$GITHUB_OUTPUT"
- name: Container Registry Login
uses: docker/login-action@v2
with:
registry: ${{ steps.registry.outputs.registry }}
username: ${{ gitea.actor }}
password: ${{ secrets.PKG_WRITE_TOKEN }}
- name: Code Checkout
uses: actions/checkout@v4
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: true
tags: "${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSIONARCH }}"
manifest:
name: Final Docker Image Manifest
runs-on: docker-x86_64
container:
image: docker:dind
privileged: true
needs: [build]
steps:
- name: Environment Setup
run: |
# If we have a proxy use it
if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# Some pre-reqs
apk add git curl nodejs
# Start docker
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
- name: Registry FQDN Setup
id: registry
run: |
registry=${{ github.server_url }}
echo "registry=${registry##http*://}" >> "$GITHUB_OUTPUT"
- name: Container Registry Login
uses: docker/login-action@v2
with:
registry: ${{ steps.registry.outputs.registry }}
username: ${{ gitea.actor }}
password: ${{ secrets.PKG_WRITE_TOKEN }}
- name: Build Docker Manifest
run: |
docker manifest create ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }} \
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-x86_64 \
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-arm64
docker manifest push --purge ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}
test:
strategy:
matrix:
arch:
- x86_64
# arm64
name: Build Docker Test Image
runs-on: docker-${{ matrix.arch }}
container:
image: docker:dind
privileged: true
env:
ARCH: ${{ matrix.arch }}
VERSIONARCH: ${{ env.VERSION }}-test-${{ env.ARCH }}
needs: [manifest]
steps:
- name: Environment Setup
run: |
# If we have a proxy use it
if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# Some pre-reqs
apk add git curl nodejs
# Start docker
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
## Some debugging info
# docker info && docker version
# env|sort
- name: Registry FQDN Setup
id: registry
run: |
registry=${{ github.server_url }}
echo "registry=${registry##http*://}" >> "$GITHUB_OUTPUT"
- name: Container Registry Login
uses: docker/login-action@v2
with:
registry: ${{ steps.registry.outputs.registry }}
username: ${{ gitea.actor }}
password: ${{ secrets.PKG_WRITE_TOKEN }}
- name: Code Checkout
uses: actions/checkout@v4
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.phptest
push: true
tags: "${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSIONARCH }}"
manifest-test:
name: Final Docker Test Image Manifest
runs-on: docker-x86_64
container:
image: docker:dind
privileged: true
needs: [test]
steps:
- name: Environment Setup
run: |
# If we have a proxy use it
if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# Some pre-reqs
apk add git curl nodejs
# Start docker
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
- name: Registry FQDN Setup
id: registry
run: |
registry=${{ github.server_url }}
echo "registry=${registry##http*://}" >> "$GITHUB_OUTPUT"
- name: Container Registry Login
uses: docker/login-action@v2
with:
registry: ${{ steps.registry.outputs.registry }}
username: ${{ gitea.actor }}
password: ${{ secrets.PKG_WRITE_TOKEN }}
- name: Build Docker Manifest
run: |
docker manifest create ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-test \
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-test-x86_64
#${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-test-arm64
docker manifest push --purge ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-test

View File

@ -1,48 +0,0 @@
image: docker:latest
stages:
- build
- build-test
variables:
BRANCH: latest
VERSION: 8.0-fpm-${BRANCH}
CACHETAG: build-${BRANCH}
DOCKER_HOST: tcp://docker:2375
services:
- docker:dind
before_script:
- docker info
- docker version
- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
x86_64:build:
stage: build
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -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=image ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
- apk add curl && curl -LX POST --post301 -F token=${TRIGGER_TOKEN} -F ref=server ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/trigger/pipeline
tags:
- docker
- x86_64
only:
- master
x86_64:build-test:
stage: build-test
script:
- if [ -f init ]; then chmod 500 init; fi
- ([ -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
- x86_64
only:
- master

View File

@ -1,66 +0,0 @@
# NAME leenooks/php
# VERSION 8.0-fpm-latest
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 \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN useradd -c "Hosting Admin User" -u 1000 -g users -G www-data -d /var/www/html -M lamp
RUN sed -e 's/^expose_php = On/expose_php = Off/' /usr/local/etc/php/php.ini-production > /usr/local/etc/php/php.ini
COPY www.conf /usr/local/etc/php-fpm.d/
COPY nginx-app.conf /etc/nginx/conf.d/
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 && sed -i -e 's#^memory_limit = 128M#memory_limit = 256M#' /usr/local/etc/php/php.ini
EXPOSE 22/tcp
# Add composer
RUN curl https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer
# Add Mongo DB
RUN pecl install mongodb && docker-php-ext-enable mongodb \
&& rm -rf /tmp/*
# Mysql/Postgress/LDAP
RUN apt-get update && apt-get install -y openssh-server libpq5 libpq-dev unzip git libldap2-dev \
&& docker-php-ext-install -j$(nproc) pdo_mysql pdo_pgsql ldap gettext \
&& apt-get -y purge libpq-dev libldap2-dev libx11-6 dbus ncurses-term systemd \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Enable phpredis
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/*
# Enable ZIP
RUN apt-get -y update \
&& apt-get -y install build-essential libzip4 libzip-dev libpng16-16 libpng-dev libbz2-dev zlib1g-dev libgmp-dev libjpeg62-turbo libjpeg-dev libfreetype6 libfreetype6-dev --no-install-recommends \
&& docker-php-ext-configure gd --with-freetype=/usr/include/freetype2 --with-jpeg=/usr/include/ \
&& docker-php-ext-install -j$(nproc) zip bz2 gd \
&& apt-get purge -y build-essential libzip-dev zlib1g-dev libpng-dev libbz2-dev zlib1g-dev libgmp-dev libjpeg-dev libfreetype6-dev \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* /tmp/*
COPY init /sbin/
RUN chmod 550 /sbin/init && chown 0:0 /sbin/init
ENTRYPOINT [ "/sbin/init" ]
CMD [ "php-fpm" ]

View File

@ -1,12 +0,0 @@
# NAME leenooks/php
# VERSION 8.0-fpm-test
FROM registry.leenooks.net/leenooks/php:8.0-fpm-mp
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
RUN apt-get update && apt-get install -y npm \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

61
docker/Dockerfile Normal file
View File

@ -0,0 +1,61 @@
# NAME docker/php
# VERSION 8.3-fpm-alpine
FROM php:8.3-fpm-alpine
# Change to http respositories, so they we can cache the install packages
RUN if [ -n ${HTTP_PROXY} ] ; then sed -i -e s'/https/http/' /etc/apk/repositories; fi
COPY docker/pecl_install /usr/local/bin/pecl_install
# Tune PHP
RUN sed -e 's/^expose_php = On/expose_php = Off/' /usr/local/etc/php/php.ini-production > /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
RUN sed -i -e 's#^memory_limit = 128M#memory_limit = 256M#' /usr/local/etc/php/php.ini
RUN adduser -g "Hosting Admin User" -u 1000 -G www-data -h /var/www/html -HD lamp
# Base
RUN apk add --no-cache bash unzip zlib nginx msmtp
RUN curl -SLo /usr/local/bin/wait-for-it https://github.com/vishnubob/wait-for-it/raw/master/wait-for-it.sh && chmod +x /usr/local/bin/wait-for-it
# Memcache
RUN apk add --no-cache memcached libmemcached pkgconfig zlib-dev memcached-dev libmemcached-dev && \
pecl_install igbinary msgpack memcached && \
mkdir /run/memcached && chown memcached:memcached /run/memcached && \
apk del --no-cache pkgconfig zlib-dev memcached-dev libmemcached-dev
# Enable ZIP BZIP2
RUN apk add --no-cache libzip libzip-dev zlib-dev && \
docker-php-ext-install -j$(nproc) zip bz2 && \
apk del --no-cache libzip-dev zlib-dev
# Add zstd
RUN pecl_install zstd
# Add GD
RUN apk add --no-cache libjpeg libgd libpng freetype freetype-dev zlib-dev libpng-dev jpeg-dev && \
docker-php-ext-configure gd --with-freetype=/usr/include/freetype2 --with-jpeg=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd && \
apk del --no-cache zlib-dev libpng-dev jpeg-dev freetype-dev
# Add intl
RUN apk add --no-cache icu icu-dev && \
docker-php-ext-install -j$(nproc) intl && \
apk del --no-cache icu-dev
# Add composer
RUN curl -4 https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer
ENV COMPOSER_HOME=/var/cache/composer
# Other config
COPY msmtprc /etc/
COPY docker/www.conf /usr/local/etc/php-fpm.d/
COPY docker/nginx-app.conf /etc/nginx/http.d/default.conf
COPY docker/init /sbin/
RUN chmod 550 /sbin/init && chown 0:0 /sbin/init
VOLUME [ "/var/cache/composer" ]
WORKDIR /var/www/html
EXPOSE 80
ENTRYPOINT [ "/sbin/init" ]
CMD [ "php-fpm" ]

View File

@ -0,0 +1,9 @@
# NAME docker/php
# VERSION 8.3-fpm-test
FROM gitea.dege.au/docker/php:8.3-fpm
# Add xdebug
RUN apk --no-cache add linux-headers \
&& pecl_install xdebug \
&& apk --no-cache del linux-headers

182
docker/init Executable file
View File

@ -0,0 +1,182 @@
#!/bin/bash
set -e
role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}
php=${PHP_DIR:-/var/www/html}
composer=${COMPOSER_HOME:-/var/cache/composer}
SITE_USER=${SITE_USER:-www-data}
NGINX_START=${NGINX_START:-TRUE}
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
mountpoint -q $1
local mp=$?
set -e
echo ${mp}
}
function nginx_start() {
# Start NGINX
if [ -x /usr/sbin/nginx -a "${NGINX_START}" == "TRUE" ]; then
echo "* Starting NGINX..."
/usr/sbin/nginx -g 'daemon on; master_process on;'
fi
}
function wait_for_db() {
# Wait for DB to be active
if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
sleep 1;
done
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
fi
}
# Run any container setup
[ -x /sbin/init-container ] && /sbin/init-container
# General Setup
if [ -x /usr/bin/memcached -a "${MEMCACHED_START}" == "TRUE" ]; then
echo "* Starting MEMCACHED..."
/usr/bin/memcached -d -P /run/memcached/memcached.pid -u memcached
fi
# Laravel Specific
if [ -r artisan -a -e ${php}/.env ]; then
mp=$(mp ${php})
# Only adjust perms if this is an external mountpoint
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; 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 a+rx ${php}/artisan
chown -R ${SITE_USER}: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
fi
fi
# 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}" != "local" ]; then
NODEV="--no-dev"
fi
mp=$(mp ${composer})
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
[ -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}" != "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}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
fi
if [ -e .lumen ]; then
echo "* Lumen detected, not caching configuration..."
else
# We only check for non mount points, in case this container has the app inside
mp=$(mp ${php})
if [ ${mp} -eq 1 ]; then
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan optimize)"
fi
fi
if [ "${role}" = "app" ]; then
if [ "${env}" != "local" ]; then
if [ -z "${IGNORE_MIGRATION}" ]; then
if [ -r .migrate ]; then
echo "* Running migration..."
# If DB_HOST not set, source the env file
[ -z "${DB_HOST}" -a -r .env ] && . .env
wait_for_db
su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate
fi
else
[ -r .migrate ] && echo "! NOTE: Migration ignored due to IGNORE_MIGRATION"
fi
# If passport is installed
if [ -d ${php}/vendor/laravel/passport ]; then
echo "* Generating OAUTH keys ..."
set +e
su www-data -s /bin/sh -c "php artisan passport:keys"
set -e
fi
fi
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
set +e
[ -x init-php.sh ] && su www-data -s /bin/bash "init-php.sh" &
exec /usr/local/bin/docker-php-entrypoint "$@"
elif [ "$role" = "queue" ]; then
QUEUE_CMD=work
if [ "${env}" == "local" ]; then
QUEUE_CMD=listen
fi
echo "* Running the queue..."
# We'll delay starting in case the app is caching
sleep 15
wait_for_db
su www-data -s /bin/sh -c "
while true; do
php ${PHP_OPTIONS} artisan queue:${QUEUE_CMD} --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} ${WORK_QUEUES:+--queue=${WORK_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}
done
"
elif [ "$role" = "scheduler" ]; then
echo "* Running the scheduler..."
# We'll delay starting in case the app is caching
sleep 15
su www-data -s /bin/sh -c "
while true; do
php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction
done
"
fi
else
nginx_start
echo "? NO container role \"${role}\", AND/OR no laravel install, just starting php-fpm"
exec /usr/local/bin/docker-php-entrypoint "$@"
fi

View File

@ -3,9 +3,14 @@ server {
listen [::]:80 default_server;
access_log off;
client_max_body_size 10m;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 16k;
client_max_body_size 64m;
error_log /dev/stdout info;
fastcgi_buffering off;
fastcgi_request_buffering off;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/javascript;
index index.php index.html;
root /var/www/html/public;
server_tokens off;
@ -24,11 +29,15 @@ server {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param HTTPS $my_https;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $host;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS $my_https;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path=/usr/sbin/sendmail -i -t";
fastcgi_read_timeout 600s;
fastcgi_send_timeout 600s;
}
}

16
docker/pecl_install Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
# This will install our PHP modules
# call peck-install module1 module2
# First install some dependancies
apk add --no-cache autoconf gcc libc-dev make
# Install the modules
for module in $@; do
pecl install -o -f ${module} && docker-php-ext-enable ${module}
done
# Clean up
rm -rf /tmp/pear
apk del --no-cache autoconf gcc libc-dev make

View File

@ -7,3 +7,6 @@ pm.max_spare_servers = 10
pm.min_spare_servers = 5
pm.start_servers = 10
user = www-data
prefix = /var/www/html
php_admin_value[memory_limit] = 512M
php_admin_value[max_execution_time] = 300

206
init
View File

@ -1,206 +0,0 @@
#!/bin/bash
set -e
role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-live}
php=${PHP_DIR:-/var/www/html}
composer=${COMPOSER_DIR:-/var/www/.composer}
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
mountpoint -q $1
local mp=$?
set -e
echo ${mp}
}
function nginx_start() {
# Start NGINX
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
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
echo "! ERROR: NO .env file..."
exec /bin/bash
fi
mp=$(mp ${php})
# Only adjust perms if this is an external mountpoint
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; 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 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
fi
fi
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}" != "local" ]; then
NODEV="--no-dev"
fi
mp=$(mp ${composer})
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
[ -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}" != "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}" != "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 optimize && php artisan view:cache)"
fi
if [ -r .migrate ]; then
echo "* Running migration..."
# If DB_HOST not set, source the env file
[ -z "${DB_HOST}" -a -r .env ] && . .env
if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
sleep 1;
done
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
fi
su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate
fi
# If passport is installed
if [ -d ${php}/vendor/laravel/passport ]; then
echo "* Generating OAUTH keys ..."
su www-data -s /bin/sh -c "php artisan passport:keys"
fi
fi
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
if [ ! -e ${php}/.env ]; then
echo "! ERROR: NO .env file..."
exec /bin/bash
fi
QUEUE_CMD=work
if [ "${env}" == "local" ]; then
QUEUE_CMD=listen
fi
if [ -e .lumen ]; then
echo "* Lumen detected..."
else
# We only check for non mount points, in case this container has the app inside
mp=$(mp ${php})
if [ ${mp} -eq 1 ]; then
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan config:cache && php artisan route:cache && php artisan view:cache)"
fi
fi
echo "* Running the queue..."
# We'll delay starting in case the app is caching
sleep 15
su www-data -s /bin/sh -c "
while true; do
php ${PHP_OPTIONS} artisan queue:${QUEUE_CMD} --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} ${WORK_QUEUES:+--queue=${WORK_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}
done
"
elif [ "$role" = "scheduler" -a -e artisan ]; then
if [ ! -e ${php}/.env ]; then
echo "! ERROR: NO .env file..."
exec /bin/bash
fi
if [ -e .lumen ]; then
echo "* Lumen detected..."
else
# We only check for non mount points, in case this container has the app inside
mp=$(mp ${php})
if [ ${mp} -eq 1 ]; then
echo "* Caching configuration..."
su www-data -s /bin/sh -c "(php artisan config:cache && php artisan route:cache && php artisan view:cache)"
fi
fi
echo "* Running the scheduler..."
# We'll delay starting in case the app is caching
sleep 15
su www-data -s /bin/sh -c "
while true; do
(php ${PHP_OPTIONS} artisan schedule:run --verbose --no-interaction &)
sleep 60
done
"
else
nginx_start
echo "? NO container role \"${role}\", AND/OR no laravel install, just starting php-fpm"
exec /usr/local/bin/docker-php-entrypoint "$@"
fi

16
msmtprc
View File

@ -1,18 +1,26 @@
# A system wide configuration file is optional.
defaults
port 25
tls off
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default
# Authentication
auth off
# The SMTP smarthost
host smtp
# Envelope-from address
#from user@example.com
domain example.com
from nobody@%H
# Sets the argument of the SMTP EHLO
domain web
# Construct envelope-from addresses of the form "user@oursite.example"
#auto_from on
#maildomain example.com
#allow_from_override on
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL

View File

@ -1,18 +0,0 @@
--- /etc/ssh/sshd_config.orig 2018-02-27 08:33:29.613104521 +0000
+++ /etc/ssh/sshd_config 2018-02-27 08:34:43.413485512 +0000
@@ -30,6 +30,7 @@
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
+PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
@@ -54,6 +55,7 @@
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
+PasswordAuthentication no
#PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with