Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup prod hosting of static media for AWS prod #2949

Closed
pmac opened this issue Nov 7, 2017 · 9 comments · May be fixed by LadyK-21/kitsune#5 or violethaze74/kitsune#5
Closed

Setup prod hosting of static media for AWS prod #2949

pmac opened this issue Nov 7, 2017 · 9 comments · May be fixed by LadyK-21/kitsune#5 or violethaze74/kitsune#5

Comments

@pmac
Copy link
Member

pmac commented Nov 7, 2017

For dev we'll probably just serve static media from the primary docker container via whitenoise, but that won't scale to prod traffic. We have some options:

  • Sync static files to S3 and serve via a CDN
  • Deploy a separate Nginx container for serving said files, optionally with a CDN in front
  • Put a CDN in front of the entire site (potentially a lot more work)
@pmac pmac added this to the AWS Migration milestone Nov 7, 2017
@glogiotatidis glogiotatidis added this to Queued (Max 6) in SUMO AWS Migration Nov 9, 2017
@glogiotatidis glogiotatidis moved this from Queued (Max 6) to In Progress (Max 6) in SUMO AWS Migration Nov 9, 2017
@glogiotatidis
Copy link
Contributor

Deploy a separate Nginx container for serving said files, optionally with a CDN in front

In this case we can also build a single image that will either run nginx-light or gunicorn depending on the value of a env variable. This would simply the building pipeline, keep the statics with the code, while we keep the flexibility to scale each function (static, app) seperately.

@glogiotatidis glogiotatidis moved this from In Progress (Max 6) to Backlog in SUMO AWS Migration Nov 13, 2017
@bookshelfdave
Copy link
Contributor

bookshelfdave commented Nov 13, 2017

regarding S3 / Cloudfront: mozmeao/infra#391 (click through to the viewsource issue)

@glogiotatidis
Copy link
Contributor

glogiotatidis commented Jan 15, 2018

I suggest that we go fwd with the following plan:

  1. Enable WhiteNoise for all dev, stage, prod
  2. Setup CDN to serve only static files and not the whole site. See instructions from WhiteNoise docs.

This way:

  • Statics remain with the code and we build only one docker image
  • We don't have to manage S3 headers and deal with other S3 oddities
  • We don't maintain nginx deployments
  • Avoid the work and problems related to putting the entire site behind CDN.
  • We maintain current SEO as the content will be only accessible through support.m.o and not the CDN url.

To move forward we need:

What do you think @mozilla/sumo?

@glogiotatidis glogiotatidis removed their assignment Jan 15, 2018
@pmac pmac moved this from Backlog to Discussing in SUMO AWS Migration Jan 22, 2018
@bookshelfdave
Copy link
Contributor

How do these CDN setting look? mozmeao/infra#694

@glogiotatidis
Copy link
Contributor

Switch to Whitenoise Storage backend (code)
Bonus points by enabling Brotli compression (docker images need update to include packages)

We're currently using Pipeline which takes care of static files collection and generates bundles with the assets. Pipeline works OK and the bundles are useful and in addition to what whitenoise offers. So we keep the Pipeline based Storage backend as we have it now.

I tested the current Whitenoise implementation and it sets proper headers for static files
Cache-Control: max-age=315360000, public, immutable.

tl;dr no changes needed on the code side to move fwd with this. We can evaluate replacing Pipeline with something different / more modern in the future.

@bookshelfdave
Copy link
Contributor

Setup CDN to serve only static files and not the whole site. See instructions from WhiteNoise docs.

per the WhiteNoise docs, each CDN is limited to static/*.

(See the Behaviors tab for each CDN below)

@glogiotatidis
Copy link
Contributor

I did setup sumo-dev.frankfurt.moz.works to use dev CDN and it works like a charm. nice work as always @metadave

I guess all we need now is the mozilla.net dns entries.

@glogiotatidis glogiotatidis moved this from Discussing to In Progress (Max 6) in SUMO AWS Migration Jan 29, 2018
@bookshelfdave
Copy link
Contributor

Sorry, should have dropped the bug # in when I created it last week:
https://bugzilla.mozilla.org/show_bug.cgi?id=1433561

@glogiotatidis
Copy link
Contributor

This is now done. Update from bug

CNAMEs created.

FQDN 		Target 	
static-media-dev-cdn.sumo.mozilla.net 	CNAME 	static-media-dev-cdn.sumo.moz.works


FQDN 		Target 	
static-media-stage-cdn.sumo.mozilla.net 	CNAME 	static-media-stage-cdn.sumo.moz.works


FQDN 		Target 	
static-media-prod-cdn.sumo.mozilla.net 	CNAME 	static-media-prod-cdn.sumo.moz.works```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
3 participants