Commit Graph

111 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
3fee5b881a feat: port git :report subcommand to golang
The bash :report implementation for the git plugin is replaced with a compiled golang binary. Property, computed and global keys are collected in parallel, while the sha and last-updated-at keys still shell out to git and stat the deploy branch ref so their values are unchanged. The non-report git helpers such as fn-git-cmd and the computed deploy-branch and keep-git-dir getters remain in place for the build pipeline.
2026-07-07 07:02:38 -04:00
Jose Diaz-Gonzalez
9517353df4 fix: recover deployed image from registry on local miss
Adds an app-aware `fn-verify-app-image` helper that pulls the deployed image
from the configured registry when it is missing locally, gated on
push-on-release being enabled, honoring per-app `registry:login` credentials.
Every in-tree `verify_image` caller migrates to the wrapper and the bare
helper is marked deprecated. `config:set` now forwards the deployed image tag
to `release-and-deploy` so the release path no longer pins recovery on the
unrecoverable `:latest` tag.
2026-05-25 16:07:47 -04:00
Jose Diaz-Gonzalez
357e12bd83 refactor: rename computed-* helpers, expose computed vector and network keys
Addresses review feedback on #8640. fn-archive-max-size,
fn-archive-max-files, fn-git-deploy-branch, and fn-git-keep-git-dir are
renamed with `computed` in the function name so the names match the
resolved-with-default semantic they implement, and every caller is
updated in lockstep. logs:report renames the misordered
--logs-vector-global-image and --logs-vector-global-networks to
--logs-global-vector-image and --logs-global-vector-networks, makes the
global getters return the raw stored value, and adds
--logs-computed-vector-image, --logs-computed-vector-networks, and
--logs-computed-vector-sink. network:report --global gains the
computed-* keys for attach-post-create, attach-post-deploy,
initial-network, and tld so external tooling can read the resolved
value at global scope. The --quiet flag is dropped from every
:report --format json | jq invocation across the PR's bats files; the
report's --format json output is the only stdout and the flag is
redundant.
2026-05-23 04:47:03 -04:00
Jose Diaz-Gonzalez
82d1f8e11c test: align triplet tests with actual plugin behavior
Fixes CI failures from the prior commit's bats additions.
storage report mounts are prefixed with `-v `, logs.bats setup does not
auto-create the test app, the nginx-vhosts shell report emits JSON keys
without the `nginx-` plugin prefix, registry computed-image-repo falls
back to the default `dokku/<app>` repo name when no template is set,
cron computed-maintenance follows OR-not-override semantics so a per-app
`false` does not override a global `true`, the scheduler subcommand
help string is `Manage scheduler settings`, and bringing ps procfile-path
into the #8640 raw convention required updating the pre-existing
`(ps:set) procfile` assertion. Also extends fn-git-keep-git-dir to fall
back through the global property before the built-in default so global
keep-git-dir actually takes effect at deploy time.
2026-05-23 01:35:04 -04:00
Jose Diaz-Gonzalez
76b033234f fix: split report global keys into raw and computed across plugins
The `<plugin>-global-<property>` keys in `:report` output returned the resolved value with the built-in default substituted in, so external tooling could not distinguish a property that had been set globally to the default from one that had never been set. The bare keys for caddy, haproxy, and traefik global-only properties had the same shape. The `global-<property>` keys now hold the raw stored value and are empty when nothing has been set, and a new `computed-<property>` key holds the effective value used at runtime, falling back through the per-app value (where one exists), the global value, and the built-in default. The bare global-only keys for the three proxy plugins are removed in favor of the raw/computed pair. Closes #8631.
2026-05-23 00:05:33 -04:00
Jose Diaz-Gonzalez
c45b95fc4d fix: expose raw deploy-branch and keep-git-dir in git:report
The bare `deploy-branch` and `keep-git-dir` keys in `git:report` returned the computed (effective) value rather than the raw per-app value, with no separate `computed-*` key to distinguish "set per-app" from "falling back to global or default". This left external tooling unable to detect a per-app unset without out-of-band state. The bare keys now hold the raw per-app value (empty when unset) and new `computed-deploy-branch` and `computed-keep-git-dir` keys hold the effective value, matching the convention used by `nginx-vhosts`, `network`, and `builder`. Closes #8610.
2026-05-11 22:18:17 -04:00
Jose Diaz-Gonzalez
7b515ea129 refactor: drop unused value_exists from report functions
The `value_exists` variable in the report info-flag loop is no longer read after the `not deployed` failure was removed, and was already unused in domains, haproxy-vhosts, traefik-vhosts, caddy-vhosts, and openresty-vhosts. Drop the declaration and the trailing assignment so the loop reads cleanly across all plugins.
2026-05-10 22:23:46 -04:00
Jose Diaz-Gonzalez
bd748052a1 fix: report info-flag should not error when app undeployed
Several plugin `:report` subcommands erroneously failed with `not deployed` when an info-flag matched a property that was empty. Empty values are legitimate for configuration properties pre-deploy and the `--format json` path already returns them without error. Remove the `value_exists` check across nginx, checks, git, certs, scheduler-docker-local, and the builder-* plugins so the info-flag form behaves consistently with the JSON form.
2026-05-10 22:15:27 -04:00
Jose Diaz-Gonzalez
93f87a0f07 fix: restrict app names to prevent command injection
The previous app name validation regex permitted shell metacharacters such as `;`, `$`, backticks, `|`, and `&`. These names were embedded unquoted into the generated git pre-receive hook script, allowing an authenticated user to execute arbitrary commands as the dokku user simply by pushing to a remote with a crafted app name. App names are now restricted to lowercase alphanumerics, dots, and hyphens, and the hook script also quotes the app variable as a defense-in-depth measure.
2026-05-09 16:00:51 -04:00
Jose Diaz-Gonzalez
e78d3bcc78 Merge pull request #8591 from dokku/arbitrary-file-write
Harden archive extraction against symlink traversal
2026-05-09 15:58:31 -04:00
Jose Diaz-Gonzalez
9decf16ea1 feat: configure archive limits via git properties
Replaces the `DOKKU_ARCHIVE_MAX_SIZE` and `DOKKU_ARCHIVE_MAX_FILES` environment variables with global git properties (`archive-max-size` and `archive-max-files`), configurable via `dokku git:set --global` and surfaced through `dokku git:report --global`. Defaults remain `1073741824` bytes and `10000` entries.
2026-05-09 13:08:23 -04:00
Jose Diaz-Gonzalez
6eb8b8632c fix: enforce 0600 permissions on .netrc credentials file
The previous use of `touch` before `netrc set` allowed the file to inherit the umask and be world-readable, exposing stored git credentials to local users. The set and unset paths now explicitly chmod 0600 and chown to the dokku user, and the plugin install hook repairs permissions on already-affected installations.
2026-05-09 12:22:17 -04:00
Jose Diaz-Gonzalez
e8d8b0683a fix: preserve info flag in plugin reports with --global
The argument-handling block in each plugin's report command overwrote APP with --global before checking whether $1 actually held an info flag, so `dokku <plugin>:report --global --<plugin>-foo` always emitted the full report instead of the requested value. Reorder the conditionals across the sixteen plugins that share the pattern so the info-flag check runs first, and add a regression bats case for each one.
2026-04-30 21:05:46 -04:00
Jose Diaz-Gonzalez
67e4cf04ab feat: migrate builds plugin to go and track per-build records
Adds typed JSON build records under data/builds/<app>/<build-id>.{json,log} keyed on a stable base36 ULID-style DOKKU_BUILD_ID generated for every deploy. The new commands surface that history (builds:list, builds:info, builds:prune) and an operator-configurable retention via builds:set retention. The existing builds:cancel and builds:output now key on the build-id (with safe handling for already-finalized and abandoned records), and the per-build log file replaces journalctl as the durable source of truth for builds:output.
2026-04-30 01:18:03 -04:00
Jose Diaz-Gonzalez
aa72794711 feat: redirect output in every case as appropriate 2026-04-29 13:48:50 -04:00
Jose Diaz-Gonzalez
8282981361 feat: accept --global on :report subcommands
Every `:report` subcommand now recognizes `--global` as a scope selector that limits the report to globally-configured properties, including in JSON form via `--global --format json`. Previously this combination was rejected because `--global` was treated as an info flag, conflicting with `--format`. The shared `common.ParseReportArgs` helper now returns a `ReportArgs` struct exposing the parsed scope; each Go and bash report selects a global-only flag map when scope is global, and skips per-app verification.
2026-04-29 10:30:59 -04:00
Jose Diaz-Gonzalez
8847fcb6b0 Merge pull request #8505 from dokku/8504-git-auth-status
Add git:auth-status to check netrc match
2026-04-27 01:25:46 -04:00
Jose Diaz-Gonzalez
66c4b3b30e feat: add --format json to git:report and nginx:report
Mirrors the JSON output convention already used by scheduler:report, builder:report, network:report, and traefik:report. Both plugins now accept `--format json` to emit a single-line JSON object whose keys are the property names with the plugin prefix stripped. Combining `--format` with an info flag is rejected with an error message that matches the Go-based report helper.

Closes #8499
2026-04-26 23:30:22 -04:00
Jose Diaz-Gonzalez
65bdbefbea feat: add git:auth-status to check netrc match
Adds `git:auth-status HOST [USERNAME] [PASSWORD]` which exits 0 when the
configured `.netrc` entry matches the requested state and 1 otherwise,
allowing external tooling to detect whether `git:auth` would change
anything without reading `$DOKKU_ROOT/.netrc` directly. Both `git:auth`
and `git:auth-status` now also accept the password via `STDIN`.
2026-04-26 23:10:30 -04:00
Jose Diaz-Gonzalez
91e800a97b Merge pull request #8266 from dokku/6847-allow-force-pull-image-on-git-from-image
Add a method to force build when re-using an image with git:from-image
2026-01-08 12:11:54 -05:00
Jose Diaz-Gonzalez
6c3936802e feat: add a method to force build when re-using an image with git:from-image
Closes #6847
2026-01-08 02:46:53 -05:00
Jose Diaz-Gonzalez
dd70fb823d feat: add the ability to skip setting the deploy-branch when running git:sync
Closes #8212
2026-01-08 02:19:22 -05:00
Jose Diaz-Gonzalez
d5ea97f7b0 chore: consolidate on single method to redirect stdout/stderr to /dev/null 2025-11-18 14:07:09 -05:00
Jose Diaz-Gonzalez
4ec6fa3eb0 fix: always set the git rev env var when building an app via git:sync
Closes #6827
2024-09-28 23:47:48 -04:00
Jose Diaz-Gonzalez
c4c3edc167 feat: use a long git sha in the git:report output
The previous method sometimes truncated the sha, depending on how the app was deployed. Using the long sha will ensure that the value is stable, regardless of the deployment method.

