{"id":140,"date":"2023-04-01T21:55:59","date_gmt":"2023-04-01T19:55:59","guid":{"rendered":"https:\/\/www.mutareb.com\/?p=140"},"modified":"2023-04-02T22:11:05","modified_gmt":"2023-04-02T20:11:05","slug":"continuous-delivery-with-google-app-engine","status":"publish","type":"post","link":"https:\/\/www.mutareb.com\/index.php\/2023\/04\/01\/continuous-delivery-with-google-app-engine\/","title":{"rendered":"Continuous Delivery with Google App Engine"},"content":{"rendered":"\n<p>Create a new Github repo<\/p>\n\n\n\n<p>Create a project in GCP UI<\/p>\n\n\n\n<p>Setup GAE API (just activate), Permissions (go to IAM and add it) and Cloud Build as well<\/p>\n\n\n\n<p>activate cloud-shell and add ssh-keys if not already added to Github: i.e. type <code>ssh-keygen -t rsa<\/code> than upload key to Github ssh settings<\/p>\n\n\n\n<p>Create an initial project scaffold. <br><code>app.yaml<\/code>, <code>main.py<\/code>, <code>main_test.py<\/code> and <code>requirements.txt<\/code><\/p>\n\n\n\n<p>Finally, run describe using the <code>gcloud<\/code> command-line to verify the project is working.<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gcloud projects describe $GOOGLE_CLOUD_PROJECT<\/code><\/pre>\n\n\n\n<p>if not, do this to switch:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gcloud config set project $GOOGLE_CLOUD_PROJECT<\/code><\/pre>\n\n\n\n<p>Next, create an app engine app in the Cloud:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gcloud app create <\/code><\/pre>\n\n\n\n<p>Now create and source the virtual environment.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>virtualenv --python $(which python) venv\nsource venv\/bin\/activate\n\n# you can double check with this\nwhich python<\/code><\/pre>\n\n\n\n<p>Now install packages<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make install<\/code><\/pre>\n\n\n\n<p>Now, run flask locally.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python main.py<\/code><\/pre>\n\n\n\n<p>Finally deploy it<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gcloud app deploy<\/code><\/pre>\n\n\n\n<p>To automate deployment, create the cloudbuild.yaml file and push it to main:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>steps:\n -name: \"gcr.io\/cloud-builders\/gcloud\"\n args: &#91;\"apps\", \"deploy\"]\ntimeout: \"1600s\"<\/code><\/pre>\n\n\n\n<p>The on Google cloud search for &#8216;cloud build&#8217;, enable the following GCP Services in settings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>App Engine\nService Accounts<\/code><\/pre>\n\n\n\n<p>Then go to triggers, create a new trigger, connect it to the repo and select the &#8216;push to branch&#8217; event.<br>Now it will auto deploy on every push, just test it with a commit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a new Github repo Create a project in GCP UI Setup GAE API (just activate), Permissions (go to IAM and add it) and Cloud Build as well activate cloud-shell and add ssh-keys if not already added to Github: i.e. type ssh-keygen -t rsa than upload key to Github ssh settings Create an initial project&hellip; <a class=\"more-link\" href=\"https:\/\/www.mutareb.com\/index.php\/2023\/04\/01\/continuous-delivery-with-google-app-engine\/\">Continue reading <span class=\"screen-reader-text\">Continuous Delivery with Google App Engine<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[37,36],"series":[35],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-cloud-computing","tag-cd","tag-gae","series-cloud-computing","entry"],"_links":{"self":[{"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":2,"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/posts\/140\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/tags?post=140"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.mutareb.com\/index.php\/wp-json\/wp\/v2\/series?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}