Skip to content

fix(nginx plugin): Put mime.types where nginx.conf expects it (#2908) - #2909

Open
jefft wants to merge 1 commit into
jetify-com:mainfrom
jefft:jefft/nginx-plugin-fix-2908
Open

jefft wants to merge 1 commit into
jetify-com:mainfrom
jefft:jefft/nginx-plugin-fix-2908

Conversation

@jefft

@jefft jefft commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

nginx starts with -p $NGINX_PATH_PREFIX, where -p means "set the prefix path". However this only affects the runtime path (for directives root, error_log, access_log etc). Relative configuration directives, like include mime.types;, are still resolved relative to nginx.conf. Therefore mime.types must go in {{ .DevboxDir }}, not {{ .Virtenv }}.

Fixes #2908

How was it tested?

rm -rf /tmp/testnginx && \
mkdir /tmp/testnginx && \
cd /tmp/testnginx && \
devbox init && \
devbox add nginx
ls  devbox.d/nginx/mime.types    # file exists
devbox services up

nginx now comes up on port 8081, whereas previously it died with open() "/tmp/testnginx/devbox.d/nginx/mime.types" failed.

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.

…-com#2908)

nginx starts with -p $NGINX_PATH_PREFIX, where -p means "set the prefix
path". However this only affects the runtime path (for directives
`root`, `error_log`, `access_log` etc). Relative configuration
directives, like `include mime.types;`, are still resolved relative to
`nginx.conf`. Therefore mime.types must go in `{{ .DevboxDir }}`, not
`{{ .Virtenv }}`.

Fixes jetify-com#2908
@jefft
jefft force-pushed the jefft/nginx-plugin-fix-2908 branch from 58b64c8 to 237a410 Compare July 8, 2026 13:55
mikeland73 added a commit that referenced this pull request Sep 13, 2026
## Summary

This bump fixes a process-compose bug where services with
`process_healthy` dependencies would hang forever (stuck in Pending
state) when the target process had no readiness_probe or liveness_probe
configured.

process-compose v1.116.0 (commit
[85686e5](F1bonacc1/process-compose@85686e5))
adds a nil-check in waitIfNeeded() that returns a clear error instead of
blocking on a channel that is never closed for processes without probes.

Changes made:

1. `go.mod`: changed github.com/f1bonacc1/process-compose v1.64.1 to
v1.116.0
2. `internal/devbox/util.go`: changed const processComposeVersion =
"1.110.0" to "1.116.0"
3. `go mod tidy`: updated go.sum and indirect dependencies

Fixes #2915

## How was it tested?

First build a devbox with a working
#2909 isolated
#2906 mariadb plugin (unless
those have been merged), plus this PR:

```sh
cd /tmp
git clone git@github.com:jetify-com/devbox.git
direnv allow /tmp/devbox
cd devbox
git remote add jefft git@github.com:jefft/devbox.git
git fetch jefft
git checkout -b merge-plugin-fixes main
git merge jefft/jefft/nginx-plugin-fix-2908
git merge jefft/jefft/mysql-plugin-ignore-etc-mysql
git merge jefft/jefft/process-compose-1.116-fix-2915
devbox run build
```

Then using modified repro script from #2915:

```bash
cat > /tmp/mariadb_testhealth.sh <<'EOF'
#!/bin/bash -eu

if [[ -d /tmp/mariadb_testhealth ]]; then
        ( cd /tmp/mariadb_testhealth && devbox services down >/dev/null 2>&1 || : )
  rm -r /tmp/mariadb_testhealth
fi
mkdir /tmp/mariadb_testhealth
cd /tmp/mariadb_testhealth
devbox init
devbox add mariadb
echo "port = $(( 10000 + RANDOM % 50000))" >> devbox.d/mariadb/my.cnf
cat > my_database_using_app <<'EOF2'
#!/bin/bash
# Connect to MariaDBD via unix socket as root.
sudo mariadb --show-warnings -u root --socket "$MYSQL_UNIX_PORT" -e "select 1;"
EOF2
chmod +x ./my_database_using_app

cat > process-compose.yml <<'EOF2'
version: "0.5"

processes:

  myapp:
    depends_on:
      mariadb:
        condition: process_healthy
    command: ./my_database_using_app
EOF2
devbox services up -b
sleep 1
echo "myapp should be Skipped:"
devbox services ls
echo "We should see an error in the process-compose log:"
grep ERR /tmp/process-compose-$USER.log
EOF

# Put our compiled version of devbox ahead of others in PATH
PATH=/tmp/devbox/dist:$PATH bash /tmp/mariadb_testhealth.sh
```

