Created
March 4, 2025 18:13
-
-
Save StuMason/9e12fd7d726467e1f0889122347cd9c5 to your computer and use it in GitHub Desktop.
forge to coolify nixpack.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[phases.setup] | |
nixPkgs = ["...", "python311Packages.supervisor", "php82Extensions.redis"] | |
[phases.build] | |
cmds = [ | |
# Create required directories in one command | |
"mkdir -p /var/log /app/storage/framework/{views,cache,sessions} /app/bootstrap/cache /etc/supervisor/conf.d", | |
# Set permissions in a single command | |
"chown -R www-data:www-data /var/log /app/storage /app/bootstrap/cache", | |
# Copy and setup config files | |
"cp /assets/{worker-*.conf,supervisord.conf} /etc/supervisor/conf.d/ && chmod +x /assets/start.sh" | |
] | |
[phases.postbuild] | |
cmds = [ | |
"php artisan migrate --force", | |
"npm run build", | |
"php artisan view:clear", | |
"php artisan cache:clear", | |
] | |
dependsOn = ["build"] | |
[start] | |
cmd = '/assets/start.sh' | |
[staticAssets] | |
"start.sh" = ''' | |
#!/bin/bash | |
# Transform the nginx configuration | |
node /assets/scripts/prestart.mjs /assets/nginx.template.conf /etc/nginx.conf | |
# Start supervisor | |
supervisord -c /etc/supervisord.conf -n | |
''' | |
"supervisord.conf" = ''' | |
[unix_http_server] | |
file=/assets/supervisor.sock | |
[supervisord] | |
logfile=/var/log/supervisord.log | |
logfile_maxbytes=50MB | |
logfile_backups=10 | |
loglevel=info | |
pidfile=/assets/supervisord.pid | |
nodaemon=false | |
silent=false | |
minfds=1024 | |
minprocs=200 | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:///assets/supervisor.sock | |
[include] | |
files = /etc/supervisor/conf.d/*.conf | |
''' | |
"worker-nginx.conf" = ''' | |
[program:worker-nginx] | |
process_name=%(program_name)s_%(process_num)02d | |
command=nginx -c /etc/nginx.conf | |
autostart=true | |
autorestart=true | |
stdout_logfile=/var/log/worker-nginx.log | |
stderr_logfile=/var/log/worker-nginx.log | |
''' | |
"worker-phpfpm.conf" = ''' | |
[program:worker-phpfpm] | |
process_name=%(program_name)s_%(process_num)02d | |
command=php-fpm -y /assets/php-fpm.conf -F | |
autostart=true | |
autorestart=true | |
stdout_logfile=/var/log/worker-phpfpm.log | |
stderr_logfile=/var/log/worker-phpfpm.log | |
''' | |
"worker-laravel.conf" = ''' | |
[program:worker-laravel] | |
process_name=%(program_name)s_%(process_num)02d | |
command=bash -c 'exec php /app/artisan queue:work --sleep=3 --tries=3 --max-time=3600' | |
autostart=true | |
autorestart=true | |
stopasgroup=true | |
killasgroup=true | |
numprocs=12 | |
startsecs=0 | |
stopwaitsecs=3600 | |
stdout_logfile=/var/log/worker-laravel.log | |
stderr_logfile=/var/log/worker-laravel.log | |
''' | |
"php-fpm.conf" = ''' | |
[www] | |
listen = 127.0.0.1:9000 | |
user = www-data | |
group = www-data | |
listen.owner = www-data | |
listen.group = www-data | |
pm = dynamic | |
pm.max_children = 50 | |
pm.min_spare_servers = 4 | |
pm.max_spare_servers = 32 | |
pm.start_servers = 18 | |
clear_env = no | |
''' | |
"nginx.template.conf" = ''' | |
user www-data www-data; | |
worker_processes 5; | |
daemon off; | |
worker_rlimit_nofile 8192; | |
events { | |
worker_connections 4096; # Default: 1024 | |
} | |
http { | |
include $!{nginx}/conf/mime.types; | |
index index.html index.htm index.php; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] $status ' | |
'"$request" $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx-access.log; | |
error_log /var/log/nginx-error.log; | |
sendfile on; | |
tcp_nopush on; | |
server_names_hash_bucket_size 128; # this seems to be required for some vhosts | |
server { | |
listen ${PORT}; | |
listen [::]:${PORT}; | |
server_name domain.com _; | |
root /app/public; | |
index index.php; | |
charset utf-8; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
include $!{nginx}/conf/fastcgi_params; | |
include $!{nginx}/conf/fastcgi.conf; | |
fastcgi_buffering off; | |
fastcgi_read_timeout 300; | |
} | |
location ~ /\.(?!well-known).* { | |
deny all; | |
} | |
} | |
} | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment