Learning paths / Containers / Path challenge

Lab: ship your own container

Verified lab · 40 min · Path challenge

Path challengeContainers

Self-checked for now. Automatic checking arrives with sign-in; until then, tick off each item under Check your work yourself.

Goal: Push the image you built to your own public registry repository and deploy it to ComputeSphere with a health check, then prove it answers on its URL.

You need A ComputeSphere account and csph set up, from lesson 5.1.1, Set up; your sample from lesson 3.8.5 with its Dockerfile; and a Docker Hub or GitHub account.

No ComputeSphere account or csph yet?

Follow lesson 5.1.1, Set up: sign up, create the learn project and its lab environment, install csph, and run the use commands. csph context should show learn and lab.

Replace <you> with your Docker Hub or GitHub username, in lower case, and <language> with node, python or go.

  1. Build for ComputeSphere

    In your sample's folder:

    docker build --platform linux/amd64 -t docker.io/<you>/containerize-<language>:1.0.0 .
    

    ComputeSphere runs spherelets on amd64 machines. On an Apple silicon Mac, Docker builds for arm64 unless you say otherwise.

    You should seeThe build finishes and names your image.

  2. Push it

    Sign in with your token as in lesson 3.5.3 (a classic token with write:packages for GitHub):

    read -s CR_PAT          # paste the token, then Enter
    echo "$CR_PAT" | docker login -u <you> --password-stdin
    unset CR_PAT
    docker push docker.io/<you>/containerize-<language>:1.0.0
    

    On GitHub, the package starts private: open it under your profile's Packages, then Package settings, and change its visibility to Public.

    You should seeLogin Succeeded, then layers uploading and a line with your tag and a sha256 digest.

  3. Write computesphere.yaml

    version: "2"
    services:
      - name: ship-container
        type: web-service
        # or ghcr.io/<you>/containerize-<language>:1.0.0
        image: docker.io/<you>/containerize-<language>:1.0.0
        port: 3000
        health_check_path: /healthz
    

    Use your full image name from step 1. port is where the app listens (the console's Port); the last line sets the health check's Endpoint path and turns it on.

    You should seeThe file saved next to your Dockerfile.

  4. Deploy it

    csph deploy --file computesphere.yaml
    

    Check yourself

    Your new version fails its health check. What happens to it?

    You should see✓ ship-container (web-service) — created, then ✓ deployment … is Running and your URL.

  5. Prove it with the URL

    curl -i https://<your-ship-container-url>/healthz
    

    csph can report success before an update is healthy, so the URL is your proof.

    You should seeHTTP/2 200 and {"status":"ok"}.

  6. Confirm the health check

    In the console, open ship-container, then Settings, and find the Health check card.

    You should seeThe Health check card shows Path /healthz and Port 3000.

Check your work

  • If this doesn't pass

    Failed with an image error: check the image is public and the name matches what you pushed. Failed after starting: the image may be arm64; rebuild with --platform linux/amd64, push, and deploy again.

  • If this doesn't pass

    If it's Running but doesn't answer, check port is 3000, the port your app listens on.

  • If this doesn't pass

    Check health_check_path in computesphere.yaml is /healthz, then deploy the file again.