331 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
1a376c3622 fix: prevent command injection via docker options eval
Values supplied through docker options, `--ttl-seconds`, and `-e` flowed into a Bash `eval` during build, deploy, and run, letting a low-privileged user execute arbitrary commands on the host as the dokku user. These arguments are now tokenized and passed through to the container verbatim, without shell expansion. A one-time migration repairs stored labels whose backticks were saved with a stray backslash so Traefik-style rules stay valid on the next deploy.
2026-07-19 01:42:12 -04:00
Jose Diaz-Gonzalez
5d07484cc2 refactor: remove unused bash report helper functions
With every bash :report subcommand now ported to golang, the shared fn-report-parse-args, fn-report-emit-json, fn-report-filter-global and fn-report-validate-format helpers are no longer referenced and are removed.
2026-07-07 07:15:19 -04:00
Jose Diaz-Gonzalez
79921d75d6 fix: pull registry-aware image name on local miss
When `image-repo` is overridden, the registry plugin pushes under that name and
the bare local `dokku/<app>:N` tag is never created. `fn-verify-app-image` now
queries the `deployed-app-image-repo` trigger and pulls `${REMOTE_REPO}${DEPLOYED_REPO}:${TAG}`,
retagging it as the local bare reference so subsequent inspects resolve. Also
aligns the `storage:ensure-directory` deprecation test assertion with the
standardized `Deprecated:` prefix.
2026-05-25 16:07:47 -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
dbac12e9f1 refactor: route bash app name validation through go
The bash and go validators previously each kept their own copy of the regex, which had to be updated in lockstep. Both bash wrappers now invoke the existing common binary via the same pattern as `verify_app_name`, leaving go as the single source of truth. The legacy `IsValidAppNameOld` rule is also widened to allow underscores again so apps created under the old naming rules can still be looked up through `VerifyAppName`'s either-rule fallback.
2026-05-09 16:00:51 -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
2df0791fcd fix: prevent tar symlink traversal in archive extraction
Archives passed to git:from-archive and certs:add were extracted without symlink or path validation, allowing a crafted archive to write arbitrary files anywhere writable by the dokku user via symlink traversal. Extraction now pre-scans entries for absolute paths, parent traversal, and unsafe symlinks, applies the GNU tar `--no-unsafe-links` flag when available, and validates symlinks after extraction.
2026-05-09 12:54:42 -04:00
Jose Diaz-Gonzalez
aea322be6f chore: use old path 2026-05-04 13:17:49 -04:00
Jose Diaz-Gonzalez
473bcce688 fix: use inline source instead of global source
Ensure property-functions are sourced only if not already defined.
2026-05-04 09:32:09 -04:00
Jose Diaz-Gonzalez
964c0fc4e9 fix: source property-functions where fn-plugin-property-* helpers are used
The release_and_deploy function and several proxy plugin scripts call fn-plugin-property-* helpers without sourcing `plugins/common/property-functions`, producing `command not found` errors during deploys. Source the helpers from `plugins/common/functions` and from each proxy plugin entry point that consumes them.
2026-05-04 06:11:22 -04:00
Jose Diaz-Gonzalez
ea25c5b6e2 fix: keep operator stdout when teeing build output to file 2026-04-30 02:02:02 -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
1308e21947 feat: migrate environment variables to plugin properties
Standardize how environment variables are migrated to properties during
install triggers and migrate all remaining DOKKU_* config vars to their
appropriate plugin properties.

Adds a reusable MigrateConfigToProperties() function in the common
package with Transform callback and ListProperty support, plus a
migrate-config-to-property subcommand for the prop binary so shell
plugins can use the same code path.