With the fixed process-compose the myapp service is in Skipped, and the
log contains a clear error message:

```
Starting all services: mariadb_logs, myapp, mariadb 
Process-compose is now running on port 40249
To stop your services, run `devbox services stop`
myapp should be Skipped:
Services running in process-compose:
PID            NAME                NAMESPACE        STATUS         AGE        HEALTH        RESTARTS        EXIT CODE
1673011        mariadb             default          Running        1s         -             0               0
1673058        mariadb_logs        default          Running        0s         -             1               1
0              myapp               default          Skipped        0s         -             0               1
We should see an error in the process-compose log:
26-07-11 02:46:21.849 ERR health dependency defined in 'myapp' but no health check exists in 'mariadb'
26-07-11 02:46:21.850 ERR Error: health dependency defined in 'myapp' but no health check exists in 'mariadb'
26-07-11 02:46:21.850 ERR Error: process myapp won't run
jturner@jturner-desktop:/tmp/devbox$ 
```

## Community Contribution License

All community contributions in this pull request are licensed to the
project
maintainers under the terms of the
[Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0).

By creating this pull request, I represent that I have the right to
license the
contributions to the project maintainers under the Apache 2 License as
stated in
the
[Community Contribution
License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license).

---------

Co-authored-by: Mike Landau <mikeland86@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
mikeland73 pushed a commit that referenced this pull request Sep 13, 2026
…cies (#2915) (#2917)

## Summary

Adds readiness_probe to mariadb, mysql, redis, valkey (using native CLI
ping commands), and apache, nginx (using http_get probes).  PostgreSQL
already had one (pg_isready).

This enables consumers to use `condition: process_healthy` in their
depends_on configuration, ensuring downstream services do not start
until their dependencies are actually accepting connections.

Fixes (along with #2916) #2915

## How was it tested?

First build a devbox with a working
#2909 isolated
#2906 mariadb plugin (unless
those have been merged), plus this PR:

```sh
cd /tmp
git clone git@github.com:jetify-com/devbox.git devbox-2915
direnv allow /tmp/devbox-2915
cd devbox-2915
git remote add jefft git@github.com:jefft/devbox.git
git fetch jefft
git checkout -b merge-plugin-fixes main
git merge --no-edit jefft/jefft/nginx-plugin-fix-2908
git merge --no-edit jefft/jefft/mysql-plugin-ignore-etc-mysql
git merge --no-edit jefft/jefft/plugin_readiness_probes-fix-2915
devbox run build
```

Then to illustrate scripts waiting for their services to come up:

```bash
cat > /tmp/testhealth.sh <<'EOF'
#!/bin/bash -eu

if [[ -d /tmp/testhealth ]]; then
        ( cd /tmp/testhealth && devbox services down >/dev/null 2>&1 || : )
  rm -r /tmp/testhealth
fi
mkdir /tmp/testhealth
cd /tmp/testhealth

cat > devbox.json <<'EOF2'
{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox.schema.json",
  "packages": [
    "mariadb@latest",
    "apache@latest",
    "nginx@latest",
    "redis@latest",
    "valkey@latest"
  ],
  "env": { 
    "HTTPD_PORT": "11101",
    "NGINX_WEB_PORT": "11102",
    "VALKEY_PORT": "11103"
  },
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}
EOF2
devbox services ls   # create devbox.d/* dirs

echo "port = $(( 10000 + RANDOM % 50000))" >> devbox.d/mariadb/my.cnf
cat > my_database_using_app <<'EOF2'
#!/bin/bash
# Connect to MariaDBD via unix socket as root.
sudo mariadb --show-warnings -u root --socket "$MYSQL_UNIX_PORT" -e "select 1;"
EOF2
chmod +x ./my_database_using_app

cat > process-compose.yml <<'EOF2'
version: "0.5"

processes:

  mariadb_tester:
    depends_on:
      mariadb:
        condition: process_healthy
    command: ./my_database_using_app

  apache_tester:
    depends_on:
      apache:
        condition: process_healthy
    command: curl http://localhost:11101

  nginx_tester:
    depends_on:
      nginx:
        condition: process_healthy
    command: curl http://localhost:11102

  valkey_tester:
    depends_on:
      valkey:
        condition: process_healthy
    command: valkey-cli -p $VALKEY_PORT ping

EOF2
which devbox
devbox services up
EOF

# Put our compiled version of devbox ahead of others in PATH
PATH=/tmp/devbox-2915/dist:$PATH bash /tmp/testhealth.sh
```

The `*_tester` dependent services now work, coming up (after a delay) as
Completed::

```bash
jturner@jturner-desktop:/tmp/testhealth$ devbox services ls
Services running in process-compose:
PID            NAME                  NAMESPACE        STATUS           AGE        HEALTH        RESTARTS        EXIT CODE
1982981        mariadb_logs          default          Running          5s         -             0               0
1982980        redis                 default          Running          5s         Ready         0               0
1982983        apache                default          Running          5s         Ready         0               0
1982984        apache-access         default          Running          5s         -             0               0
1983151        mariadb_tester        default          Completed        0s         -             0               0
1983126        apache_tester         default          Completed        0s         -             0               0
1983127        valkey_tester         default          Completed        0s         -             0               0
1982982        nginx                 default          Running          5s         Ready         0               0
1982978        nginx-error           default          Running          5s         -             0               0
1982974        nginx-access          default          Running          5s         -             0               0
1982977        valkey                default          Running          5s         Ready         0               0
1982976        apache-error          default          Running          5s         -             0               0
1983125        nginx_tester          default          Completed        0s         -             0               0
1982973        mariadb               default          Running          5s         Ready         0               0
```


[devbox_dependent_services.webm](https://github.com/user-attachments/assets/51e78b8f-a848-4a36-9ac0-2745852f8e4a)


## Community Contribution License

All community contributions in this pull request are licensed to the
project
maintainers under the terms of the
[Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0).

By creating this pull request, I represent that I have the right to
license the
contributions to the project maintainers under the Apache 2 License as
stated in
the
[Community Contribution
License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license).
mikeland73 added a commit that referenced this pull request Sep 14, 2026
…oject dir work (#2960)

## Summary

Fixes #2631.

Several builtin plugins reference an absolute project path in their
process-compose **service command** without wrapping it in double
quotes:

| Plugin | command (before) |
| --- | --- |
| `apache` | `apachectl start -f $HTTPD_CONFDIR/httpd.conf ...`, `tail
-f $HTTPD_ERROR_LOG_FILE`, `tail -f $HTTPD_ACCESS_LOG_FILE` |
| `caddy` | `caddy run --config=$CADDY_CONFIG` |
| `php` | `php-fpm -y {{ .DevboxDir }}/php-fpm.conf --nodaemonize` |
| `redis` | `redis-server $REDIS_CONF --port $REDIS_PORT` |
| `valkey` | `valkey-server $VALKEY_CONF --port $VALKEY_PORT` |

Each of these variables/templates expands to the project's **absolute
path** (for example `$CADDY_CONFIG` → `{{ .DevboxDir }}/Caddyfile`,
`$REDIS_CONF` → `{{ .DevboxDir }}/redis.conf`). An unquoted reference is
word-split by the shell whenever the project directory contains a space,
so the service fails to start. This is the same class of bug as the
`init_hook` fix in #2876 — now applied to the plugin **service
commands** that run under `devbox services`.

### Fix

Wrap each path reference in double quotes, matching the pattern the
`postgresql` plugin already uses (`pg_isready -p "${PGPORT:-5432}"` and
`-k "$PGHOST"`). Ports and other non-path values are left unquoted.
After the fix, e.g.:

```yaml
command: "caddy run --config=\"$CADDY_CONFIG\""
command: "php-fpm -y \"{{ .DevboxDir }}/php-fpm.conf\" --nodaemonize"
```

The affected plugins' `version` fields are bumped, consistent with how
prior plugin behavior changes are versioned.

The `mariadb`, `mysql`, and `nginx` plugins have the same unquoted-path
pattern in their service commands, but they currently have other
in-flight PRs touching those exact files (#2906, #2911, #2909). They
were intentionally left out of this PR to avoid conflicts and can be
quoted in those PRs or a small follow-up.

## How was it tested?

- Added `plugins/service_command_quoting_test.go`, which scans every
builtin plugin's `process-compose.yaml` and asserts that templated paths
(`{{ ... }}`) and known path-bearing env vars in service commands are
quoted. It reuses the shell-quoting model from the existing
`init_hook_quoting_test.go`. Verified it **fails** on the old (unquoted)
content and **passes** on the fix.
- `go test ./plugins/ ./internal/plugin/`, `go vet ./plugins/`, and
`gofmt` are clean.

cc @arent-groebner — thanks for the report.

## Community Contribution License

All community contributions in this pull request are licensed to the
project
maintainers under the terms of the
[Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0).

By creating this pull request, I represent that I have the right to
license the
contributions to the project maintainers under the Apache 2 License as
stated in
the
[Community Contribution
License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license).

---
_Generated by [Claude
Code](https://claude.ai/code/session_017vU39wucKJwc6SGydhzoiN)_

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

nginx plugin broken due to misplaced mime.types

1 participant