Skip to content

Commit 832b37a

Browse files
Docker, CircleCI, GitHub Actions
1 parent c019d2f commit 832b37a

24 files changed

+946
-0
lines changed

.circleci/config.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# PHP CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-php/ for more details
4+
#
5+
version: 2
6+
machine:
7+
# Override /etc/hosts
8+
hosts:
9+
localhost: 127.0.0.1
10+
jobs:
11+
build:
12+
docker:
13+
# Specify the version you desire here
14+
- image: cimg/php:8.3.3
15+
environment:
16+
working_directory: ~/genealogy
17+
DB_CONNECTION: mysql
18+
DB_HOST: 127.0.0.1
19+
DB_PORT: 3306
20+
21+
# Specify service dependencies here if necessary
22+
# CircleCI maintains a library of pre-built images
23+
# documented at https://circleci.com/docs/2.0/circleci-images/
24+
# Using the RAM variation mitigates I/O contention
25+
# for database intensive operations.
26+
- image: circleci/mysql:latest-ram
27+
# command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --innodb-large-prefix=true --innodb-file-format=Barracuda
28+
command: mysqld
29+
environment:
30+
MYSQL_USER: liberu
31+
MYSQL_PASSWORD: password
32+
MYSQL_ALLOW_EMPTY_PASSWORD: true
33+
MYSQL_ROOT_HOST: "%"
34+
DB_HOST: 127.0.0.1
35+
DB_PORT: 3306
36+
working_directory: ~/genealogy
37+
# - image: redis:2.8.19
38+
steps:
39+
- checkout
40+
#- setup_remote_docker:
41+
# docker_layer_caching: true
42+
# - run: docker-build
43+
- run: sudo apt-get update
44+
- run: sudo apt-get install lsb-release
45+
- run: sudo apt update # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev
46+
- run: sudo apt install -y default-mysql-client libxml2-dev libpng-dev
47+
libfreetype6-dev libpng-dev libjpeg-dev libjpeg-turbo8-dev libzip-dev
48+
#- run: sudo docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
49+
- run: sudo docker-php-ext-configure gd --with-freetype --with-jpeg
50+
- run: sudo docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd
51+
- run: sudo docker-php-ext-install zip pdo_mysql bcmath pcntl soap gd
52+
53+
#- run: pecl install xdebug && docker-php-ext-enable xdebug
54+
# - run: docker-php-ext-enable xdebug
55+
56+
# Download and cache dependencies
57+
- restore_cache:
58+
keys:
59+
# "composer.lock" can be used if it is committed to the repo
60+
- v1-dependencies-{{ checksum "composer.json" }}
61+
# fallback to using the latest cache if no exact match is found
62+
- v1-dependencies-
63+
- run: composer clearcache
64+
- run: sudo composer selfupdate
65+
- run: composer install -n --prefer-dist
66+
- save_cache:
67+
key: v1-dependencies-{{ checksum "composer.json" }}
68+
paths:
69+
- ./vendor
70+
- run:
71+
name: Mysql database
72+
command: mysql -h 127.0.0.1 -u root -e "create database liberu;"
73+
# - run: sudo echo "localhost 127.0.0.1" >> /etc/hosts
74+
- run: cp .env.testing .env
75+
- run: php artisan key:generate
76+
- run: php artisan migrate --seed
77+
- run: mkdir -p build/logs
78+
# - run: php artisan test
79+
- run: vendor/bin/phpunit
80+
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
81+
resource_class: large
82+
83+
# - run: mkdir -p ~/phpunit
84+
# - run: vendor/bin/phpunit --log-junit ~/phpunit/junit.xml tests
85+
# store_test_results:
86+
# path: ~/phpunit

