Deploy your first app

Reading · 10 min · Module 1, lesson 2 of 436 min left in this module

Module 1 · Your first deployLesson 2 of 4

Goal: Deploy a container image to a live HTTPS URL and say where it landed in your account.

3:40 · captions and chapters · narrated with an AI-generated voice
Transcript

Narration uses an AI-generated voice.

[00:00] Where we're going

In the next few minutes, you'll put an app on the internet, on its own secure web address. And it takes one command.

Here's where we're headed. That's the app, running on its own HTTPS address. Now let's get there, starting from nothing.

[00:18] The big idea

Here's the big idea. You give ComputeSphere an image. That's your app, packaged up and ready to run. ComputeSphere runs it on a spherelet. That's the unit of compute your app lives on. Then it puts it behind HTTPS, and gives you a web address. No servers to set up first.

[00:39] Install csph

First, we need the command line tool, the ComputeSphere CLI. On a Mac, it's one brew command. If you're on Linux or Windows, the lesson page has those steps too. And that's it, installed. Asking for the version confirms it.

[00:56] Sign in

Next, let's sign in, with the CLI's login command. It shows you a short code, and a link to open.

In the browser, enter that code, check it matches your terminal, and allow access.

And you're signed in. This works from any terminal, even over SSH, or inside a coding agent.

[01:20] Deploy

Okay, this is the fun part. A deploy needs just three things. First, the image. That's your app, packaged up and ready to run. Second, a name. I'll call mine hello-web. And third, the port. That's the number your app listens on, and for this one, it's eighty eighty. Now, if you remember one thing from this video, make it this: if the port is wrong, your app still starts... but nothing can reach it. Almost everyone runs into that at some point. So take a second, check the port, and then press Enter.

There we go. ComputeSphere creates a web service for you, and starts a deployment. Deploying means it's pulling your image, and starting it up.

[02:08] Deployment states

Every deployment ends up in one of these states. Running means your app started, and it's serving. Failed means something stopped it. When that happens, the deploy log tells you why.

[02:22] Check it works

And there it is. Running. That web address is yours, and it already has a certificate on it.

Let's make sure it answers. A two hundred. That means it's working. And here it is in the browser. Your app, on the internet, over HTTPS.

[02:43] In the console

Everything you just did from the terminal shows up in the console, too. Here's your service, and its status. And in its settings, you'll find the image it's running, and the port, eighty eighty.

And this is the deploy log. It lists every step the deployment took. When something goes wrong, this is the first place to look. We'll break things on purpose in a later module, so you'll get plenty of practice.

[03:12] Recap and your lab

So, a quick recap. An image, a name, and a port. One command, and ComputeSphere handles the servers, the certificate, and the address.

Now it's your turn. Head to the lab, deploy hello-web yourself, and add its health check. Then work through Check your work, one item at a time. I'll see you in the next lesson.

Key idea

A web service needs three things: an image to run, a name, and the port the app listens on. Give ComputeSphere those and it returns an HTTPS address.

The model in 60 seconds

  • Your account holds billing and members.
  • A project groups the parts of one product; yours is learn.
  • An environment is an isolated copy of that product; yours is lab.
  • A service is one running part, like a web server.
  • A spherelet is one running copy of a service, with a fixed amount of CPU and memory.

Module 2 goes through each one properly.

Deploy hello-web

csph deploy --image quay.io/computesphere/learn-hello-web:1.0.0 --name hello-web --port 8080

--image is the container image, --name becomes part of the URL, and --port is where the app listens (8080 if you leave it out).

If the port is wrong, the app starts but nothing can reach it.

Watch it go live

csph waits for you:

Applied 1 resource(s) — status: success
  ✓ hello-web (web-service) — created
deployment… (Deploying)
✓ deployment 3f9c2a71-… is Running
  https://d-hello-web-3f9c2a71.computesphere.app

Deploying means the image is being pulled and started. Running means it's live and serving. The last line is your URL, with a certificate already on it. In the console, the same URL is on the service's page.

curl -I https://d-hello-web-3f9c2a71.computesphere.app

HTTP/2 200 means it's answering. Open it in a browser too.

Slow app, or you don't want to wait?

csph waits up to five minutes by default. Add --wait-timeout 10m for an app that starts slowly, or --no-wait to return as soon as the deployment has started.

Where it landed

csph context shows the account, project and environment csph deployed into: yours, learn and lab. In the console, open Projects, learn, then the lab environment, and hello-web is there.

Check yourself

Your app listens on port 3000, but you deployed it with --port 8080. What happens?