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

Static file mounting #3

Merged
merged 14 commits into from Nov 18, 2014

Conversation

Projects
None yet
2 participants
@rgbkrk
Member

rgbkrk commented Nov 18, 2014

This begins the adventure of both:

  • Sticking nginx in a container
  • Mounting static assets from the userland container to the nginx container

This also tosses the static.tar legacy file.

@rgbkrk rgbkrk changed the title from [WIP] Static file mounting to Static file mounting Nov 18, 2014

@rgbkrk

This comment has been minimized.

Show comment
Hide comment
@rgbkrk

rgbkrk Nov 18, 2014

Member

Alright, this is ready for review!

Member

rgbkrk commented Nov 18, 2014

Alright, this is ready for review!

@rgbkrk

This comment has been minimized.

Show comment
Hide comment
@rgbkrk

rgbkrk Nov 18, 2014

Member

This works! It's alive!

Member

rgbkrk commented Nov 18, 2014

This works! It's alive!

rgbkrk added a commit that referenced this pull request Nov 18, 2014

@rgbkrk rgbkrk merged commit ff9dee1 into master Nov 18, 2014

@rgbkrk rgbkrk deleted the static_files branch Nov 18, 2014

- name: nginx
apt: name=nginx state=present
- name: pull docker image for user containers
command: docker pull {{ tmpnb_image }}

This comment has been minimized.

@smashwilson

smashwilson Nov 18, 2014

Contributor

There's a trick you can use to register whether or not a newer image was actually pulled, which can save you extraneous restarts:

- name: pull the latest docker build
  command: docker pull myimage
  register: someimage
  changed_when: someimage.stdout.find('Downloaded newer image') != -1
  sudo: yes
@smashwilson

smashwilson Nov 18, 2014

Contributor

There's a trick you can use to register whether or not a newer image was actually pulled, which can save you extraneous restarts:

- name: pull the latest docker build
  command: docker pull myimage
  register: someimage
  changed_when: someimage.stdout.find('Downloaded newer image') != -1
  sudo: yes

This comment has been minimized.

@rgbkrk

rgbkrk Nov 18, 2014

Member

Hmmm, with that I'll need to start a new nginx container too then (so that it links to new static assets).

I'm not as worried about upgrading nodes in place since we can end up with a version mismatch here:

  1. User creates a notebook server
  2. (Some) assets are cached by their browser
  3. We upgrade the static files served by nginx
  4. They open a link to their server on a different browser, computer, etc.
  5. The notebook now uses different js/css than is served by nginx
@rgbkrk

rgbkrk Nov 18, 2014

Member

Hmmm, with that I'll need to start a new nginx container too then (so that it links to new static assets).

I'm not as worried about upgrading nodes in place since we can end up with a version mismatch here:

  1. User creates a notebook server
  2. (Some) assets are cached by their browser
  3. We upgrade the static files served by nginx
  4. They open a link to their server on a different browser, computer, etc.
  5. The notebook now uses different js/css than is served by nginx

This comment has been minimized.

@smashwilson

smashwilson Nov 18, 2014

Contributor

Hmmm, with that I'll need to start a new nginx container too then (so that it links to new static assets).

Yes, the idea is that later you can do:

- name: Restart nginx
  docker: image=nginx state=restarted
  when: someimage | changed

I'm not as worried about upgrading nodes in place since we can end up with a version mismatch here

Oh, right. I really wish the assets could be hash-fingerprinted, it would solve a lot of problems like this one...

@smashwilson

smashwilson Nov 18, 2014

Contributor

Hmmm, with that I'll need to start a new nginx container too then (so that it links to new static assets).

Yes, the idea is that later you can do:

- name: Restart nginx
  docker: image=nginx state=restarted
  when: someimage | changed

I'm not as worried about upgrading nodes in place since we can end up with a version mismatch here

Oh, right. I really wish the assets could be hash-fingerprinted, it would solve a lot of problems like this one...

This comment has been minimized.

@rgbkrk

rgbkrk Nov 18, 2014

Member

Even if we hash-fingerprint them, we're still serving a specific set from nginx rather than what any given container is necessarily running.

If we wanted to though, we could finish up the piece from tmpnb's tornado app that handles static asset serving. Right now it only serves static.tar when it could serve static for each path (making sure to key on image id).

@rgbkrk

rgbkrk Nov 18, 2014

Member

Even if we hash-fingerprint them, we're still serving a specific set from nginx rather than what any given container is necessarily running.

If we wanted to though, we could finish up the piece from tmpnb's tornado app that handles static asset serving. Right now it only serves static.tar when it could serve static for each path (making sure to key on image id).

This comment has been minimized.

@rgbkrk

rgbkrk Nov 18, 2014

Member

The better option, that I still haven't tried, is to try loading IPython's static assets over a CDN.

This involves setting the static_url setting for IPython's tornado server.

@rgbkrk

rgbkrk Nov 18, 2014

Member

The better option, that I still haven't tried, is to try loading IPython's static assets over a CDN.

This involves setting the static_url setting for IPython's tornado server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment