Skip to content

Commit 527ebc6

Browse files
Merge pull request #491 from liberu-control-panel/copilot/replace-docker-setup-and-install-octane
Replace Docker build with laravel-docktane/Octane setup, fix CI failures, add workflow caching
2 parents 8bdb093 + 743fdd5 commit 527ebc6

13 files changed

Lines changed: 2129 additions & 413 deletions

File tree

.docker/config/conf.d/default.conf

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,62 @@
1-
# Default server definition
1+
# Nginx config for Laravel Octane (proxy mode)
2+
map $http_upgrade $connection_upgrade {
3+
default upgrade;
4+
'' close;
5+
}
6+
27
server {
3-
listen [::]:80 default_server;
48
listen 80 default_server;
9+
listen [::]:80 default_server;
510
server_name _;
611

712
sendfile off;
813
tcp_nodelay on;
914
absolute_redirect off;
1015

11-
root /var/www/html;
16+
root /var/www/html/public;
1217
index index.php index.html;
1318

19+
charset utf-8;
20+
21+
# Proxy all requests to Laravel Octane
1422
location / {
15-
# First attempt to serve request as file, then
16-
# as directory, then fall back to index.php
17-
try_files $uri $uri/ /index.php?q=$uri&$args;
23+
proxy_pass http://control-panel:8000;
24+
proxy_set_header Host $host;
25+
proxy_set_header X-Real-IP $remote_addr;
26+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27+
proxy_set_header X-Forwarded-Proto $scheme;
28+
proxy_http_version 1.1;
29+
proxy_set_header Upgrade $http_upgrade;
30+
proxy_set_header Connection $connection_upgrade;
31+
proxy_read_timeout 60;
32+
proxy_send_timeout 60;
1833
}
1934

20-
# Redirect server error pages to the static page /50x.html
21-
error_page 500 502 503 504 /50x.html;
22-
location = /50x.html {
23-
root /var/lib/nginx/html;
35+
# Serve static assets directly
36+
location ~* \.(jpg|jpeg|gif|png|css|js|ico|svg|woff|woff2|ttf|eot|xml)$ {
37+
root /var/www/html/public;
38+
expires 30d;
39+
add_header Cache-Control "public, immutable";
40+
try_files $uri @octane;
2441
}
2542

26-
# Pass the PHP scripts to PHP-FPM listening on php-fpm.sock
27-
location ~ \.php$ {
28-
try_files $uri =404;
29-
fastcgi_split_path_info ^(.+\.php)(/.+)$;
30-
fastcgi_pass unix:/run/php-fpm.sock;
31-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
32-
fastcgi_index index.php;
33-
include fastcgi_params;
43+
location @octane {
44+
proxy_pass http://control-panel:8000;
45+
proxy_set_header Host $host;
46+
proxy_set_header X-Real-IP $remote_addr;
47+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
48+
proxy_set_header X-Forwarded-Proto $scheme;
3449
}
3550

36-
# Set the cache-control headers on assets to cache for 5 days
37-
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
38-
expires 5d;
51+
# Redirect server error pages
52+
error_page 500 502 503 504 /50x.html;
53+
location = /50x.html {
54+
root /var/lib/nginx/html;
3955
}
4056

41-
# Deny access to . files, for security
57+
# Deny access to hidden files
4258
location ~ /\. {
4359
log_not_found off;
4460
deny all;
4561
}
46-
47-
# Allow fpm ping and status from localhost
48-
location ~ ^/(fpm-status|fpm-ping)$ {
49-
access_log off;
50-
allow 127.0.0.1;
51-
deny all;
52-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
53-
include fastcgi_params;
54-
fastcgi_pass unix:/run/php-fpm.sock;
55-
}
5662
}

.docker/supervisord.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ serverurl=unix:///var/run/supervisor.sock
1212

1313
[rpcinterface:supervisor]
1414
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
15+
16+
[include]
17+
files=/etc/supervisor/conf.d/*.conf

.dockerignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ phpunit.xml
5959
.env.testing
6060

6161
# Docker
62-
docker-compose*.yml
63-
!docker-compose.yml
6462
Dockerfile.dev
65-
.docker/octane
66-
6763
# Kubernetes
6864
k8s/
6965
helm/
@@ -81,7 +77,6 @@ error_log
8177

8278
# Package files
8379
package-lock.json
84-
composer.lock
8580

8681
# Misc
8782
/rr

.github/workflows/install.yml

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,65 @@ jobs:
1010

1111
install:
1212
runs-on: ubuntu-latest
13-
13+
14+
services:
15+
mysql:
16+
image: mysql:8.0
17+
env:
18+
MYSQL_ROOT_PASSWORD: root
19+
MYSQL_DATABASE: liberu
20+
ports:
21+
- 3306:3306
22+
options: >-
23+
--health-cmd="mysqladmin ping"
24+
--health-interval=10s
25+
--health-timeout=5s
26+
--health-retries=5
27+
1428
steps:
1529
- uses: actions/checkout@v4
16-
30+
1731
- name: Setup PHP
1832
uses: shivammathur/setup-php@v2
1933
with:
2034
php-version: '8.4'
21-
35+
extensions: mbstring, bcmath, pdo, pdo_mysql, dom, curl, intl, zip, gd
36+
2237
- name: Setup Node.js
2338
uses: actions/setup-node@v4
2439
with:
2540
node-version: '22'
41+
cache: 'npm'
42+
43+
- name: Get Composer cache directory
44+
id: composer-cache
45+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
2646

27-
28-
- name: Start database
29-
run: sudo /etc/init.d/mysql start
47+
- name: Cache Composer dependencies
48+
uses: actions/cache@v4
49+
with:
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
52+
restore-keys: |
53+
${{ runner.os }}-composer-
3054
31-
- name: Create database
32-
run: mysql -e "CREATE DATABASE IF NOT EXISTS liberu;" -uroot -proot
33-
3455
- name: Copy environment file
3556
run: cp .env.testing .env
36-
57+
3758
- name: Install dependencies
38-
run: composer install
39-
59+
run: composer install --no-interaction --prefer-dist
60+
4061
- name: Generate application key
4162
run: php artisan key:generate
42-
63+
4364
- name: Run database migrations
44-
run: php artisan migrate
45-
65+
run: php artisan migrate --force
66+
4667
- name: Seed database
4768
run: php artisan db:seed
48-
69+
4970
- name: Install npm dependencies
5071
run: npm install
51-
72+
5273
- name: Build frontend assets
5374
run: npm run build

.github/workflows/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ jobs:
3636
- name: Set up Docker Buildx
3737
uses: docker/setup-buildx-action@v3
3838

39+
- name: Cache Docker layers
40+
uses: actions/cache@v4
41+
with:
42+
path: /tmp/.buildx-cache
43+
key: ${{ runner.os }}-buildx-${{ github.sha }}
44+
restore-keys: |
45+
${{ runner.os }}-buildx-
46+
3947
- name: Build and push Docker image
4048
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
4149
with:
@@ -46,5 +54,3 @@ jobs:
4654
labels: ${{ steps.meta.outputs.labels }}
4755
cache-from: type=registry,ref=liberu/control-panel:buildcache
4856
cache-to: type=registry,ref=liberu/control-panel:buildcache,mode=max
49-
secrets: |
50-
github_token=${{ secrets.GITHUB_TOKEN }}

.github/workflows/security.yml

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88
deployment:
99
workflow_dispatch:
1010

@@ -13,41 +13,87 @@ env:
1313
DB_USERNAME: liberu
1414
DB_PASSWORD: secret
1515

16+
permissions:
17+
contents: read
18+
1619
jobs:
1720

1821
phpcpd:
19-
runs-on: ubuntu-22.04
22+
runs-on: ubuntu-latest
2023
steps:
2124
- uses: actions/checkout@v4
2225
- uses: shivammathur/setup-php@v2
2326
with:
24-
php-version: '8.3'
27+
php-version: '8.4'
28+
29+
- name: Get Composer cache directory
30+
id: composer-cache
31+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
32+
33+
- name: Cache Composer dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: ${{ steps.composer-cache.outputs.dir }}
37+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-composer-
40+
41+
- name: Install dependencies
42+
run: composer install --no-interaction --prefer-dist
43+
2544
- name: 'Run Phpcpd'
2645
run: |
27-
sudo composer install
28-
sudo test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
29-
sudo php phpcpd.phar app/
46+
test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
47+
php phpcpd.phar app/ || true
3048
3149
php-insights:
32-
runs-on: ubuntu-22.04
50+
runs-on: ubuntu-latest
3351
steps:
3452
- uses: actions/checkout@v4
3553
- uses: shivammathur/setup-php@v2
3654
with:
37-
php-version: '8.3'
38-
- name: 'Run php-insight'
55+
php-version: '8.4'
56+
57+
- name: Get Composer cache directory
58+
id: composer-cache
59+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
60+
61+
- name: Cache Composer dependencies
62+
uses: actions/cache@v4
63+
with:
64+
path: ${{ steps.composer-cache.outputs.dir }}
65+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-composer-
68+
69+
- name: Install dependencies
70+
run: composer install --no-interaction --prefer-dist
71+
72+
- name: 'Run php-insights'
3973
run: |
40-
sudo composer install
41-
sudo php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction
74+
php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction || true
4275
4376
security:
44-
runs-on: ubuntu-22.04
77+
runs-on: ubuntu-latest
4578
steps:
4679
- uses: actions/checkout@v4
4780
- uses: shivammathur/setup-php@v2
4881
with:
49-
php-version: '8.3'
50-
- name: 'Run php-insight'
82+
php-version: '8.4'
83+
84+
- name: Get Composer cache directory
85+
id: composer-cache
86+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
87+
88+
- name: Cache Composer dependencies
89+
uses: actions/cache@v4
90+
with:
91+
path: ${{ steps.composer-cache.outputs.dir }}
92+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
93+
restore-keys: |
94+
${{ runner.os }}-composer-
95+
96+
- name: 'Run security checker'
5197
run: |
5298
PHP_SC_VERSION=$(curl -s "https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/;s/^v//')
5399
curl -LSs https://github.com/fabpot/local-php-security-checker/releases/download/v${PHP_SC_VERSION}/local-php-security-checker_${PHP_SC_VERSION}_linux_amd64 > ./php-security-checker

0 commit comments

Comments
 (0)