@flisk-sh/flisk-export
v0.10.0
Published
Write a Render Blueprint (render.yaml), a Cloudflare wrangler.toml or a standalone docker-compose.yml from Flisk service.json files. Never deploys.
Readme
flisk-export
Write a Render Blueprint (render.yaml) or a Cloudflare wrangler.toml from the service.json files of a Flisk project.
It writes files only. It never deploys, never creates DNS records, never calls a cloud API, and writes environment variable names, never values. The Flisk CLI runs it at a pinned version as flisk export.
Use
npx @flisk-sh/flisk-export render [dir] [--resource <name>] [--out <dir>] [--dry-run] [--force]
npx @flisk-sh/flisk-export wrangler [dir] --resource <name> [--route <host>] [--out <dir>] [--allow-non-worker] [--dry-run] [--force]Or, from a Flisk project: flisk export render --dry-run.
render
- Exports every resource whose
appTypeisbackend,frontend,agent,mcporbring-your-own(a resource with noappTypeis not exported), or one with--resource. - A resource with a Dockerfile becomes
runtime: docker; one with apackage.jsonbecomesruntime: node. - The
service.jsonportis written asPORT, because Render routes traffic to$PORT. - Every other env name is written with
sync: false, so Render asks for the value. Names that are not valid variable names are left out with a warning. healthCheckPathcomes fromservice.json(default/health).- Paths are relative to the git repository root, which is where Render reads them, and the file is written there by default.
--outmoves the file but not the paths. - Two resources that become the same service name (
api_v1andapi-v1) are refused.
wrangler
- One resource.
maincomes frompackage.jsonmain, or the first ofsrc/index.ts,src/index.js,src/worker.ts,src/worker.js,index.ts,index.js. - A resource with a Dockerfile, or without a
wrangler,@cloudflare/workers-typesorhonodependency, is refused unless--allow-non-worker. --route api.example.comwrites a Custom Domain route. Wildcards are refused: Custom Domains do not accept them.- Env names are listed in a comment for
wrangler secret put.
Develop
npm install
npm run typecheck && npm run lint && npm run build && npm testCompose
flisk-export compose # writes .autogenerated/docker-compose.yml
flisk-export compose --check # exit 1 when that file is out of date (for CI)Writes a standalone docker-compose.yml from the bring-your-own service.json files (image or dockerfile, env,
secrets.required, envFile, profiles, models, volumes, extraPorts, dependsOn, healthCheck, sidecarOf, container). It runs without Flisk (docker compose --env-file .env -f .autogenerated/docker-compose.yml up -d from the project root, since Compose looks for .env next to the file it reads): no external
networks, no FLISK_* variables, no generated secrets. ${VAR} references in env, and every name in secrets.required, pass through as ${NAME} for Compose to read from .env.
A volume's name (the Docker volume an install already has) is kept, and the project is named after its stack (or, when .flisk/project.json has composeProjectNames.<stack> from flisk-import, the Compose project name it had before, such as pl_mail), so docker compose up finds the same data as before.
An image with Compose variables (postgres:${POSTGRES_VERSION:-18}-alpine) is written as it is, for Compose to resolve; restart: "on-failure:N" keeps N. From container: stopGracePeriod becomes stop_grace_period, networkAliases become networks: { default: { aliases } } (not on a sidecarOf service, which has no network of its own), extraHosts become extra_hosts and ulimits stay ulimits. Each value is checked so it cannot add YAML keys; one that does not fit is an error.
healthCheck.command becomes a Compose healthcheck (with startPeriod as start_period); a service that lists a checked service in dependsOn waits for service_healthy (only when that healthcheck is written: a service with only healthCheckPath, or enabled: false, is waited for with service_started), and a dependsOn entry written as { name, condition } (flisk#2983) keeps its condition. buildArgs become build.args, logging stays logging, a bind source ${NAME:-./path} keeps reading NAME with its default rewritten for this file, selinux becomes the :z/:Z mount option, and an image may use ${NAME:?message} (Flisk 1.4.28 fields). container.command and container.entrypoint (Flisk 1.4.31) become Compose command: and entrypoint: lists as written ($$ and ${VAR} stay, an empty entrypoint drops the image's ENTRYPOINT). A service with no restart gets none (Compose's default), as the project's own Compose file had it. and one that lists a restart: "no" job waits for service_completed_successfully.
Other resource types and command (native) services are not exported. The file is generated: change service.json and run it
again with --force. It never starts a container or calls an API.
License
MIT