Closes #6770
2024-03-28 20:22:39 -04:00
Andrew Kvalheim
f64cf3bdfa fix: dereference annotated tags
refs/heads/master cannot be updated to an annotated tag per se; the rev
given must first be resolved to a commit. ^{commit} recursively
dereferences the rev until a commit is found.

Resolves #6737 and test failure:

    # bats --filter annotated-tag tests/unit/git_3.bats
    git_3.bats
     ✗ (git) git:sync existing [--no-build annotated-tag]
       fatal: update_ref failed for ref 'refs/heads/master': cannot update ref 'refs/heads/master': trying to write non-commit object 6399bed673f513332f3d5d99e777e0262f42404c to branch 'refs/heads/master'
2024-03-18 17:30:19 -07:00
Jose Diaz-Gonzalez
efc35ab104 fix: correctly check if a repository has code or not in git plugin 2024-03-14 10:09:14 -04:00
Jose Diaz-Gonzalez
58772984cd tests: check that the ref has been updated to the correct value 2024-03-14 05:28:37 -04:00
Jose Diaz-Gonzalez
4de97a1094 feat: add ability to only build synced repo if there are changes
Closes #6242
2024-03-14 04:42:28 -04:00
Jose Diaz-Gonzalez
a1790d674c fix: use correct variable 2024-03-13 07:48:01 -04:00
Jose Diaz-Gonzalez
50958fc448 refactor: remove git:unlock command
This is no longer necessary with improvements elsewhere in Dokku.
2024-03-13 06:24:30 -04:00
Jose Diaz-Gonzalez
10468ce47d fix: ensure we cleanup the data directory on app deletion
Also use a variable for the clone root dir.
2024-03-13 05:37:06 -04:00
Jose Diaz-Gonzalez
ec65d97139 feat: allow generating an ssh deploy key via the git plugin
While this might not seem super intuitive, the key is mostly related to git management, not the ssh-keys we currently use to add/remove access to push to dokku.
2024-01-19 06:30:30 -05:00
Jose Diaz-Gonzalez
ef25a9b0d8 refactor: standardize on shorthand for redirecting all output to /dev/null
The shorthand is more prevalent in this codebase, and is something that bash supports, so we should just use the same thing everywhere.

