Ferdigheter · Apper
Publish a static site
Host a site that is only files (HTML, CSS, JavaScript, images) without a server of its own, with new versions and rollbacks in seconds.
An app on Skybu is either a server or a static site. A server runs in its own virtual machine. A static site is built the same way, but Skybu then copies one folder out of the built image and serves its files from a shared server: no virtual machine, nothing that counts against the project's memory, and going live or rolling back takes seconds.
Everything in the folder is public: anyone who can open the site can download every file in it.
In short
- Check that the app suits a static site (the table below). If it needs a server, deploy it as usual (
skill://apps/deploy-an-app). - Find the folder the build writes the site to, as a full path inside the built image:
/app/distfor most tools. - Deploy with
deploy_files(orcreate_upload+deploy_upload) withkind: "static",staticDirand, for a single-page app,staticFallback: "index". - Follow it with
get_deploymentuntil it islive. - To turn an existing app into a static site, or back, use
set_app_hostingand deploy again.
Static site or server?
| Choose a static site when | Choose a server when |
|---|---|
| The site is HTML, CSS, JavaScript and images, made by a build step or written by hand. | The app has server code: an API, server-side rendering, form handling on the server. |
| Data comes from APIs the browser calls itself. | The app reads the project's database (DATABASE_URL) while it runs. |
| Nothing secret is needed when it runs: everything in the files is public. | The app needs secrets while it runs: API keys, passwords, tokens. |
Settings are baked in at build time, such as VITE_*, NEXT_PUBLIC_* or PUBLIC_* variables. | Settings must change without a new build. |
Variables set with set_env_vars reach the build, so a framework can bake them into the files. They are not available afterwards, because nothing runs. Never put a secret in a variable a static build bakes in: it ends up in the files, readable by anyone.
Step 1: the folder
staticDir is the full path, inside the image the build makes, of the folder to publish. It must have an index.html at the top; otherwise the deploy fails with static_no_index.
Without a Dockerfile, Skybu builds the app with Railpack, which puts the app in /app. The folder is then /app/ followed by where the tool writes its output:
| Tool | Output | staticDir |
|---|---|---|
| Vite (React, Vue, Svelte, …) | dist | /app/dist (the default) |
| Astro | dist | /app/dist |
| Create React App | build | /app/build |
Next.js with output: "export" | out | /app/out |
| Plain HTML files, no build | the folder itself | /app |
Read the project's config before choosing: an outDir in vite.config.*, distDir in next.config.* or outDir in astro.config.* moves the output. With a root directory (rootDir) on a Git link, the app is still at /app.
With a Dockerfile, the folder is wherever the Dockerfile leaves the files, for example /usr/share/nginx/html or the WORKDIR plus the output folder. The image is never started, so it needs no CMD or server.
A Next.js app that is not a static export (it uses API routes, server components that fetch at request time or getServerSideProps) needs a server.
Step 2: deploy
{
"name": "deploy_files",
"arguments": {
"projectId": "<project id>",
"name": "kampanje",
"dataClass": "none",
"kind": "static",
"staticDir": "/app/dist",
"staticFallback": "index",
"files": [
{ "path": "package.json", "content": "{ \"name\": \"kampanje\", \"scripts\": { \"build\": \"vite build\" }, … }" },
{ "path": "package-lock.json", "content": "…" },
{ "path": "index.html", "content": "…" },
{ "path": "src/main.tsx", "content": "…" }
]
}
}
- Send the source, not the built files: Skybu runs the build. Leave out
node_modules,distand.envfiles. kind,staticDirandstaticFallbackapply only when the deploy creates the app.staticDirdefaults to/app/distandstaticFallbackto404.deploy_uploadtakes the same three arguments for sites over a few MB.- The data class and department are asked for as for any app (
skill://apps/deploy-an-app). A public site with no personal data is usuallynone.
Step 3: follow it
{ "name": "get_deployment", "arguments": { "deploymentId": "<deployment id>" } }
The statuses are the same as for a server. Once the build is done, publishing the files takes seconds. A live static deployment has staticFiles (how many files) and staticBytes (their total size).
Unknown addresses: 404 page or single-page app
staticFallback | An address with no matching file gets |
|---|---|
404 (default) | The folder's 404.html with status 404, or a plain 404 page if there is none. |
index | /index.html with status 200 when the path has no file extension, so the app's own router shows the page. Paths with an extension, such as a missing /logo.png, still get 404. |
Use index for single-page apps with client-side routing (React Router, Vue Router, TanStack Router): without it, opening /orders/42 directly or reloading it gives a 404. For a site with a page per address (Astro, a Next.js export, plain HTML), keep 404 and put a 404.html at the top of the folder.
Change an existing app
{ "name": "set_app_hosting", "arguments": { "appId": "<app id>", "kind": "static", "staticDir": "/app/build", "staticFallback": "index" } }
Give only what changes. The change applies from the next deploy: the version running now keeps serving until then, so deploy again (deploy_files, deploy_upload or deploy_latest_commit for an app linked to Git). kind: "server" turns a static site back into a server; its next version must listen on PORT like any server.
Previews of pull requests follow their app; set_app_hosting on a preview is refused with preview_hosting_follows_app.
Roll back
{ "name": "rollback_app", "arguments": { "appId": "<app id>", "deploymentId": "<deployment id>" } }
A static site switches back to the earlier version's files in a couple of seconds. When the organisation requires approval, an owner approves the rollback first, as for a server.
Limits
| Limit | Value |
|---|---|
| The folder, compressed | 200 MB |
| The folder, unpacked | 500 MB |
| Files | 20 000 |
A site over a limit fails to deploy, and the previous version keeps serving. Large media (videos, many big images) are better kept in the project's file storage (skill://files/store-files) and linked from the site.
Things to know
- Custom domains (
skill://domains/custom-domain) and members-only access (skill://access/members-only-apps) work the same as for a server. - There is no app log, because nothing runs. The build log is on the deployment (
get_deployment). - Outbound traffic rules do not apply: the site makes no requests of its own; the visitors' browsers do.