diff --git a/node/build/Dockerfile b/node/build/Dockerfile new file mode 100644 index 0000000..2518e28 --- /dev/null +++ b/node/build/Dockerfile @@ -0,0 +1,13 @@ +FROM node:10.8.0-alpine + +LABEL maintainer="joblocal GmbH " + +RUN apk add --update python3 \ + curl \ + bash \ + && rm -rf /var/cache/apk/* + +RUN curl -O https://bootstrap.pypa.io/get-pip.py \ + && python3 get-pip.py \ + && pip install --upgrade pip \ + && pip install awscli --upgrade diff --git a/php/app/Dockerfile b/php/app/Dockerfile new file mode 100644 index 0000000..84c11f2 --- /dev/null +++ b/php/app/Dockerfile @@ -0,0 +1,45 @@ +FROM alpine:3.7 + +LABEL maintainer="joblocal GmbH " + +ENV \ + DEPS="ca-certificates \ + nginx \ + nginx-mod-http-headers-more \ + memcached \ + php7 \ + php7-fpm \ + php7-curl \ + php7-ctype \ + php7-dom \ + php7-memcached \ + php7-mbstring \ + php7-json \ + php7-xml \ + php7-pdo_mysql \ + php7-pdo_sqlite \ + php7-simplexml \ + runit \ + bash" + +RUN addgroup -g 1000 -S www-data \ + && adduser -u 1000 -D -S -G www-data www-data + +RUN apk add --update $DEPS \ + && rm -rf /var/cache/apk/* \ + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log + + +# Set Timezone to UTC and remove apk cache +RUN apk add --update tzdata \ + && cp /usr/share/zoneinfo/UTC /etc/localtime \ + && echo "UTC" > /etc/timezone \ + && apk del tzdata \ + && rm -rf /var/cache/apk/* + +COPY ./rootfs / + +EXPOSE 80 + +CMD ["/sbin/runit-wrapper"] diff --git a/php/app/rootfs/etc/nginx/conf.d/default.conf b/php/app/rootfs/etc/nginx/conf.d/default.conf new file mode 100644 index 0000000..23369d1 --- /dev/null +++ b/php/app/rootfs/etc/nginx/conf.d/default.conf @@ -0,0 +1,37 @@ +server { + listen 80 default_server; + + charset utf-8; + + root /var/www/public; + index index.php index.html; + + location = /ping { + access_log off; + log_not_found off; + + try_files $uri /index.php =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/var/run/php-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location / { + # remove trailing slash + rewrite ^/(.*)/$ /$1 permanent; + + # try to find requested file + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/var/run/php-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/php/app/rootfs/etc/nginx/nginx.conf b/php/app/rootfs/etc/nginx/nginx.conf new file mode 100644 index 0000000..60fe7ab --- /dev/null +++ b/php/app/rootfs/etc/nginx/nginx.conf @@ -0,0 +1,66 @@ +daemon off; +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + variables_hash_max_size 2048; + variables_hash_bucket_size 1024; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + gzip_disable "msie6"; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} diff --git a/php/app/rootfs/etc/php7/conf.d/custom_config.ini b/php/app/rootfs/etc/php7/conf.d/custom_config.ini new file mode 100644 index 0000000..a3f2376 --- /dev/null +++ b/php/app/rootfs/etc/php7/conf.d/custom_config.ini @@ -0,0 +1 @@ +expose_php = Off diff --git a/php/app/rootfs/etc/php7/mods-available/memcached.ini b/php/app/rootfs/etc/php7/mods-available/memcached.ini new file mode 100644 index 0000000..11a613a --- /dev/null +++ b/php/app/rootfs/etc/php7/mods-available/memcached.ini @@ -0,0 +1 @@ +extension=memcached.so \ No newline at end of file diff --git a/php/app/rootfs/etc/php7/php-fpm.conf b/php/app/rootfs/etc/php7/php-fpm.conf new file mode 100644 index 0000000..0dced7b --- /dev/null +++ b/php/app/rootfs/etc/php7/php-fpm.conf @@ -0,0 +1,49 @@ +[global] +pid = /var/run/php-fpm.pid +error_log = /proc/self/fd/2 +daemonize = no +emergency_restart_threshold = 10 +emergency_restart_interval = 1m +process_control_timeout = 10s + +[www] +user = www-data +group = www-data +listen = /var/run/php-fpm.sock +listen.owner = www-data +listen.group = www-data +listen.allowed_clients = 127.0.0.1 +pm = dynamic +pm.max_children = 35 +pm.start_servers = 15 +pm.min_spare_servers = 15 +pm.max_spare_servers = 25 +pm.max_requests = 500 +chdir = / +catch_workers_output = yes +; access.log = /proc/self/fd/2 +slowlog = /proc/self/fd/2 +request_slowlog_timeout = 30s + +; environment variables +env[APP_ENV]=$APP_ENV +env[APP_DEBUG]=$APP_DEBUG +env[APP_KEY]=$APP_KEY + +env[DB_CONNECTION]=$DB_CONNECTION + +env[CACHE_DRIVER]=$CACHE_DRIVER +env[MEMCACHED_HOST]=$MEMCACHED_HOST +env[MEMCACHED_PORT]=$MEMCACHED_PORT + +env[AWS_ACCESS_KEY_ID]=$AWS_ACCESS_KEY_ID +env[AWS_SECRET_ACCESS_KEY]=$AWS_SECRET_ACCESS_KEY +env[AWS_DEFAULT_REGION]=$AWS_DEFAULT_REGION + +env[QUEUE_DRIVER]=$QUEUE_DRIVER +env[QUEUE_URL]=$QUEUE_URL + +env[GUZZLE_BASE_URI]=$GUZZLE_BASE_URI +env[GUZZLE_TIMEOUT]=$GUZZLE_TIMEOUT + +env[SENTRY_DSN]=$SENTRY_DSN diff --git a/php/app/rootfs/etc/service/nginx/run b/php/app/rootfs/etc/service/nginx/run new file mode 100644 index 0000000..cdd5f97 --- /dev/null +++ b/php/app/rootfs/etc/service/nginx/run @@ -0,0 +1,7 @@ +#!/bin/sh + +exec 2>&1 +source /env + +mkdir -p /run/nginx +exec /usr/sbin/nginx -c '/etc/nginx/nginx.conf' diff --git a/php/app/rootfs/etc/service/php-fpm/run b/php/app/rootfs/etc/service/php-fpm/run new file mode 100644 index 0000000..4579cb1 --- /dev/null +++ b/php/app/rootfs/etc/service/php-fpm/run @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/sbin/php-fpm7 diff --git a/php/app/rootfs/sbin/runit-wrapper b/php/app/rootfs/sbin/runit-wrapper new file mode 100644 index 0000000..6150469 --- /dev/null +++ b/php/app/rootfs/sbin/runit-wrapper @@ -0,0 +1,17 @@ +#!/bin/sh + +main() { + export > /env + + trap onterm SIGTERM SIGINT + + /sbin/runsvdir-start & + wait "$!" +} + +onterm() { + pkill -SIGHUP runsvdir-start + exit $? +} + +main "$@" diff --git a/php/app/rootfs/sbin/runsvdir-start b/php/app/rootfs/sbin/runsvdir-start new file mode 100644 index 0000000..c4399d9 --- /dev/null +++ b/php/app/rootfs/sbin/runsvdir-start @@ -0,0 +1,5 @@ +#!/bin/sh + +export PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin + +exec runsvdir -P /etc/service diff --git a/php/app/rootfs/usr/lib/php/20151012/memcached.so b/php/app/rootfs/usr/lib/php/20151012/memcached.so new file mode 100644 index 0000000..60373ac Binary files /dev/null and b/php/app/rootfs/usr/lib/php/20151012/memcached.so differ diff --git a/php/build/Dockerfile b/php/build/Dockerfile new file mode 100644 index 0000000..0f1fee9 --- /dev/null +++ b/php/build/Dockerfile @@ -0,0 +1,23 @@ +FROM joblocal/base-app:alpine-3.7 + +LABEL maintainer="joblocal GmbH " + +RUN apk add --update \ + curl \ + ghostscript \ + imagemagick \ + php7-apcu \ + php7-fileinfo \ + php7-iconv \ + php7-imagick \ + php7-opcache \ + php7-phar \ + php7-simplexml \ + php7-tokenizer \ + php7-xsl \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ + && rm -rf /var/cache/apk/* + +WORKDIR /workspace + +VOLUME /workspace diff --git a/php/worker/Dockerfile b/php/worker/Dockerfile new file mode 100644 index 0000000..4dcb24e --- /dev/null +++ b/php/worker/Dockerfile @@ -0,0 +1,37 @@ +FROM alpine:3.7 + +LABEL maintainer="joblocal GmbH " + +ENV \ + DEPS="ca-certificates \ + memcached \ + php7 \ + php7-curl \ + php7-ctype \ + php7-dom \ + php7-memcached \ + php7-mbstring \ + php7-json \ + php7-xml \ + php7-pdo_mysql \ + php7-pdo_sqlite \ + php7-simplexml \ + runit \ + bash" + +RUN addgroup -g 1000 -S www-data \ + && adduser -u 1000 -D -S -G www-data www-data + +RUN apk add --update $DEPS \ + && rm -rf /var/cache/apk/* + +# Set Timezone to UTC +RUN apk add --update tzdata \ + && cp /usr/share/zoneinfo/UTC /etc/localtime \ + && echo "UTC" > /etc/timezone \ + && apk del tzdata \ + && rm -rf /var/cache/apk/* + +COPY ./rootfs / + +CMD ["/usr/bin/queuelistener.sh"] diff --git a/php/worker/rootfs/etc/php7/mods-available/memcached.ini b/php/worker/rootfs/etc/php7/mods-available/memcached.ini new file mode 100644 index 0000000..11a613a --- /dev/null +++ b/php/worker/rootfs/etc/php7/mods-available/memcached.ini @@ -0,0 +1 @@ +extension=memcached.so \ No newline at end of file diff --git a/php/worker/rootfs/usr/bin/queuelistener.sh b/php/worker/rootfs/usr/bin/queuelistener.sh new file mode 100644 index 0000000..4704b81 --- /dev/null +++ b/php/worker/rootfs/usr/bin/queuelistener.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo "Starting queue listener" +/usr/bin/php /var/www/artisan queue:listen \ + --tries=4 \ + --sleep=0 \ + --timeout=300 \ + --memory=128 diff --git a/php/worker/rootfs/usr/lib/php/20151012/memcached.so b/php/worker/rootfs/usr/lib/php/20151012/memcached.so new file mode 100644 index 0000000..60373ac Binary files /dev/null and b/php/worker/rootfs/usr/lib/php/20151012/memcached.so differ