.docker/octane/.rr.prod.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '2.7'
2+
rpc:
3+
listen: 'tcp://127.0.0.1:6001'
4+
http:
5+
middleware: [ "static", "gzip", "headers" ]
6+
max_request_size: 20
7+
static:
8+
dir: "public"
9+
forbid: [ ".php", ".htaccess" ]
10+
uploads:
11+
forbid: [".php", ".exe", ".bat", ".sh"]
12+
pool:
13+
allocate_timeout: 10s
14+
destroy_timeout: 10s
15+
supervisor:
16+
max_worker_memory: 128
17+
exec_ttl: 60s
18+
logs:
19+
mode: production
20+
level: debug
21+
encoding: json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=%(ENV_USER)s
4+
logfile=/var/log/supervisor/supervisord.log
5+
pidfile=/var/run/supervisord.pid
6+
7+
[program:octane]
8+
process_name=%(program_name)s_%(process_num)02d
9+
command=php %(ENV_ROOT)s/artisan octane:start --server=frankenphp --host=0.0.0.0 --port=80 --admin-port=2019
10+
user=%(ENV_USER)s
11+
autostart=true
12+
autorestart=true
13+
environment=LARAVEL_OCTANE="1"
14+
stdout_logfile=/dev/stdout
15+
stdout_logfile_maxbytes=0
16+
stderr_logfile=/dev/stderr
17+
stderr_logfile_maxbytes=0
18+
19+
[program:horizon]
20+
process_name=%(program_name)s_%(process_num)02d
21+
command=php %(ENV_ROOT)s/artisan horizon
22+
user=%(ENV_USER)s
23+
autostart=%(ENV_WITH_HORIZON)s
24+
autorestart=true
25+
stdout_logfile=%(ENV_ROOT)s/horizon.log
26+
stopwaitsecs=3600
27+
28+
[program:scheduler]
29+
process_name=%(program_name)s_%(process_num)02d
30+
command=supercronic -overlapping /etc/supercronic/laravel
31+
user=%(ENV_USER)s
32+
autostart=%(ENV_WITH_SCHEDULER)s
33+
autorestart=true
34+
stdout_logfile=%(ENV_ROOT)s/scheduler.log
35+
36+
[program:clear-scheduler-cache]
37+
process_name=%(program_name)s_%(process_num)02d
38+
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
39+
user=%(ENV_USER)s
40+
autostart=%(ENV_WITH_SCHEDULER)s
41+
autorestart=false
42+
stdout_logfile=%(ENV_ROOT)s/scheduler.log
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '2.7'
2+
rpc:
3+
listen: 'tcp://127.0.0.1:6001'
4+
server:
5+
relay: pipes
6+
http:
7+
middleware: [ "static", "gzip", "headers" ]
8+
max_request_size: 20
9+
static:
10+
dir: "public"
11+
forbid: [ ".php", ".htaccess" ]
12+
uploads:
13+
forbid: [".php", ".exe", ".bat", ".sh"]
14+
pool:
15+
allocate_timeout: 10s
16+
destroy_timeout: 10s
17+
supervisor:
18+
max_worker_memory: 128
19+
exec_ttl: 60s
20+
logs:
21+
mode: production
22+
level: debug
23+
encoding: json
24+
status:
25+
address: localhost:2114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=%(ENV_USER)s
4+
logfile=/var/log/supervisor/supervisord.log
5+
pidfile=/var/run/supervisord.pid
6+
7+
[program:octane]
8+
process_name=%(program_name)s_%(process_num)02d
9+
command=php %(ENV_ROOT)s/artisan octane:start --server=roadrunner --host=0.0.0.0 --port=80 --rpc-port=6001 --rr-config=%(ENV_ROOT)s/.rr.yaml
10+
user=%(ENV_USER)s
11+
autostart=true
12+
autorestart=true
13+
environment=LARAVEL_OCTANE="1"
14+
stdout_logfile=/dev/stdout
15+
stdout_logfile_maxbytes=0
16+
stderr_logfile=/dev/stderr
17+
stderr_logfile_maxbytes=0
18+
19+
[program:horizon]
20+
process_name=%(program_name)s_%(process_num)02d
21+
command=php %(ENV_ROOT)s/artisan horizon
22+
user=%(ENV_USER)s
23+
autostart=%(ENV_WITH_HORIZON)s
24+
autorestart=true
25+
stdout_logfile=%(ENV_ROOT)s/horizon.log
26+
stopwaitsecs=3600
27+
28+
[program:scheduler]
29+
process_name=%(program_name)s_%(process_num)02d
30+
command=supercronic -overlapping /etc/supercronic/laravel
31+
user=%(ENV_USER)s
32+
autostart=%(ENV_WITH_SCHEDULER)s
33+
autorestart=true
34+
stdout_logfile=%(ENV_ROOT)s/scheduler.log
35+
36+
[program:clear-scheduler-cache]
37+
process_name=%(program_name)s_%(process_num)02d
38+
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
39+
user=%(ENV_USER)s
40+
autostart=%(ENV_WITH_SCHEDULER)s
41+
autorestart=false
42+
stdout_logfile=%(ENV_ROOT)s/scheduler.log
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=%(ENV_USER)s
4+
logfile=/var/log/supervisor/supervisord.log
5+
pidfile=/var/run/supervisord.pid
6+
7+
[program:octane]
8+
process_name=%(program_name)s_%(process_num)02d
9+
command=php %(ENV_ROOT)s/artisan octane:start --server=swoole --host=0.0.0.0 --port=80
10+
user=%(ENV_USER)s
11+
autostart=true
12+
autorestart=true
13+
environment=LARAVEL_OCTANE="1"
14+
stdout_logfile=/dev/stdout
15+
stdout_logfile_maxbytes=0
16+
stderr_logfile=/dev/stderr
17+
stderr_logfile_maxbytes=0
18+
19+
[program:horizon]
20+
process_name=%(program_name)s_%(process_num)02d
21+
command=php %(ENV_ROOT)s/artisan horizon
22+
user=%(ENV_USER)s
23+
autostart=%(ENV_WITH_HORIZON)s
24+
autorestart=true
25+
stdout_logfile=%(ENV_ROOT)s/horizon.log
26+
stopwaitsecs=3600
27+
28+
[program:scheduler]
29+
process_name=%(program_name)s_%(process_num)02d
30+
command=supercronic -overlapping /etc/supercronic/laravel
31+
user=%(ENV_USER)s
32+
autostart=%(ENV_WITH_SCHEDULER)s
33+
autorestart=true
34+
stdout_logfile=%(ENV_ROOT)s/scheduler.log
35+
36+
[program:clear-scheduler-cache]
37+
process_name=%(program_name)s_%(process_num)02d
38+
command=php %(ENV_ROOT)s/artisan schedule:clear-cache
39+
user=%(ENV_USER)s
40+
autostart=%(ENV_WITH_SCHEDULER)s
41+
autorestart=false
42+
stdout_logfile=%(ENV_ROOT)s/scheduler.log

