Skip to content

Instantly share code, notes, and snippets.

@ludoch
Created November 8, 2019 13:29
Show Gist options
  • Save ludoch/f9bc361e2a86a70757ac2f98e53429f0 to your computer and use it in GitHub Desktop.
Save ludoch/f9bc361e2a86a70757ac2f98e53429f0 to your computer and use it in GitHub Desktop.
Google App Engine Static Content Serving
#!/bin/sh
# Inspiration: https://nsirap.com/posts/006-google-app-engine-with-hugo/
# Create a directory of static content to deploy
mkdir -p gae/www
cd gae
#put static content web site under a www directory
#
cat > app.yaml
runtime: java11
handlers:
- url: /robots.txt
static_files: www/robots.txt
upload: www/robots.txt
secure: always
# file with extensions (longer cache period)
- url: /(.*\.(css|js|woff|woff2|ico|png|jpg))
static_files: www/\1
upload: www/(.*)
expiration: "14d"
secure: always
# file with extensions
- url: /(.*\..*)
static_files: www/\1
upload: www/(.*)
secure: always
# assume file without extensions use index.html
- url: /(.*)/
static_files: www/\1/index.html
upload: www/(.*)/index.html
secure: always
- url: /
static_files: www/index.html
upload: www/index.html
secure: always
CRTL-D
gcloud app deploy .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment