Skip to content

Commit

Permalink
[Feature] PHP 8.2 and performance improvements (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen authored Sep 5, 2023
1 parent dc6538d commit 4e5261f
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 164 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
*.postman_collection.json
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
41 changes: 11 additions & 30 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
APP_NAME="Speedtest Tracker"
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost

FORCE_HTTPS=false

LOG_CHANNEL=stderr
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=error
# A full list of options can be found in the '.env.example' file.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=speedtest_tracker
DB_USERNAME=
DB_PASSWORD=
# Application key
# Used for encryption where needed, if a key is not generated run: php artisan key:generate
APP_KEY=

BROADCAST_DRIVER=log
CACHE_DRIVER=database
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
SESSION_DRIVER=database
SESSION_LIFETIME=120
# 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

# 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
Expand All @@ -33,10 +19,5 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
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 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
|
*/

'name' => env('APP_NAME', 'Laravel'),
'name' => env('APP_NAME', 'Speedtest Tracker'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/broadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
|
*/

'default' => env('BROADCAST_DRIVER', 'null'),
'default' => env('BROADCAST_DRIVER', 'log'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
|
*/

'default' => env('CACHE_DRIVER', 'file'),
'default' => env('CACHE_DRIVER', 'database'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
|
*/

'default' => env('LOG_CHANNEL', 'stack'),
'default' => env('LOG_CHANNEL', 'stderr'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
|
*/

'driver' => env('SESSION_DRIVER', 'file'),
'driver' => env('SESSION_DRIVER', 'database'),

/*
|--------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
58 changes: 0 additions & 58 deletions docker/8.1/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions docker/8.1/php.ini

This file was deleted.

17 changes: 0 additions & 17 deletions docker/8.1/start-container

This file was deleted.

21 changes: 0 additions & 21 deletions docker/8.1/supervisord.conf

This file was deleted.

2 changes: 1 addition & 1 deletion docker/8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
15 changes: 4 additions & 11 deletions docker/deploy/etc/s6-overlay/scripts/laravel-automations
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down Expand Up @@ -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[@]}"
Expand All @@ -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 ""

Expand Down
6 changes: 6 additions & 0 deletions docker/mysql/create-testing-database.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions docker/pgsql/create-testing-database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT 'CREATE DATABASE testing'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'testing')\gexec

0 comments on commit 4e5261f

Please sign in to comment.