Skip to main content

Deploy your first app on Cloider

This tutorial deploys a small web app to Cloider and then walks through the everyday tasks around it: watching the build, opening the app on its free HTTPS address, setting an environment variable, reading the logs and deploying a new version. It takes about ten minutes.

An app on Cloider is your source code, built into a container image and run for you. You bring the code; Cloider detects the language, builds it (with your Dockerfile if the project has one, or with buildpacks if it doesn't), runs it and gives it a URL. You don't manage servers, clusters or certificates. Read the Apps overview for the full picture.

Before you begin​

  • A Cloider account. See Create an account.
  • For the CLI path, the cloider CLI installed and logged in with Read and write access. See Install the CLI.
  • Some code to deploy. This tutorial uses a minimal Node.js server, but any language Cloider supports works (see Supported languages), and so does a folder of static HTML.

What happens when you deploy​

Every deploy creates a numbered build (version 1, 2, and so on). The app's status follows the build through these steps:

StatusWhat is happening
PendingThe source archive is still being uploaded
QueuedThe build is waiting for a builder
BuildingCloider is building a container image from your code
DeployingThe new image is being applied
StartingThe new containers are pulling the image and starting up
ReadyThe new version is running and serving requests
FailedThe build or start failed. The build log says why, and you can retry it

If an app already has a working version, a failed build doesn't take it down: the previous version keeps serving.

Step 1: Prepare the code​

Create a folder called hello with two files:

package.json
{
"name": "hello",
"version": "1.0.0",
"scripts": {
"start": "node server.js"
}
}
server.js
const http = require('http');

const port = process.env.PORT || 8080;
const greeting = process.env.GREETING || 'Hello';

http
.createServer((req, res) => {
console.log(`${req.method} ${req.url}`);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(`${greeting} from Cloider!\n`);
})
.listen(port, () => console.log(`Listening on ${port}`));

Two things matter for any app you deploy:

  • Listen on the port Cloider gives you. An app built from source receives the port in the PORT environment variable. Use it, or make sure the port you set when you create the app is the one your code listens on.
  • Start with one command. Cloider uses the project's own start script (here npm start) or Procfile. You can also set a Start Command yourself.
Keep secrets and build output out of the upload

The CLI leaves out everything .gitignore lists, plus .git and .cloider. To leave out more without changing .gitignore, list it in a .cloiderignore file with the same syntax. An upload can hold up to 2000 files and 100 MB.

Step 2: Deploy​

  1. Open Apps in the sidebar and click Create App.

    The Bring your own code step of Create App, with GitHub, GitLab and Bitbucket import buttons, a Docker image button and an upload drop zone
    Step 1 of Create App: import a Git repository, deploy a Docker image or upload your code.
  2. Under Application source, drag the hello folder onto the drop zone, or click choose a folder. A zip file or a single HTML file works too. To deploy from a repository instead, click GitHub, GitLab or Bitbucket under Import a Git repository (see Deploy from Git), and to run an image you already built, click Docker image (see Deploy a Docker image).

  3. Cloider uploads the code and looks at it. The Configure your app step opens with what it detected under We had a look at your code.

  4. Fill in the form:

    • App Name: hello. Lowercase letters, digits and dashes, 2 to 64 characters, starting with a letter.
    • Port: 8080.
    • Start Command: leave empty, so npm start runs.
    • Give this app a free subdomain: leave on, and type hello-acme in Subdomain. Wait for hello-acme.cloider.app is available.
    • Environment variables, Build variables and Build arguments: leave empty for now.
  5. Click Create App.

Step 3: Watch the build​

The first build turns your code into a container image, so it takes a little while. You can follow it live.

The app page opens after Create App. Its status moves through Queued, Building, Deploying and Starting to Ready. Open the Builds tab and click Logs on the build to see the build output as it happens.

The Builds tab of an app with the latest build's log output open
Build logs show every step of the build.

Step 4: Open the app​

When the status is Ready, the app answers on its URL. The URL is on the app's Overview tab, printed by cloider deploy, and opened in your browser by cloider app open hello.

curl https://hello-acme.cloider.app
Output
Hello from Cloider!

HTTPS is set up for you. You can add your own domain later, see App domains.

Step 5: Set an environment variable​

Environment variables configure the running app without changing the code. Changing them restarts the app with the new values; no new build is needed. Mark a value as secret to keep it out of every listing.

  1. Open the app and go to the Environment tab.
  2. Under Environment variables, click Add variable.
  3. Type GREETING as the name and Hi as the value. To store a value as a secret, click the lock icon next to it.
  4. Click Save changes.

After the restart, curl https://hello-acme.cloider.app answers Hi from Cloider!. Read Environment variables for build time variables and secrets.

Step 6: Read the logs​

Everything your app prints to standard output and standard error is in its logs. The example server prints one line per request.

Open the app's Logs tab. New lines appear as they are printed.

More in Logs.

Step 7: Deploy a new version​

Change the code, for example the text in server.js, and deploy again.

Open the app's Builds tab, click Deploy new version and upload the folder again. An app imported from Git shows Deploy latest commit instead, and also deploys on every push to its branch unless you turn that off.

The current version keeps serving while the new one builds, and if the new build fails, the current version stays up. When a new version reaches Ready, the one before it is marked Superseded in the build history. Read Builds and deployments.

Verify​

  • The app's status is Ready in the dashboard, or cloider app status hello prints Ready.
  • curl https://hello-acme.cloider.app answers with your text.
  • The Builds tab, or cloider app builds hello, lists versions 1 and 2, with version 2 live.

Troubleshooting​

SymptomLikely cause and fix
The build is FailedRead the build log. Common causes are a missing start script, a dependency that fails to install, or a Dockerfile error. Fix it and deploy again, or retry the build.
The app never gets past StartingThe app isn't listening on its port, or it crashes on start. Check the Logs tab and that the code listens on PORT.
Only up to 2000 files can be uploaded, zip your project first.The folder has too many files, usually node_modules. Leave it out (the CLI follows .gitignore) or upload a zip.
You have read-only access to this account, you can not create apps!Your role is Restricted, or you logged the CLI in with a read only token. Ask an owner or admin, or run cloider login again with Read and write.
The subdomain is takenPick another name. Free subdomains are unique across all of Cloider.

More in Apps troubleshooting.

Next steps​

Frequently asked questions

How do I deploy an app to Cloider?

In the dashboard, open Apps, click Create App, upload your code or import a Git repository, and click Create App. From a terminal, run cloider deploy in the project folder.

Does my app need a Dockerfile?

No. Without a Dockerfile, Cloider builds your code with buildpacks. If the project has a Dockerfile, Cloider builds that instead and uses its CMD to start the app.

Which port should my app listen on?

The port you set when you create the app, 8080 by default with the CLI. An app built from source also gets that port in the PORT environment variable, so listening on process.env.PORT or the equivalent always works.

Does changing an environment variable rebuild my app?

No. Changing environment variables restarts the app with the new values. Changing build arguments or build variables builds the app again.

What happens to the running version if a new build fails?

It keeps running. A failed build only takes an app down when the app has no other version to serve.

How big can an app upload be?

Up to 2000 files and 100 MB. Leave out dependencies and build output, which Cloider installs and builds itself.