Add daily email for 2024-12-09
Running Drupal on devenv
This commit is contained in:
parent
37aee7bf6b
commit
b02ff3c5b0
|
@ -71,6 +71,8 @@ function npm:build:css {
|
|||
args=(--watch)
|
||||
fi
|
||||
|
||||
cd assets || exit
|
||||
|
||||
tailwindcss \
|
||||
--config tailwind.config.ts \
|
||||
--input css/tailwind.css \
|
||||
|
|
102
source/_daily_emails/2024-12-09.md
Normal file
102
source/_daily_emails/2024-12-09.md
Normal file
|
@ -0,0 +1,102 @@
|
|||
---
|
||||
title: Running Drupal on devenv
|
||||
date: 2024-12-09
|
||||
permalink: daily/2024/12/09/drupal-devenv
|
||||
tags:
|
||||
- software-development
|
||||
- drupal
|
||||
- php
|
||||
- nix
|
||||
- devenv
|
||||
cta: ~
|
||||
snippet: |
|
||||
Here's an example of how I'm running Drupal applications locally with Nix and devenv.
|
||||
---
|
||||
|
||||
I recently said that [I've been using devenv to run Drupal applications locally][0].
|
||||
|
||||
Here's the `devenv.nix` file I used for [my recent talk for the Drupal London meetup][1]:
|
||||
|
||||
```nix
|
||||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
drupal.root = "web";
|
||||
in
|
||||
{
|
||||
packages = [ pkgs.git ];
|
||||
|
||||
dotenv.disableHint = true;
|
||||
|
||||
languages = {
|
||||
php = {
|
||||
enable = true;
|
||||
version = "8.2";
|
||||
|
||||
ini = ''
|
||||
memory_limit = 256M
|
||||
'';
|
||||
|
||||
fpm.pools.web = {
|
||||
listen = "127.0.0.1:9000";
|
||||
|
||||
settings = {
|
||||
"pm" = "dynamic";
|
||||
"pm.max_children" = 75;
|
||||
"pm.max_requests" = 500;
|
||||
"pm.max_spare_servers" = 20;
|
||||
"pm.min_spare_servers" = 5;
|
||||
"pm.start_servers" = 10;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
processes = { };
|
||||
|
||||
services = {
|
||||
caddy = {
|
||||
enable = true;
|
||||
|
||||
config = ''
|
||||
{
|
||||
http_port 8080
|
||||
}
|
||||
|
||||
localhost:8080 {
|
||||
root * ${drupal.root}
|
||||
encode gzip
|
||||
php_fastcgi localhost:9000
|
||||
file_server
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
mysql = {
|
||||
enable = true;
|
||||
initialDatabases = [ { name = "drupal_london"; } ];
|
||||
};
|
||||
};
|
||||
|
||||
enterShell = ''
|
||||
if [[ ! -d vendor ]]; then
|
||||
composer install
|
||||
fi
|
||||
'';
|
||||
|
||||
enterTest = ''
|
||||
phpunit --testdox
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
It installs the required version of PHP for this project, creates a web server (Caddy) and configures MariaDB with a default database.
|
||||
|
||||
I've also added commands to run `composer install` to download dependencies when entering the shell and `phpunit` for tests.
|
||||
|
||||
With this approach, there's no need for containers as everything is run locally and I can view the site at <http://localhost:8080> (or whatever port is defined).
|
||||
|
||||
All of my current development projects are using this approach and I think it'll be my default method for future projects.
|
||||
|
||||
[0]: {{site.url}}/daily/2024/11/30/using-nix-for-local-application-development
|
||||
[1]: {{site.url}}/presentations/tdd-test-driven-drupal
|
Loading…
Reference in a new issue