.docker/octane/entrypoint.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
container_mode=${CONTAINER_MODE:-app}
5+
octane_server=${OCTANE_SERVER:-swoole}
6+
echo "Container mode: $container_mode"
7+
8+
php() {
9+
su octane -c "php $*"
10+
}
11+
12+
initialStuff() {
13+
php artisan optimize:clear; \
14+
php artisan package:discover --ansi; \
15+
php artisan event:cache; \
16+
php artisan config:cache; \
17+
php artisan route:cache;
18+
}
19+
20+
if [ "$1" != "" ]; then
21+
exec "$@"
22+
elif [ ${container_mode} = "app" ]; then
23+
echo "Octane server: $octane_server"
24+
initialStuff
25+
if [ ${octane_server} = "swoole" ]; then
26+
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.app.conf
27+
elif [ ${octane_server} = "roadrunner" ]; then
28+
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.app.roadrunner.conf
29+
else
30+
echo "Invalid Octane server supplied."
31+
exit 1
32+
fi
33+
elif [ ${container_mode} = "horizon" ]; then
34+
initialStuff
35+
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.horizon.conf
36+
elif [ ${container_mode} = "scheduler" ]; then
37+
initialStuff
38+
exec supercronic /etc/supercronic/laravel
39+
else
40+
echo "Container mode mismatched."
41+
exit 1
42+
fi

.docker/octane/opcache.ini

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Opcache]
2+
opcache.enable = 1
3+
opcache.enable_cli = 1
4+
opcache.memory_consumption = 256M
5+
opcache.use_cwd = 0
6+
opcache.max_file_size = 0
7+
opcache.max_accelerated_files = 32531
8+
opcache.validate_timestamps = 0
9+
opcache.revalidate_freq = 0
10+
11+
[JIT]
12+
opcache.jit_buffer_size = 100M
13+
opcache.jit = function

.docker/octane/php.ini

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[PHP]
2+
post_max_size = 100M
3+
upload_max_filesize = 100M
4+
expose_php = 0
5+
variables_order = "GPCS"

.docker/octane/supervisord.app.conf

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
logfile=/var/log/supervisor/supervisord.log
5+
pidfile=/var/run/supervisord.pid
6+
7+
[program:octane]
8+
process_name=%(program_name)s_%(process_num)02d
9+
command=php /var/www/html/artisan octane:start --server=swoole --host=0.0.0.0 --port=9000 --workers=auto --task-workers=auto --max-requests=500
10+
user=octane
11+
autostart=true
12+
autorestart=true
13+
environment=LARAVEL_OCTANE="1"
14+
stdout_logfile=/dev/stdout
15+
stdout_logfile_maxbytes=0
16+
stderr_logfile=/dev/stderr
17+
stderr_logfile_maxbytes=0
18+
19+
[program:horizon]
20+
process_name=%(program_name)s_%(process_num)02d
21+
command=php /var/www/html/artisan horizon
22+
user=octane
23+
autostart=%(ENV_APP_WITH_HORIZON)s
24+
autorestart=true
25+
stdout_logfile=/var/www/html/horizon.log
26+
stopwaitsecs=3600
27+
28+
[program:scheduler]
29+
process_name=%(program_name)s_%(process_num)02d
30+
command=supercronic /etc/supercronic/laravel
31+
user=octane
32+
autostart=%(ENV_APP_WITH_SCHEDULER)s
33+
autorestart=true
34+
stdout_logfile=/var/www/html/scheduler.log

0 commit comments

Comments
 (0)