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.
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.
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.
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.
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.txtand Start command togunicorn --bind 0.0.0.0:5000 app:app.Replace the default start command: this app has no
main.py.0.0.0.0lets traffic from outside the app reach it.You should seePython 3.12 with your build and start commands filled in.
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.
Deploy and watch the build
Choose Deploy, then open the service's Builds tab.
Check yourself
You should seeIn the Builds tab: Queued, Building, Deploying, then Running.
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.