As a proof of concept, we should be able to build a buildpack-based image for a specific tool in Toolforge and run the webservice using it.
For now, we're focusing on Python 3.7 due to simplicity and my familiarity with it.
As a proof of concept, we should be able to build a buildpack-based image for a specific tool in Toolforge and run the webservice using it.
For now, we're focusing on Python 3.7 due to simplicity and my familiarity with it.
Mentioned in SAL (#wikimedia-cloud) [2020-10-29T21:33:16Z] <legoktm> published docker-registry.tools.wmflabs.org/toolbeta-test image (T265681)
Mentioned in SAL (#wikimedia-cloud) [2020-10-29T22:20:50Z] <legoktm> switched test tool over to use buildpack image (T265681)
legoktm@toolsbeta-proxy-1:~$ curl -H "Host: test.toolforge.org" localhost Hello to the new buildpack-based world!
Wheeee
I wrote a basic flask app:
# License: CC0-1.0 from flask import Flask app = Flask(__name__) @app.route('/') def index(): return 'Hello to the new buildpack-based world!'
Then built the buildpack-based image:
And then I deployed it in toolsbeta:
This doesn't work on tools, only toolsbeta, pending T265557 things
Test with:
andrew@toolsbeta-proxy-3:~$ curl -H "Host: test.toolforge.org" https://localhost -k Hello to the new buildpack-based world!
I went ahead and put the example through the mill deploying it in toolsbeta from my GitHub repo though the Tekton pipeline instead of from NFS with pack or whatever. The particular builder's resulting image ends up pretty large (218 MB), which that's nowhere near the size of a standard Toolforge image (which is like 600MB easy). By comparison, using a paketo builder, I set up a much more complex ruby image that was only 43MB.
toolsbeta.test@toolsbeta-sgebastion-04:~$ curl -H "Host: test.toolforge.org" -k https://test.toolsbeta.wmflabs.org Hello to the new buildpack-based world!
That said, paketo doesn't come with a python build pack at the moment. I'd have to use Heroku or Google's to get that.
I was ablet o build (with buildpacks), deploy (manually) and run a webservice on toolsbeta manually.
toolsbeta.test@toolsbeta-sgebastion-05:~$ toolforge build-list run_name status start_time end_time source_url repo_url image_name image_tag builder_image test-buildpacks-pipelinerun-9hv4d ok 2022-04-14T09:54:52Z 2022-04-14T09:56:15Z https://github.com/david-caro/wm-lol.git harbor.toolsbeta.wmflabs.org/test python snap docker-registry.tools.wmflabs.org/toolforge-buster0-builder
# Edited the deployment and remove replicasets/pods to force refresh # dcaro@toolsbeta-proxy-3:~$ curl -v -H "Host: test.toolforge.org" https://127.0.0.1 --insecure -o /dev/null ... < HTTP/2 200 < server: nginx/1.14.2 < date: Thu, 14 Apr 2022 10:05:56 GMT < content-type: text/html; charset=utf-8 < content-length: 5371 < strict-transport-security: max-age=31622400 < x-clacks-overhead: GNU Terry Pratchett < permissions-policy: interest-cohort=() < content-security-policy-report-only: default-src 'self' 'unsafe-eval' 'unsafe-inline' blob: data: filesystem: mediastream: *.toolforge.org wikibooks.org *.wikibooks.org wikidata.org *.wikidata.org wikimedia.org *.wikimedia.org wikinews.org *.wikinews.org wikipedia.org *.wikipedia.org wikiquote.org *.wikiquote.org wikisource.org *.wikisource.org wikiversity.org *.wikiversity.org wikivoyage.org *.wikivoyage.org wiktionary.org *.wiktionary.org *.wmcloud.org *.wmflabs.org wikimediafoundation.org mediawiki.org *.mediawiki.org wss://test.toolforge.org; report-uri https://csp-report.toolforge.org/collect; < { [5371 bytes data] 100 5371 100 5371 0 0 187k 0 --:--:-- --:--:-- --:--:-- 194k * Connection #0 to host 127.0.0.1 left intact
So almost there, missing the webservice cli part, and deploying in tools instead of tolosbeta for the POC.