Prepare the program
Put a Dockerfile and the application source in a directory in your project. Pin your base image and dependencies. Supply an argument array such as["python3", "/app/convert.py"] when publishing. The runtime appends two arguments: the absolute input manifest path and the output directory. Read input paths relative to the input manifest’s directory and preserve their array order when order matters.
A Node-based PDF merger can install its own locked dependencies with this Dockerfile. Put pdf-lib in the project’s package.json, commit its package-lock.json, and publish the version with ["node", "/app/merge.mjs"].
inputs (each with a path) and parameters. Write regular files to the output directory and an ordered outputs.json alongside them. Every output entry includes path, media_type and exact size_bytes:
Publish, run and retrieve files
- Save the exact source revision. Use
container_job_version_publishwith the project and environment, job name, source revision, context path, Dockerfile relative to the context, entry point, runtime limit and build credit cap. Keep the idempotency key when retrying. Pollcontainer_job_version_getforready. - Request a private upload using
container_job_input_uploadwithkind: input, the content type and exact byte length.PUTthe file bytes to the returned URL with that content type. Keep the file ID. Supply optional JSON parameters using a separate upload withkind: parametersandapplication/json. Short-lived transfer URLs are bearer credentials. - Use
container_job_quotewith the pinned version ID, ordered file IDs, optional parameters file ID and maximum runtime. Pass the quote ID, maximum microcredits and a stable idempotency key tocontainer_job_start. The response includes a run ID. One credit equals 1,000,000 microcredits. - Poll
container_job_getwith the same project and environment. When it succeeds, request each output usingcontainer_job_output_download. The result can be downloaded after the container has stopped. Copy the output to durable project files if it must outlive the temporary retention period. - Use
container_job_cancelto stop a queued or active run. Poll until it reaches a terminal state. Closing the caller’s connection leaves the job running.
ohmyhost job commands.
Submit and poll jobs from a deployed app
A deployed backend can call the Jobs gateway directly by adding its environment’s HTTPS origin toruntime.egress.allow in ohmyhost.yaml (https://jobs.dev.ohmyho.st in Development, https://jobs.ohmyho.st in Production). The platform automatically injects two runtime variables into deployments that allow the Jobs gateway origin, and permits the matching file-transfer host (https://job-files.dev.ohmyho.st or https://job-files.ohmyho.st):
OHMYHOST_JOBS_BASE_URL— the environment’s Jobs gateway origin.OHMYHOST_JOBS_TOKEN— a deployment-scoped bearer credential bound to this project, environment and deployment. Keep it server-side and send it only toOHMYHOST_JOBS_BASE_URL.
/v1/job-inputs, /v1/job-quotes, /v1/job-runs, /v1/job-runs/{run_id}, /v1/job-runs/{run_id}/outputs/{file_id}/download and /v1/job-runs/{run_id}/cancel with Authorization: Bearer ${env.OHMYHOST_JOBS_TOKEN}. The app controls which of its end users may submit work or retrieve a result.
For example, this server-side function submits an already published version. Pass your stored idempotency key and the maximum the user accepted. A retry of the same start must reuse the same quote and key.
status_url against env.OHMYHOST_JOBS_BASE_URL with the same bearer token after next_poll_after_seconds.