[Feature] PHP 8.2 and performance improvements (#676)

This commit is contained in:
Alex Justesen
2023-09-05 09:29:14 -04:00
committed by GitHub
parent dc6538d4f2
commit 4e5261f4f0
19 changed files with 55 additions and 164 deletions
+1
View File
@@ -23,3 +23,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
*.postman_collection.json
+6 -1
View File
@@ -4,6 +4,11 @@ APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost
FORCE_HTTPS=false
DASHBOARD_POLLING=60
NOTIFICATION_POLLING=60
RESULTS_POLLING=false
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
@@ -37,4 +42,4 @@ AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
TELEGRAM_BOT_TOKEN=
TELEGRAM_BOT_TOKEN=null
+11 -30
View File
@@ -1,29 +1,15 @@
APP_NAME="Speedtest Tracker"
APP_ENV=production
# A full list of options can be found in the '.env.example' file.
# Application key
# Used for encryption where needed, if a key is not generated run: php artisan key:generate
APP_KEY=
APP_DEBUG=false
# Application URL
# Not used in the URL but effects links in emails and notifications: https://docs.speedtest-tracker.dev/faqs#links-in-emails-dont-point-to-the-correct-url
APP_URL=http://localhost
FORCE_HTTPS=false
LOG_CHANNEL=stderr
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=error
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=speedtest_tracker
DB_USERNAME=
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=database
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
SESSION_DRIVER=database
SESSION_LIFETIME=120
# SMTP mail config
# Only SMTP protocol is supported at this time: https://docs.speedtest-tracker.dev/settings/notifications/mail
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
@@ -33,10 +19,5 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
TELEGRAM_BOT_TOKEN=
# Telegram bot config
TELEGRAM_BOT_TOKEN=null
+4
View File
@@ -5,18 +5,22 @@ A short description of the pull request changes should go here and the sections
## Changelog
### Added
- one
- two
### Changed
- one
- two
### Fixed
- one
- two
### Removed
- one
- two
+11 -9
View File
@@ -1,4 +1,4 @@
FROM serversideup/php:8.1-fpm-nginx
FROM serversideup/php:8.2-fpm-nginx
# Add /config to allowed directory tree
ENV PHP_OPEN_BASEDIR=$WEBUSER_HOME:/config/:/dev/stdout:/tmp
@@ -11,7 +11,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
cron \
htop \
php8.1-pgsql \
php8.2-pgsql \
&& echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
\
# Install Speedtest cli
@@ -25,15 +25,17 @@ RUN apt-get update \
# Copy package configs
COPY --chmod=755 docker/deploy/etc/s6-overlay/ /etc/s6-overlay/
WORKDIR /var/www/html
# Copy app
COPY --chown=webuser:webgroup . /var/www/html
COPY --chown=webuser:webgroup . $WEBUSER_HOME
WORKDIR $WEBUSER_HOME
# Install app dependencies
RUN composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev --no-cache \
&& mkdir -p storage/logs \
&& php artisan optimize:clear \
&& chown -R webuser:webgroup /var/www/html
RUN composer install \
--no-interaction \
--prefer-dist \
--optimize-autoloader \
--no-dev \
--no-cache
VOLUME /config
+1 -1
View File
@@ -16,7 +16,7 @@ return [
|
*/
'name' => env('APP_NAME', 'Laravel'),
'name' => env('APP_NAME', 'Speedtest Tracker'),
/*
|--------------------------------------------------------------------------
+1 -1
View File
@@ -15,7 +15,7 @@ return [
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
'default' => env('BROADCAST_DRIVER', 'log'),
/*
|--------------------------------------------------------------------------
+1 -1
View File
@@ -15,7 +15,7 @@ return [
|
*/
'default' => env('CACHE_DRIVER', 'file'),
'default' => env('CACHE_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
+1 -1
View File
@@ -18,7 +18,7 @@ return [
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
'default' => env('LOG_CHANNEL', 'stderr'),
/*
|--------------------------------------------------------------------------
+1 -1
View File
@@ -18,7 +18,7 @@ return [
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
+4 -4
View File
@@ -2,11 +2,11 @@ version: '3'
services:
laravel.test:
build:
context: ./docker/8.1
context: ./docker/8.2
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: speedtest-tracker-8.1/app
image: speedtest-tracker-8.2/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
@@ -38,7 +38,7 @@ services:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
- './docker/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
@@ -67,7 +67,7 @@ services:
# POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
# volumes:
# - 'sail-pgsql:/var/lib/postgresql/data'
# - './vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql'
# - './docker/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql'
# networks:
# - sail
# healthcheck:
-58
View File
@@ -1,58 +0,0 @@
FROM ubuntu:22.04
LABEL maintainer="Alex Justesen"
ARG WWWGROUP
ARG NODE_VERSION=18
ARG POSTGRES_VERSION=15
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin cron \
&& curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
&& apt-get install -y php8.1-cli php8.1-dev \
php8.1-pgsql php8.1-sqlite3 php8.1-gd \
php8.1-curl \
php8.1-mysql php8.1-mbstring \
php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \
php8.1-intl php8.1-readline \
php8.1-msgpack php8.1-igbinary php8.1-redis \
php8.1-memcached php8.1-pcov php8.1-xdebug \
&& curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client-$POSTGRES_VERSION \
&& curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash \
&& apt-get update \
&& apt-get install -y speedtest \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& echo "MAILTO=\"\"\n* * * * * sail /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]
-7
View File
@@ -1,7 +0,0 @@
[PHP]
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
[opcache]
opcache.enable_cli=1
-17
View File
@@ -1,17 +0,0 @@
#!/usr/bin/env bash
if [ ! -z "$WWWUSER" ]; then
usermod -u $WWWUSER sail
fi
if [ ! -d /.composer ]; then
mkdir /.composer
fi
chmod -R ugo+rw /.composer
if [ $# -gt 0 ]; then
exec gosu $WWWUSER "$@"
else
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
fi
-21
View File
@@ -1,21 +0,0 @@
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
[program:cron]
command=/usr/sbin/cron -f -l 8
user=root
autostart=true
stdout_logfile=/var/log/cron.out.log
stderr_logfile=/var/log/cron.err.log
[program:php]
command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80
user=sail
environment=LARAVEL_SAIL="1"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
+1 -1
View File
@@ -14,7 +14,7 @@ ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin cron \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch cron \
&& curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \
&& echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
@@ -11,7 +11,8 @@ echo ""
echo "🔒 Fixing app path file permissions..."
chmod -R 755 /config
chown -R webuser:webgroup /config
chown -R webuser:webgroup $WEBUSER_HOME
chmod -R 755 $WEBUSER_HOME/storage
chown -R webuser:webgroup $WEBUSER_HOME/storage
echo "✅ Permissions fixed."
echo ""
@@ -51,7 +52,6 @@ echo ""
echo "🔗 Creating symlinks for config and log files..."
symlinks=( \
/var/www/html/.env \
/var/www/html/storage/logs/laravel.log
)
for i in "${symlinks[@]}"
@@ -78,17 +78,10 @@ fi
echo ""
# create storage symlink
echo "🔐 Linking the storage..."
s6-setuidgid webuser php $WEBUSER_HOME/artisan storage:link --no-ansi -q
echo "✅ Storage linked."
echo ""
# Build cache
echo "💰 Building the cache..."
s6-setuidgid webuser php $WEBUSER_HOME/artisan config:cache --no-ansi -q
s6-setuidgid webuser php $WEBUSER_HOME/artisan route:cache --no-ansi -q
s6-setuidgid webuser php $WEBUSER_HOME/artisan view:cache --no-ansi -q
s6-setuidgid webuser php $WEBUSER_HOME/artisan view:clear --no-ansi -q
s6-setuidgid webuser php $WEBUSER_HOME/artisan optimize --no-ansi -q
echo "✅ Cache set."
echo ""
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
mysql --user=root --password="$MYSQL_ROOT_PASSWORD" <<-EOSQL
CREATE DATABASE IF NOT EXISTS testing;
GRANT ALL PRIVILEGES ON \`testing%\`.* TO '$MYSQL_USER'@'%';
EOSQL
+2
View File
@@ -0,0 +1,2 @@
SELECT 'CREATE DATABASE testing'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'testing')\gexec