loading...
Cover image for Add Static Assets to Deployment - Building SaaS #29

Add Static Assets to Deployment - Building SaaS #29

mblayman profile image Matt Layman Originally published at mattlayman.com ・2 min read

In this episode, we pushed CI built static files to S3, then pulled those files into the Ansible deployment. This is part of the ongoing effort to simplify deployment by moving work to CI.

Last time, we processed static files like JavaScript, CSS, and images using webpack on Circle CI. Once the files were processed, I used the tar command to create a tarball (i.e., a .tar.gz file) that contains all the static assets.

The first task from this episode was the upload the generated tarball to AWS S3. I created an S3 bucket where the asset tarballs can live. We then used the Circle CI AWS S3 orb to push the generated tarball to the new S3 bucket.

With the tarball on S3, we were finally ready to move to deployment. I created Ansible tasks to:

  1. Create a directory for asset tarballs to live on the server.
  2. Pull a tarball from S3 and store it in the directory.
  3. Extract the tarball files into the static root directory where Nginx can serve the files to users.

I didn't quite finish it all because some file permission issues popped that we still need to resolve. Next time we will fix those issues, then do the fun stuff of ripping out the old deployment steps.

Show notes for this stream are at Episode 29 Show Notes.

To learn more about the stream, please check out Building SaaS with Python and Django.

Discussion

pic
Editor guide