Skip to content

Fix envsubst issues #1462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions examples/servers/nginx/devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@
"lockfile_version": "1",
"packages": {
"nginx@latest": {
"last_modified": "2023-08-30T00:25:28Z",
"last_modified": "2023-09-04T16:24:30Z",
"plugin_version": "0.0.3",
"resolved": "github:NixOS/nixpkgs/a63a64b593dcf2fe05f7c5d666eb395950f36bc9#nginx",
"resolved": "github:NixOS/nixpkgs/3c15feef7770eb5500a4b8792623e2d6f598c9c1#nginx",
"source": "devbox-search",
"version": "1.24.0"
"version": "1.24.0",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/prz9lx44d3hicpmsri5rm9qk44r79ng8-nginx-1.24.0"
},
"aarch64-linux": {
"store_path": "/nix/store/b2v5yw11gmywahlyhbqajml7hjdkhsar-nginx-1.24.0"
},
"x86_64-darwin": {
"store_path": "/nix/store/1nyjvgj3hbhck80wkwi0h18561xbp3sy-nginx-1.24.0"
},
"x86_64-linux": {
"store_path": "/nix/store/vc66rk5b86lx1myxr18qkgzha0fjx2ks-nginx-1.24.0"
}
}
}
}
}
6 changes: 3 additions & 3 deletions examples/stacks/drupal/devbox.d/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
events {}
http{
server {
listen 8000;
listen [::]:8000;
listen 8081;
listen [::]:8081;
server_name localhost;
root ../../../web;
root ../../../devbox.d/web;

error_log error.log error;
access_log access.log;
Expand Down
46 changes: 46 additions & 0 deletions examples/stacks/drupal/devbox.d/nginx/nginx.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
events {}
http{
server {
listen $NGINX_WEB_PORT;
listen [::]:$NGINX_WEB_PORT;
server_name $NGINX_WEB_SERVER_NAME;
root $NGINX_WEB_ROOT;

error_log error.log error;
access_log access.log;
client_body_temp_path temp/client_body;
proxy_temp_path temp/proxy;
fastcgi_temp_path temp/fastcgi;
uwsgi_temp_path temp/uwsgi;
scgi_temp_path temp/scgi;
include mime.conf;

index index.html;
server_tokens off;

index index.php index.htm index.html;

location / {
try_files $uri /index.php?$query_string; # For Drupal >= 7
}

location @rewrite {
rewrite ^ /index.php;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:$PHPFPM_PORT;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
}

# Don't allow direct access to PHP files in the vendor directory.
location ~ /vendor/.*\.php$ {
deny all;
return 404;
}

}
}
6 changes: 3 additions & 3 deletions examples/stacks/drupal/devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"git@latest",
"[email protected]",
"php81Packages.composer@latest",
"nginx@latest",
"mariadb@latest"
"mariadb@latest",
"nginx@latest"
],
"shell": {
"init_hook": [],
Expand All @@ -20,4 +20,4 @@
]
}
}
}
}
5 changes: 3 additions & 2 deletions examples/stacks/drupal/devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
}
},
"nginx@latest": {
"last_modified": "2023-05-01T16:53:22Z",
"last_modified": "2023-09-04T16:24:30Z",
"plugin_version": "0.0.3",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#nginx",
"resolved": "github:NixOS/nixpkgs/3c15feef7770eb5500a4b8792623e2d6f598c9c1#nginx",
"source": "devbox-search",
"version": "1.24.0",
"systems": {
"aarch64-darwin": {
Expand Down
16 changes: 13 additions & 3 deletions examples/stacks/lepp-stack/devbox.d/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ server {
listen 8089;
listen [::]:8089;
server_name localhost;
root ../../../devbox.d/web;
root ../../../my_app;

error_log error.log error;
access_log access.log;
Expand All @@ -14,7 +14,17 @@ server {
uwsgi_temp_path temp/uwsgi;
scgi_temp_path temp/scgi;

index index.html;
server_tokens off;
index index.php index.htm index.html;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:8082;
fastcgi_index index.php;
}
}
}
14 changes: 12 additions & 2 deletions examples/stacks/lepp-stack/devbox.d/nginx/nginx.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ server {
uwsgi_temp_path temp/uwsgi;
scgi_temp_path temp/scgi;

index index.html;
server_tokens off;
index index.php index.htm index.html;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:$PHPFPM_PORT;
fastcgi_index index.php;
}
}
}
3 changes: 2 additions & 1 deletion examples/stacks/lepp-stack/devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"postgresql@14",
"[email protected]",
"php81Extensions.pgsql@latest",
"nginx@1.24"
"nginx@latest"
],
"env": {
"NGINX_WEB_PORT": "8089",
"NGINX_WEB_ROOT": "../../../my_app",
"PGPORT": "5433"
},
"shell": {
Expand Down
7 changes: 4 additions & 3 deletions examples/stacks/lepp-stack/devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
}
}
},
"nginx@1.24": {
"last_modified": "2023-05-01T16:53:22Z",
"nginx@latest": {
"last_modified": "2023-09-04T16:24:30Z",
"plugin_version": "0.0.3",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#nginx",
"resolved": "github:NixOS/nixpkgs/3c15feef7770eb5500a4b8792623e2d6f598c9c1#nginx",
"source": "devbox-search",
"version": "1.24.0",
"systems": {
"aarch64-darwin": {
Expand Down
4 changes: 2 additions & 2 deletions plugins/nginx.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "nginx",
"version": "0.0.3",
"version": "0.0.4",
"readme": "nginx can be configured with env variables\n\nTo customize:\n* Use $NGINX_CONFDIR to change the configuration directory\n* Use $NGINX_TMPDIR to change the tmp directory. Use $NGINX_USER to change the user\n* Use $NGINX_WEB_PORT to change the port NGINX runs on. \n Note: This plugin uses envsubst when running `devbox services` to generate the nginx.conf file from the nginx.template file. To customize the nginx.conf file, edit the nginx.template file.\n",
"__packages": ["envsubst@latest"],
"__packages": ["gettext@latest", "gawk@latest"],
"env": {
"NGINX_CONF": "{{ .DevboxDir }}/nginx.conf",
"NGINX_CONFDIR": "{{ .DevboxDir }}",
Expand Down
2 changes: 1 addition & 1 deletion plugins/nginx/process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "0.5"
processes:
nginx:
command: |
if [ -f $NGINX_CONFDIR/nginx.template ]; then envsubst < $NGINX_CONFDIR/nginx.template > $NGINX_CONFDIR/nginx.conf; fi
if [ -f $NGINX_CONFDIR/nginx.template ]; then envsubst $(awk 'BEGIN {for (k in ENVIRON) {printf "$"k","}}') < $NGINX_CONFDIR/nginx.template > $NGINX_CONFDIR/nginx.conf; fi
nginx -p $NGINX_PATH_PREFIX -c $NGINX_CONFDIR/nginx.conf -e error.log -g "pid nginx.pid;daemon off;"
availability:
restart: on_failure
Expand Down