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.

Once your fork is connected, every push to the service's branch builds and deploys by itself. You start the first build when you create the service.

  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. Under Import a Git repository, pick your connection and choose Import next to your fork. On the next page, in the Service card, edit Name to flask-web.

    You should seeThe configure page, with your fork and main at the top.

  4. Set the runtime

    In Build and run, Build shows Dockerfile, detected from the repo. Edit it, set Build method to Managed and 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. Check the port

    Keep the Flex size and 1 spherelet in Size. In Build and run, check Port is 5000, where the app listens, detected from the repo.

    You should seePort 5000 in Build and run.

  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 isn't 5000. Set Port to 5000 in Build and run and redeploy.

Changed the code? Ship it

Push it to the service's branch. ComputeSphere builds the new commit and rolls it out, and the build shows in the Builds tab. To rebuild without a new commit, open the service, choose Redeploy, keep Build & deploy selected, and confirm.