Migrated variables and their new property owners:
- DOKKU_APP_PROXY_TYPE/DOKKU_PROXY_TYPE → proxy type
- DOKKU_DISABLE_PROXY → proxy disabled
- DOKKU_PROXY_PORT → ports proxy-port
- DOKKU_PROXY_SSL_PORT → ports proxy-ssl-port
- DOKKU_APP_RESTORE → ps restore
- DOKKU_SKIP_DEPLOY → ps skip-deploy
- DOKKU_START_CMD → ps start-cmd
- DOKKU_DOCKERFILE_START_CMD → ps dockerfile-start-cmd
- DOKKU_DISABLE_APP_AUTOCREATION → apps disable-autocreation
- DOKKU_APP_SHELL → scheduler shell
- DOKKU_SKIP_CLEANUP → builder skip-cleanup
- DOKKU_CHECKS_DISABLED → checks disabled
- DOKKU_CHECKS_SKIPPED → checks skipped
- DOKKU_CHECKS_WAIT → checks wait
- DOKKU_CHECKS_TIMEOUT → checks timeout
- DOKKU_CHECKS_ATTEMPTS → checks attempts
- DOKKU_DEFAULT_CHECKS_WAIT → checks default-wait
- DOKKU_SKIP_ALL_CHECKS → checks disabled (legacy)
- DOKKU_SKIP_DEFAULT_CHECKS → checks skipped (legacy)

Also refactors existing bespoke migration loops in scheduler, ports, ps,
builder, and nginx-vhosts plugins to use the standardized utility.

Removes DOKKU_PARALLEL_ARGUMENTS from documentation (unused in core).
Deprecates fn-migrate-config-to-property bash function.

closes #1558
2026-04-25 05:11:07 -04:00
Jose Diaz-Gonzalez
41a15a7319 fix: set DOCKER_CONFIG to the directory holding the config.json 2026-01-09 23:47:00 -05:00
Jose Diaz-Gonzalez
6a83fd053c feat: add the ability to log into a registry on a per-app basis
Closes #5324
2026-01-09 00:12:16 -05:00
Jose Diaz-Gonzalez
551eae0c5b chore: remove references to pack being experimental
It is no longer experimental and is here to stay.
2025-11-09 20:32:39 -05:00
Jose Diaz-Gonzalez
5d5d56c560 refactor: remove public exposure of DOKKU_APP_TYPE in favor of builder detected property
The DOKKU_APP_TYPE has long since ceased to be the correct way to specify the builder for the application. It's only usage has been during the detection phase, specifically to ensure that the herokuish plugin injects the correct docker arguments during the build. As such, it is safe to migrate away to a property in a patch release.

Users that seek to set a specific builder should use 'dokku builder:set $APP selected' instead.

Refs #7863
2025-08-21 23:59:41 -04:00
Jose Diaz-Gonzalez
577f46153f refactor: use helper go functions to handle extracting files from a repository
This standardizes the extraction code and makes it easier to reuse in future implementations of file extraction.

Additionally, this adds a way to extract folders from codebases.
2025-07-23 18:16:16 -04:00
Jose Diaz-Gonzalez
becba49c87 refactor: always use golang version of CopyFromImage 2024-12-16 01:47:00 -05:00
Jose Diaz-Gonzalez
83b89453a5 feat: write current process id to all acquired lock files
This allows us to check on what process created a lock.

Additionally, we now always have a DOKKU_PID value, even when running in cron (which does not have access to BASH_PID.
2024-03-14 08:18:35 -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
0d6bde2eff Merge pull request #6156 from dokku/migrate-lock-path
Migrate the app deploy lock to the data directory
2024-03-12 22:24:55 -04:00
Jose Diaz-Gonzalez
87bde84115 fix: handle case where most builders didn't detect amd64 images on arm64
Images would build but then fail to be tagged, causing deployment problems on arm64 architectures for a small number of images.

Also fix a minor issue in the nixpacks builder that caused any pre-release-builder triggers that consumed the image to get an empty string instead.
2024-03-06 19:02:08 -05:00
Tasos Maschalidis
f574c1d0a3 Handle DOKKU_FORCE_TTY in has_tty function 2024-02-11 00:57:44 +02:00
Jose Diaz-Gonzalez
db476d3b51 chore: run shfmt 2024-02-09 14:53:45 -05:00
Jose Diaz-Gonzalez
f0c6f45596 fix: correctly namespace the lock file 2024-02-09 14:38:43 -05:00
Jose Diaz-Gonzalez
b7a3ef2f8a fix: use correct path for lock 2024-02-09 14:34:32 -05:00
Jose Diaz-Gonzalez
126a3ed509 chore: remove deprecated proxy-ports functions and and plugin subcommands
These were deprecated in 0.31.0 in favor of the ports plugin.
2023-10-16 00:18:39 -04:00
Jose Diaz-Gonzalez
ffc64e7d8b feat: add a shell function to check if a plugin trigger exists 2023-10-15 20:25:08 -04:00
Jose Diaz-Gonzalez
625ea14c8f feat: add openresty proxy implementation
This plugin is mostly compatible with the nginx plugin, but runs the proxy within a docker container. Users do not have direct access to add custom openresty configuration at this time, but instead receive the ability to setup automatic ssl on first request via letsencrypt integration.
2023-08-05 20:59:01 -04:00
Jose Diaz-Gonzalez
f8ccf52079 refactor: only use detected port mapping if override is not specified
Previously, we would always set the port mapping during a dockerfile build, making it difficult for users to override mappings. We also only _sometimes_ updated the detected port mapping, further confusing issues when users were migrating from Dockerfile to Buildpacks for builds.

Now, we always detect the port mapping during the build process, and only use that detected port mapping if an override is not specified. This greatly simplifies the experience around port mapping, as now a user can create an app, set a port mapping, and that first deploy will respect the port mapping without an additional deploy.

The builder always has the best context for what the app should be listening on, and thus we can always specify a "default" port mapping at this stage. Users can override this map as desired later.

This change also results in the removal of a ton of internal code that is now centralized in the ports plugin.

Closes #4067
2023-08-05 10:58:57 -04:00
Jose Diaz-Gonzalez
192f7cf768 refactor: move code for fetching an available port to the ports plugin
Also translate the code to golang.
2023-08-05 10:58:57 -04:00
Jose Diaz-Gonzalez
121e4737a8 refactor: move code that fetches raw tcp ports for dockerfile deploys to ports plugin 2023-08-05 10:58:57 -04: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
e628e21879 chore: remove deprecated --rm-container and--rm global flags 2023-02-12 13:09:00 -05:00
Jose Diaz-Gonzalez
d27c8f09d1 chore: remove deprecated common functions 2023-02-12 13:08:45 -05:00
Jose Diaz-Gonzalez
a2444b453d chore: remove deprecated --detach flag
This option was deprecated in Dokku 0.25.0.
2023-01-16 01:19:39 -05:00
Jose Diaz-Gonzalez
80fd9bbd4b fix: run linting 2022-12-02 16:00:32 -05:00
Jose Diaz-Gonzalez
c2ebf48524 refactor: use a single implementation for checking cnb/herokuish images
Also use a plugin trigger for testing whether an image is herokuish or not rather than trying to mess around with sourced files.
2022-12-02 15:54:48 -05:00
Jose Diaz-Gonzalez
edd6e476b3 refactor: simplify how url generation works
The URLS file is no longer necessary as urls are now generated directly from the app VHOST file.

This also moves all the url generation logic to the domains plugin.
2022-12-02 02:19:59 -05:00
Jose Diaz-Gonzalez
daa4ee829e fix: run shfmt 2022-11-22 20:34:23 -05:00
Jose Diaz-Gonzalez
c74e6ce216 refactor: use a common wrapper function to migrate config vars to properties 2022-11-22 20:27:43 -05:00
Jose Diaz-Gonzalez
4a9bdd6dc2 fix: add missing {{end}} to docker format template 2022-11-07 10:07:48 -05:00
Jose Diaz-Gonzalez
3ff5e0e3a6 fix: error out if commands using compose are executed
Refs #5335
2022-11-05 23:44:51 -04:00
Jose Diaz-Gonzalez
a71e4219be fix: set the correct image source type based on label
We also have a special carveout for herokuish as folks may deploy built images with it.
2022-08-09 02:11:32 -04:00
Jose Diaz-Gonzalez
cfc1cfb305 feat: export DOKKU_COMMAND for use in authentication systems
Some auth systems may decide that an app is not available for use by a particular command vs making them wholly available or not. Exporting the variable here allows such systems to function correctly.
2022-07-17 17:58:37 -04:00
Jose Diaz-Gonzalez
db4d8dba88 refactor: consolidate app name verification into golang binary
This change ensures we only have to change this logic once in order to get them to apply to both languages in the codebase.
2022-05-29 11:32:24 -04:00
Jose Diaz-Gonzalez
b3d7174a7a fix: filter apps when verifying app names
This ensures folks can't interact with apps that are hidden from them via the filtering performed in app listing.
2022-05-27 23:28:59 -04:00