Learning paths / Deploy on ComputeSphere / Deploy from a repository

Lab: build from your repository

Verified lab · 30 min · Module 3, lesson 4 of 640 min left in this module

Module 3 · Deploy from a repositoryLesson 4 of 6

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

Goal: Deploy a web service that ComputeSphere builds from a GitHub repository, and prove it's live.

You need A GitHub account, and the lab project and environment from lesson 5.1.1.

Pushing to your repository doesn't deploy yet. You start every build yourself, from the console.

  1. Fork the sample

    On GitHub, fork github.com/computesphere-samples/computesphere-python-flask-example. It's a small Flask app that serves one page on port 5000.

    You should seeYour own copy of computesphere-python-flask-example under your GitHub account.

  2. Connect your fork

    Follow lesson 5.3.1 and give the ComputeSphere app access to only your fork.

    You should seeThe GitHub connection listed under Connections.

  3. Create the service

    In your lab project, choose New service, then Web Service. Name it flask-web and choose Git repository as the source. Under Configuration, choose Private (Connections), your connection, your fork and the main branch.

    You should seeThe Runtime step of the new service form.

  4. Set the runtime

    Choose Python, version 3.12. Set Build command to pip install -r requirements.txt and Start command to gunicorn --bind 0.0.0.0:5000 app:app. Replace the default start command: this app has no main.py. 0.0.0.0 lets traffic from outside the app reach it.

    You should seePython 3.12 with your build and start commands filled in.

  5. Set the port

    Keep the Flex shape and 1 spherelet. Under Networking, change the port from 80 to 5000, where the app listens.

    You should seePort 5000 under Networking.

  6. Deploy and watch the build

    Choose Deploy, then open the service's Builds tab.

    Check yourself

    While it builds: if the build ends Built but the service ends Failed, where do you look?

    You should seeIn the Builds tab: Queued, Building, Deploying, then Running.

  7. Open the URL

    curl -I https://<your-flask-web-url>
    

    You should seeThe Flask page in your browser, and a 200 status from curl.

Check your work

  • If this doesn't pass

    Build Failed: open it in the Builds tab and fix the first error (lesson 5.3.3), usually a typo in the build command. Built but the service Failed: check the start command, then run csph logs flask-web. An error about main.py means the default start command is still set.

  • If this doesn't pass

    Running but no answer: the port is probably still 80. Set it to 5000 in the service's Networking settings and redeploy.

Changed the code? Ship it

Open the service, choose Redeploy, keep Build & deploy selected, and confirm. ComputeSphere builds the latest commit on your branch. Automatic deploys on push are on the way.