Django multi-server compressor

I was fortunate enough to open django_compressor and implement it in our stack, which is deployed on many servers (currently 6, but when we deploy small virtual machines.)

Now everything is fine and dandy if you use django_compressor at its best. CSS / JS Source Compression

However, tell me, now I want to introduce some type of pre-compiler. Let them say that for this example it is LESS (css). The thought process for this is quite simple:

  • Install node, npm and a smaller package on the server.

  • Add less to your precompilers!

    COMPRESS_PRECOMPILERS = (('text / less', 'lessc {infile} {outfile}'),)

Now you are deploying and your server is compiling fewer files. Everything is fantastic!

Now add 8 more servers and you have to install node, npm and less on each server?

That something seems wrong, and I feel that something is missing. I believe the Django community has encountered this problem before.

My thoughts so far have been:

  • Use post-commit to compile CSS on a development machine. This means that through django_compressor we refer to the compiled static file in HTML, and our repository contains both compiled and non-compiled versions. My only downside is that it does not take half the advantages of django_compressor and can be tedious for developers?

  • Connect it and create node, npm and less of the server stack.

Update

I did some additional inspections, and it seems that using the COMPRESS_OFFLINE flag (or just --force) with the control command will lead to the creation of a stand-alone manifest file that does what I need (tested only locally). So setting this up with a pre-deployed hook likes to be the answer.

Of course, still open to other ideas :-)

+4
source share
2 answers

In combination with the tips in the comments on COMPRESS_OFFLINE you can look at the django-staticfiles repository stuff. For example, you can host static files on amazon s3, so hosting all of this on one static server and using it from all your servers can also be a good solution. You do not need to do anything with static (and compressed) files on separate servers.

An alternative solution for multiple servers: I created a user structure (docs.fabfile.org) script that installs / configures the material on our servers. I just recently started using coffeescript and less, but these two finally end in my fabfile. This solves the installation problem for me.

(Alternatives to fabfile are things like a custom debian package with standard dependencies. Or a chef or puppet or something like that.)

0
source

you can use the puppet to set

0
source

Source: https://habr.com/ru/post/1394627/


All Articles