Podmaker
All pages
Use

Your own services and functions

Run your own API, worker or a small piece of code as a shared service that your apps use - from a podmaker-service.yml.

Your own services and functions

Besides databases and queues, Podmaker runs your own shared services:

  • an internal API (a geo service, a PDF renderer, an image resizer …);
  • a worker image you built elsewhere;
  • a function: a few lines of Node.js or Python, served over HTTP for you, like AWS Lambda but on your servers.

You describe it in a podmaker-service.yml. Podmaker runs it on the server you choose. The apps you connect to it get its address and a token as variables. It is reachable from other servers over the private network, only by the servers that use it (firewall).

A function

# podmaker-service.yml
version: 1
name: geo                  # becomes the service type x-geo
title: Geo lookups
kind: function
function:
  runtime: node22          # node22 or python313
  file: handler.mjs        # or inline:  code: |
  timeout: 10              # seconds per request (max 300)
  memory: 256              # MB (64-4096)
  env:                     # plain settings; secrets: see below
    DEFAULT_COUNTRY: TR
access:
  projects: [shop, blog]   # who may use it; ['*'] (or leave out) for all

Node.js: export the handler as default; it may be async.

// handler.mjs
export default async (req) => {
  // req: { method, path, query, headers, body }   (body: parsed JSON, or text)
  return { status: 200, headers: {}, body: { hello: req.query.name ?? 'world' } };
};

Python:

# handler.py
def handler(req):
    return {"status": 200, "body": {"hello": req["query"].get("name", "world")}}

What the runtime does for you:

  • A returned object or list is sent as JSON, a string as text. Returning just a value works too: it becomes the body.
  • GET /health answers for the health check.
  • Every other request needs Authorization: Bearer <token>; without it the answer is 401.
  • Bodies are limited to 1 MB.
  • When the time is up, the answer is 504.

Limits for now:

  • Only the standard library: no npm install or pip install. For dependencies, build an image and use kind: compose.
  • The code is at most 256 KB.

Your own image

version: 1
name: pdf
title: PDF renderer
kind: compose
service: api
port: 3000                 # the port inside the container
compose:
  image: ghcr.io/acme/pdf-renderer:2.1
  environment:
    API_TOKEN: ${IMP_ADMIN_PASSWORD}   # the token Podmaker gives to apps
  volumes: [data:/var/cache/pdf]       # named volumes only
  healthcheck:
    test: [CMD, wget, -qO-, http://127.0.0.1:3000/health]
connect:                   # what each connected app gets
  PDF_URL: http://{{host}}:{{port}}
  PDF_TOKEN: '{{token}}'

Podmaker sets the networking: no ports, networks, privileged or host mounts. Building from a Dockerfile is not supported yet; push the image to a registry first.

What apps get

connect lists the variables of each connected app. Placeholders:

  • {{host}} and {{port}}: the private address on the same server, or the private-network address from another server;
  • {{token}}: the token the service checks;
  • {{url}}: http://host:port.

Without connect an app gets <NAME>_URL and <NAME>_TOKEN.

curl -H "Authorization: Bearer $GEO_TOKEN" "$GEO_URL/country?code=TR"

Add it, start it, connect apps

  1. Add the definition:
    • Panel: Services → Your own services → Add your own. Paste the manifest, or read it from a connected repository or a zip.
    • Desktop app: Services → From a folder.
    • CLI: podmaker service define path/to/folder.
  2. Start it on a server like any shared service:
    • Services → Add a service → your service;
    • or podmaker service create geo --type x-geo --server app-01.
  3. Connect apps like a database:
    • the project’s environment → services;
    • or podmaker service bind.

Updating: add the changed manifest again; running copies are redeployed. Removing: delete the service on its server first, then the definition.

Example

A complete example is in the repository: packages/services/examples/geo.