Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker, web app static files. Best practices?

How do people tend to handle static assets in web deployment on docker?

For example, in a django app deployed in a container, do you have the app server serve up the static files from the container, or do you sync them to another server for a webserver to serve, or do you use a CDN?

If not serving from the app container, when do you push files to CDN or webserver: as part of the container build, or as a second process in the build, and how do you ensure both steps stay in sync?

like image 916
jvc26 Avatar asked May 11 '15 22:05

jvc26


People also ask

Is Docker good for web apps?

Docker is very useful for web applications running on a server or console-based software. But if your product is a standard desktop application, especially with a rich GUI, Docker may not be the best choice.

Where should I store Docker files?

The best way is to put the Dockerfile inside the empty directory and then add only the application and configuration files required for building the docker image. To increase the build's performance, you can exclude files and directories by adding a . dockerignore file to that directory as well.


1 Answers

You will have to use a form of cloud storage to achieve that. S3 for example. You can also host your static files just like a CDN. Since you're using django, consider reading this article. It explains how to host static files from within a django app.

As a Laravel user you could use Laravels built in flysystem support.

like image 77
M K Avatar answered Sep 22 '22 22:09

M K