Note that we do not use shorthand redirect in Makefile as shell parsing is a bit different in Make and the shorthand redirect doesn't seem to be properly supported, causing CI errors.
2023-08-05 10:58:57 -04:00
Jose Diaz-Gonzalez
8faa338bd4 fix: ensure users can push from an image-deploy repository and respect deploy-branch
Previously, we created this weird bare repo that didn't do set all the normal git config. This change switches to cloning the local temp directory, fixing the `receive.denyCurrentBranch` property that blocked pushing to this weird bare repo after calling git:from-image or git:from-archive.

Additionally, since we now use a git clone, we set the default branch correctly, ensuring git pushes later on that branch work as expected (and not on master if it was customized prior to app creation).

Closes #5601
Closes #5662
2023-05-28 03:10:45 -04:00
josegonzalez
ca04c2dc48 fix: return after showing the contents of the public key file 2023-04-27 22:54:14 -04:00
josegonzalez
b11d9bc3a0 fix: correct shfmt issue and fallback to default case 2023-04-11 22:43:37 -04:00
Michael OBrien
2cac8718dd Improve ed25519 + rsa ssh key search and presentation 2023-04-05 18:52:36 -07:00
Michael OBrien
343a98560b Check for both default rsa and ed25519 ssh public key files 2023-04-05 15:34:57 -07:00
Jose Diaz-Gonzalez
98970a597c chore: drop code supporting git versions without worktree support
This was necessary on Ubuntu 14.04 (and maybe 16.04) due to using a version of Dokku older than #2699, so we can safely drop the support here as we haven't supported either in a few years.
2023-03-20 00:51:50 -04:00
Jose Diaz-Gonzalez
d333c16347 feat: add ability to deploy images generated via docker save with git:load-image
Closes #4559
2023-01-21 14:05:31 -05:00
josegonzalez
b9a9094b46 fix: properly parse arguments for git:status command 2022-12-27 01:42:08 -05:00
Jose Diaz-Gonzalez
c3c6e2174a fix: keep track of the source image when building an app via git:from-image
This change fixes issues with ps:rebuild not working as expected - essentially ignoring files in the repo - as well as adds tests.

Closes #5518
2022-12-18 17:57:24 -05:00
Jose Diaz-Gonzalez
aca8deb2f2 feat: add git:status subcommand
Closes #5248
2022-11-09 00:04:45 -05:00
Jose Diaz-Gonzalez
deeb18b56c fix: set core.bare=true on correct repository path
Closes #5275
2022-08-10 16:51:17 -04:00
Jose Diaz-Gonzalez
49d08a8fb6 fix: pass along failed build status when building from image 2022-04-16 02:44:51 -04:00
Jose Diaz-Gonzalez
1b6861cdbb feat: add plugin trigger for checking if an app has code
This will allow us to short-circuit build processes that would otherwise be triggered due to various commands in Dokku.
2022-04-16 01:40:22 -04:00
Jose Diaz-Gonzalez
548bb6eae2 chore: always use DOKKU_ROOT env var instead of /home/dokku 2022-04-03 13:14:52 -04:00
Jose Diaz-Gonzalez
98e38bd70d chore: update log output for deploy-branch setting
The code was referencing an env var that is no longer used in favor of a git plugin setting.
2022-04-03 13:14:27 -04:00
Jose Diaz-Gonzalez
62a3eff5bb refactor: move apps listing from common plugin to apps plugin
This helps centralize app-related listing fetching.
2022-02-26 00:37:51 -05:00