You need A ComputeSphere account and csph set up, from lesson 5.1.1, Set up; the compose-stack sample from lesson 3.6.2; Docker; and a Docker Hub or GitHub account.
Setting up, and the trial's limit
Lesson 5.1.1 covers signing up, creating the learn project, installing csph and csph auth login.
This lab runs two Flex spherelets. The trial allows two at a time, so delete any other lab service first.
Build and push the web app
In
compose-stack, with<you>as your Docker Hub or GitHub username in lowercase:docker build --platform linux/amd64 -t <you>/compose-web:1.0.0 ./app docker push <you>/compose-web:1.0.0docker build --platform linux/amd64 -t ghcr.io/<you>/compose-web:1.0.0 ./app docker push ghcr.io/<you>/compose-web:1.0.0ComputeSphere runs
linux/amd64images, so build for that even on an Apple Silicon Mac.Never pushed an image?
Do lesson 3.5.3 first. It covers the token,
docker login, and making the image public, which ComputeSphere needs to pull it without credentials.Can't push your own image yet?
If you can't push your own image yet, use
quay.io/computesphere/learn-compose-web:1.3.0and come back to pushing in 3.5.3.You should seeA push that ends with a line holding 1.0.0 and a sha256 digest.
Point the deploy file at your image
Open
compose.deploy.yamland replace<your-registry>/compose-web:1.0.0with the name you pushed.You should seeimage: <you>/compose-web:1.0.0 (or the ghcr.io name) under web.
Import it
csph import compose -f compose.deploy.yaml --force--forcereplaces thecomputesphere.yamlfrom lesson 3.6.3, if you made one. Check thatAPI_URLis now afromServicereference toapi.You should see✓ wrote computesphere.yaml (2 services), and no warnings.
Create an environment with Private Network
csph regions list csph environments create --name compose-lab --region <region> \ --project <project-id> --private-network=true csph environments list --project <project-id>webreachesapiby its private address, which only works with Private Network on, and it must be on when the environment is created.You should seecompose-lab in the list, with its ID in the first column.
Apply the manifest
csph apply -f computesphere.yaml \ --project <project-id> --environment <compose-lab-id>With two services, apply returns once both are accepted.
You should seeApplied 2 resource(s) — status: success, with web and api both created.
Wait for both to be Running
In the console, open Projects, then
learn, thencompose-lab. Openweband copy its URL.Check yourself
You should seeweb and api both Running in compose-lab.
Check web can reach api
curl https://<your-web-url>/healthzYou should see{"status":"ok","api":"reachable"}
Check your work
If this doesn't pass
If apply printed failed, the line under it says why. An image-pull failure usually means the image is private or the name in compose.deploy.yaml doesn't match what you pushed.
If this doesn't pass
If web keeps failing, open its deploy log. An image built on Apple Silicon without --platform linux/amd64 won't start: rebuild, push, and apply again.
If this doesn't pass
api unreachable means the environment has no Private Network. Create a new environment with --private-network=true and apply into it.
Clean up
csph services list --project <project-id>
csph services delete <service-id> # once for web, once for api
csph environments delete <compose-lab-id>