DEV Community

Cover image for Add Static Assets to Deployment - Building SaaS #29
Matt Layman
Matt Layman

Posted on • Originally published at mattlayman.com

2

Add Static Assets to Deployment - Building SaaS #29

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.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay