Subscribe to my newsletter!| vsupalov.com
Tools I value and enjoy using at the moment.| vsupalov.com
Okay, how much has Docker has changed since 2018? Sometimes you are so comfortable with a tool, it fades into the background. You don’t even notice that it is moving and changing, while you are happily using it - after all, it’s doing everything you want from it, and it does not get in the way. This is pretty much what has happened to me and Docker. Occasionally, single topics like nifty features of BuildKit have caught my attention, but I have not taken the time to follow all developments.| vsupalov.com
It has happened. I have recently gotten what Tailwind CSS is about. Working with it has become a breeze, instead of copying code and hoping for the best. Don’t get me wrong - I don’t have a complete grasp of it, nor did I dive into more advanced topics yet! However, I feel confident to have generated enough understanding to code up almost any project I want with it. If you are a backend developer approaching Tailwind CSS (or a fellow ops-kin curious about giving it a try), you have come t...| vsupalov.com
Recently, I wondered how a Linux desktop environment that really fit my needs would look like. Well, okay. I was bored and could not do much else being sick, so the only thing left was idle reading and tinkering in between bouts of tiredness. I learned a lot! And I think it could be fun to share what I have discovered while playing around. Into The Unknown In recent years, I was using Ubuntu for my desktop/working needs.| vsupalov.com
‘The Kernel’ is a ominous sounding term which sometimes comes up when you talk about containers. To me, it felt a bit hand-wavy at times. Whenever it came up it was as a side-note. With the intention to move towards the actual topic right after. Understanding was assumed. Or at least there was a silent agreement that nobody had the intention to go any closer to the topic. “Containers share ‘The Kernel’ of the host you see.| vsupalov.com
ZFS is one of the technologies I have gotten to know a bit better recently (the other one being Nix, but more on that in another article). I would like to share what I learned, what got me interested and why I think ZFS is worth learning about. What is ZFS for? The glorious Arch Wiki has a great description of the benefits and technical parameters of ZFS. Here are a few key quotes: it is “an advanced filesystem” and “described as ‘The last word in filesystems’”.| vsupalov.com
A simple way to create a machine learning model which can generate text are markov chains. I had to adjust my workflows at this point, because just loading the whole dataset into memory started causing performance issues… So filtering submissions while loading them from disk was the way to go. Having all HN submission titles, it was pretty quick to filter out successful submissions (ones which received at least a few comments or upvotes), and provide them to a ready-made markov chain librar...| vsupalov.com
I’ve recently started to play around with HN data. A first look at the first 10 years was interesting enough. But now that the dataset is almost complete, I wanted to dive a bit deeper. What are frequent suffixes and prefixes of HN submission titles? Note: the analyzed dataset isn’t quite complete, but large enough to be representative at this point. We have 3 million submitted posts to work on.| vsupalov.com
I’ve recently started to play around with HN data. Here are a few interesting things I found while getting to know the dataset. The Data You can read about the data here. At the time of writing, there are about 31.150.000 entries. Every single comment, story or other type of post have an index, starting with… The First Entry No need to go to the raw data for this. You can simply open it using https://news.| vsupalov.com
I’ve had a few sessions of looking around HN data. Gathering recent comments and stories to be processed, building a web app around it. It seems to be a fun data playground / learning project, so I’d like to take it seriously. The following are my working notes. The current idea is to have a mix of work-log-like entries, and notes around topics, and to refine them over time. Sometimes Sections will be left out as “to be filled in”, sometimes notes will become articles.| vsupalov.com
When I discovered the spark of ‘getting’ mathematics for myself, I couldn’t get but try and get an overview. Find out what’s within mathematics. There are a lot of interesting and fascinating subfields! This is an attempt to share my curiosity and new-found appreciation for the field of mathematics. I hope, that the spark can be shared. Warning: the following list is a selective transcription of the articles above. This is the part most likely to be wrong-ish.| vsupalov.com
It took a while for me to get a real understanding of what math is about. I also did not understand the reasons behind the structure of scientific papers. When putting in the work for University, I was following the patterns I saw. Applying them mechanically, imitating what I saw. I was missing a deeper understanding. I only understood it years later, when reading about a fictional conversation. What Made If Click The book was Cryptonomicon, by Neal Stephenson.| vsupalov.com
I haven’t really understood mathematics for a long time. It never occured to me, that there was something to be interested in. There was plenty of exposure to using math. Thanks computer science! But I managed to get by without a deeper understanding of what math is about or an appreciation for it, besides the benefits of practical applications. I dealt with applications. Getting very familiar with the leaves of the tree, never caring about why the tree came to be in the first place.| vsupalov.com
At the time of writing, Pulumi is still kind of a new kid on the block. Most people have used some flavor of infrastructure as code (IaC) tooling. Terraform as the most common cross-cloud solution, or a cloud-focused one like specific tooling around CloudFormation (like troposphere, or CDK). Pulumi’s main selling point vs Terraform is, that you can code it in a language you already know - TypeScript and Python for example, instead of Terraform’s HCL.| vsupalov.com
Here’s how you can set up and get going with Vagrant! Using this overview, you will have a usable virtual machine going really fast. 1. Install Vagrant. To get started, you’ll need to install Vagrant on your local development machine. Go to Vagrant’s download page and install the most recent version from there. Note: if you’re on Ubuntu or Debian, you can also follow the steps under Linux -> Ubuntu/Debian to add the apt repository and stay updated.| vsupalov.com
Learning Solidity can be fun! Here are a few resources which helped me get started and for comfortable with the language. Crypto Zombies Hands-down, one of the best resources to learn about Solidity and smart contracts step-by-step. You learn about basic elements of the language, writing code which adds up to a smart contract with game mechanics. You’ll also get to know essentials building blocks of the ecosystem, like OpenZeppelin, and can dive deeper into more advanced topics in later cou...| vsupalov.com
You have understood how smart contracts work, how dApps are structured, made your first steps learning Solidity and are ready to start your own first project. Here are a few nifty tools & resources, which can help you skip over tedious parts, and focus on learning and creating something that excites you! Just A Local Solidity Starting Point Please If you want to start simple, check out this starter kit. It’s pretty straightforward, uses hardhat and ethers.| vsupalov.com
I found this quite hard to Google, and spent too much time finding it out. Here’s a quick writeup for anyone who’s just getting started with Solidity and ethers.js. A word of caution: I’m a beginner as well! Things which worked for me may not work for you. The stuff below may be very flawed for reasons I don’t understand. For personal studying purposes only, no guarantees of any kind.| vsupalov.com
After being a casual Vue enthusiast for a while, I tried React and… Liked it! Working with Next.js was a blast, I got everything done which I wanted to. The resources are great, the tooling just works. Everything is (at least with hooks, and a simple application) pretty convenient and understandable. Here are my notes, about things I had to find out by doing them wrong, and Googling around. Components Can Be Functions Just define a function, and make sure it returns one of those jsx thingies.| vsupalov.com
This article is my contribution to taking some of the magic and mystery out of Web3 DApps. Once you understand how they work from a high level, the topic becomes a lot more approachable and less scary. I hope this will help you wrap your head around Web3 faster. Note: the explanations below are very Ethereum-ecosystem-focused. They apply to compatible blockchain environments like Polygon though! Probably others as well, but I haven’t got enough experience to generalize with confidence.| vsupalov.com
Before diving in, a quick disclaimer: I have been looking into this topic for a short while. Some of the things written below may be inprecise or false. My focus is on the Ethereum (ETH) ecosystem, things can be different when it comes to other ones. Consider the below to be a work in progress. Disclaimer: I’m pretty new to this topic, and might be mixing up words and concepts without realizing it!| vsupalov.com
I love the utility made possible by beautifulsoup4, aka bs4. I also struggle with the docs every single time I pick it up. Somehow, I find it hard to find the parts which I need, and end up searching for them a long. Which is annoying the 5th time around. So here’s a quick overview of the most essential snippets. You’re welcome future-me. Installation & Docs The package is called beautifulsoup4.| vsupalov.com
Every time I want to tinker with data, I have noticed going through the same incantations again and again. Of course I don’t remember them every single time, and have to look stuff up. This article is where I want to be looking from now on :) A Fresh Environment Assuming Python 3.* is installed on the system, pip and pipenv are installed globally, as well as all libraries needed to build Python packages if needed.| vsupalov.com
Sometimes I need one of those fancy directory overview-ish examples for a peace of writing - be it docs or new article. Here’s a tool which can help with that. Say hi to tree. Installation I’m guessing for the non-mac part here: # mac: $ brew install tree # ubuntu-ish $ sudo apt-get install tree Usage $ tree PATH_YOU_CARE_ABOUT $ tree . This will spit out a nice shiny overview of the directory in question!| vsupalov.com
How can I make a script run a command on my remote machine? Sometimes I’m surprised by all the things that I don’t know. This was one of them. There are excellent automation tools to make local workflows less tedious, but only one of those would be a good solution for running remote commands. And using Fabric requires creating a project and a lot of thought. Too much effort for a one-off casual command.| vsupalov.com
What does it take to make your containerized application easier to operate in production? What can help to keep them running and make them more reliable? Here are a few things to look out for, which will make your container ops job easier, both inside and outside of your running containers. Output Logs To Stdout Most logging solutions for containers are built around the assumption, that log s are written to stdout.| vsupalov.com
Gosh, that naming gets confusing really fast! I’m talking about the Unix CLI tool less. Less is more, but better. more being another CLI tool, which was there before less. As it happens, less is one of those tools I use a lot and couldn’t imagine being without. I use it a lot, and it’s so present that I sometimes don’t really notice just how much I use it for.| vsupalov.com
Networking is a topic I have been tip-toeing around for a while. It always takes a bit of effort and intentionality to learn about basics, which are not immediately needed for daily work. Here’s the overview I wish I had about Docker networking for practical purposes, I hope it will help you get an overview of the topic. The Docker docs on networking are cool. However, I felt like I needed to read a lot and look in many different places while researching the topic.| vsupalov.com
The Docker build cache can speed up your image builds and save a lot of bandwidth, or be something that eats away your time for no reason. This article is about how the Docker build cache works, what it is good for and how to make the most out of it. If you are not quite sure about the difference between an image and a container, check out this overview of Docker basics.| vsupalov.com
You often read that Docker images consist of layers. But what are those layers anyway? TL;DR Each layer is an image itself, just one without a human-assigned tag. They have auto-generated IDs though. Each layer stores the changes compared to the image it’s based on. An image can consist of a single layer (that’s often the case when the squash command was used). Each instruction in a Dockerfile results in a layer.| vsupalov.com
Git is such an essential part of my development workflows, it almost fades into the background of everyday work for me. This is a sure sign, that I should notice and care about it more :) After all, mastery is a process and not a state you arrive at. It’s always a good idea to tend to the tools of your craft. So, for the sake of pushing (heh) myself to discover things I don’t know yet, I’d like to share a collection of facts I wish I had internalized about Git sooner.| vsupalov.com
Okay, check this out: you install a containerized application on your Kubernetes cluster, which manages other applications for you. That’s what Kubernetes operators are in a nutshell. But let’s start from the beginning. Reconciliation Kubernetes, like other orchestrators, is stuck in an eternal loop - the control loop. It checks what the world looks like, compares it to its note on how the world is SUPPOSED to look like, and performs operations to make reality resemble the desired state.| vsupalov.com
Multi-stage builds are simple in principle, but the benefits they bring can be surprising. Let’s look at a few useful things you can do with Docker multi-stage builds. Reduce Redundant Build Effort Are you rebuilding your frontend assets every time a new backend package is installed? In the spirit of Docker layers, multi-stage builds can be a good advanced tool to reduce the amount of duplicate work needed. Especially for production builds, where you just need the final artifacts.| vsupalov.com
Docker can be used for deployment, local development and testing. It’s also a useful experimenting and tinkering tool. But what practical problems can it help solve? Here’s a non-exhaustive list of problems which can be made less painful with the help of Docker. If you’re looking to understand what jobs Docker has you can read more here. There are three main ones - packaging, distributing and running applications. This is a slightly different, more practical way to approach the same topic.| vsupalov.com
How to choose a base image for your Dockerfile? I have written about my process of creating a Dockerfile before, and this detail seemed to warrant an own closer look. Here’s how I would go about the decision in detail. What’s The Usecase? What do I need this image to do for me? Do I need to build a new one? If there’s a ready-made official image available, I would opt towards using it instead of rolling my own.| vsupalov.com
Today I wondered - what goes through my head, when I want to create a new Dockerfile? I don’t think I have written about this before. I think it could be useful to get a glimpse of how I approach creating a new Dockerfile, what the high-level thinking looks like and what decisions I care about. Let’s start with the most important part: the context around the Dockerfile. What Is This For?| vsupalov.com
Your first docker-compose stack does not need to be fancy, perfect or even mostly functional to be useful. Personally, I try to avoid developing inside of containers. Nevertheless, for any project which moves towards being deployed, I create a local docker-compose stack. Not for the final production destination, but as a test-bed to figure out the deployment requirements and make sure I have thought about all parts. It Doesn’t Need To Be Fancy A simple Dockerfile for the application.| vsupalov.com
When you are deploying containerized applications, it’s just a question of time until you ask yourself: “should we use an orchestrator?”. But what is an orchestrator anyway? The Short Version Container orchestrators are tools that helps you with managing your running containers. They take care of the busywork for you. Here’s an example: you tell your orchestrator “I want 2 containers based on image X running at all times”. The orchestrator starts paying attention, and takes action...| vsupalov.com
What are multi-stage Docker builds for? What can you do with them, and why should you care? Here’s a quick explanation of the benefits, without going into too many details! You Can Copy Between Stages This is the most important part to grasp. What makes multi-stage builds useful, is that you can copy specific folders and files from one named stage to another. This way, you can selectively copy only what you need in your final image from other stages.| vsupalov.com
This can be done by setting an environment variable in your shell: export DOCKER_BUILDKIT=1 This will configure Docker to use BuildKit for build commands. If you want this to use BuildKit every single time from now on, you could set this variable in your .bashrc, or adjust the Docker settings in /etc/docker/daemon.json as described in the docs (or via the “preferences/Docker Engine” menu in Docker Desktop), by adding “buildkit” in the “features” section:| vsupalov.com
What’s a Docker image anyway? Let’s create a simple image, export it, and look take a look at what it’s made of. Creating An Image Let’s keep it really simple. I want to investigate the image of the following Dockerfile: FROM ubuntu RUN echo hihi RUN touch /hi RUN rm /hi CMD ["echo", "hello"] Completely without any practical purpose! We don’t even make the effort to use a properly tagged base image.| vsupalov.com
It’s called changes. Here’s how I tend to use it: # editing a file in a Git project $ git add $FILE_I_CHANGED $ changes It needs to be located in a PATH-included directory, I usually put mine into an own folder called ~/local/bin. Not For Team Use I wouldn’t run it on a non-private non-early-stage project. All it does, is create a new commit with the message “changes” and push it.| vsupalov.com
So, what did this command just do? Have you always wondered what files change on disk when you update your OS package information? Would you like to know what files were added after you installed a particular package or ran a script? Docker can help you to be nosy about what files changed due to a particular command you ran. Two Approaches You can go about it in two ways.| vsupalov.com
How to go about adding Tailwind CSS to a static site? This article will show how to get started easily, how to set up your tooling in a more complex way and what to look out for. Note: for a more complete guide on getting started with Tailwind CSS, check out the Tailwind CSS For Non-Designers article. Starting Simple This approach works independently from where you want to add Tailwind CSS.| vsupalov.com
This might be the most frequent advice I give to folks: “Have you tried using a Dockerfile linter?” Apart from learning the basics of Docker, this is the most bang-for-the-buck thing your can do to improve your Docker game and save yourself from a few nasty gotchas. Maybe “linter” is a bit too specific, it’s really about having an automated way to catch and discover avoidable mistakes. Cool Tools To Know About Here’s a list of tools you can use to get started.| vsupalov.com
I have written about this topic before in the past. If you don’t watch out, you can easily leak your SSH credentials into your Docker image, sometimes without even noticing. Handling build-time secrets got easier with BuildKit, and the same goes for SSH secrets. However, there’s a special mechanism to pass SSH credentials into your building Docker image without leaving a trace, with is an even better fit than the new secret mount type.| vsupalov.com
Passing build-time variables to Docker is a solvable problem. However, if you want that data to leave no traces in the image, it’s another story. For example, when you want to access private SSH repositories during a build. You had to watch out not to leak any secrets. Packing lots of commands into a single line, making sure to clean up with squashing (nah), using multi-stage builds to keep secrets in non-public files (okay), or coming up with elaborate schemes to access those secrets secur...| vsupalov.com
Are your Docker builds taking forever? Docker can be a valuable part of your tool belt, or a constant source of annoyance. This article will walk you through frequent sources of slowness when building Docker images for Python projects, and ways how you can avoid or fix them. Let’s speed up an utterly slow Docker build together using the right high-level approach, easy to implement tricks and brand-new Docker features to speed up your build protect your coding flow from annoying delays.| vsupalov.com
Here’s something I stumble over almost every time I clone a git repository with submodules. Those darn folders are empty and using the project fails. Here are two ways to fix that: Clone With The Recursive Flag When issuing your git clone, add a --recursive flag. It will look like this: $ git clone git@github.com:user/project.git --recursive And as easy as that, your submodules are there. If you cloned your repo and don’t mind starting over - delete the freshly cloned repository and add t...| vsupalov.com
What’s a better naming scheme for Docker image tags than the tricky :latest tag? What naming schemes can help you have an easier time handling your Docker images, and make it harder to run into unexpected errors? Let’s look at a few options! The Thing With “Reusing” Tags If you use another tag than :latest, you might still run into issues if you end up “reusing” the same tag for different images.| vsupalov.com
A quick demonstration of what a BuildKit-using Dockerfile looks like, so you can make use of those cool new BuildKit features.| vsupalov.com
When learning Docker, there are a lot of subtle details you can miss. But knowing them can be really helpful. I often had full-fledged “aha” moments. After stumbling upon a small snippet of information suddenly things started to make much more sense all of a sudden. I like to think them as puzzle pieces, which help you figure out what the whole image is supposed to look like and provide you with an overview.| vsupalov.com
Depending on how often you are doing something, even seconds saved each time can add up quickly. Why do the same thing over and over, if you can get some help from a robot-assistant instead? This is an overview of useful tools you might not know yet, which can help you to automate parts of your development workflows. I hope this will help you to focus on writing code and getting things done instead of thinking through each step a toil-y shell-incantation.| vsupalov.com
Docker always had a very compelling first-usage story. Just install Docker, and you can run your first containerized application right away. Want to create your own image? Just write a Dockerfile with a few lines. Easy, convenient and, unfortunately, not that simple. Getting started with Docker is easy, but it takes time and experience to avoid even the most common ways to build broken images or run unreliable and insecure containers.| vsupalov.com
How to find out how long your Docker image build takes for each layer? Measuring the total build time is quite straightforward - just add time in front of your docker build command. You also don’t have to sit there with a stop-watch to time your layers. Here’s a simple way to get the time each layer you build: Use the BuildKit buildx Command BuildKit brings along a few useful features you can use out of the box starting with Docker 18.| vsupalov.com
A few new BuildKit features which can help you to handle build-time secrets, access private Git repositories and cache directories in between rebuilds. Knowing about those features can help you speed up and simplify your Docker image builds in the future.| vsupalov.com
It’s easy to get started with Docker, but once you go beyond very basic usage you can start running into issues and questions which are hard to ask or answer. It can feel like banging your head against the wall. Simple things you expected to “just work” turn out to be really hard or not to make sense. Lots of struggles are caused by superficial understanding of Docker - the tool, its parts and the concepts behind them.| vsupalov.com
When starting a new Django project, I always like to get a first, simple view working. It’s kind of a “Hello World” step I like to take. If you have created and configured a templates folder, and created your first template within it, all that’s left to do is to add two lines to the project’s urls.py: from django.contrib import admin from django.urls import path from django.views.generic.base import TemplateView # here urlpatterns = [ path('admin/', admin.| vsupalov.com
Does the thought of setting up a new development environment for your Django project seem like a tedious task? How about helping somebody else to start helping with the development? Do you feel like you and your project would be well prepared? If both of these scenarios sound uncomfortable, this article is for you. Read onto learn an easy first step towards making your project more onboarding-friendly. Write a Friendly Note to Future-You It doesn’t need to be a huge effort.| vsupalov.com
It’s frustrating to work with a fragile docker-compose development setup. One frequent issue, is if the dockerized application crashes because the database isn’t ready early enough. All you see is an error message and a terminated container. Racing conditions are pretty annoying. They don’t always happen, and it’s easy to get caught in the trap of “retrying until it works again” once too often. Here’s an easy way to work around your failing dependency quickly, and get a fix in p...| vsupalov.com
Working with docker-compose can feel like a chore if it makes you wait again and again. Waiting for containers to stop or when restarting can cost a lot of time if you’re using docker-compose for development. If you need to wait for your containers to be “stopped gracefully”, chances are that docker-compose isn’t at fault. Rather, it’s because of your dockerized apps don’t react to a SIGTERM signal and time out instead.| vsupalov.com
Local development in Docker can feel really slow. All you wanted was to have reproducible environments, but the price to pay are painful waiting times, and way more commands. If you are using docker build frequently and your containers need to be restarted a lot, this post will help you to save some time. Mount Your Code Directory Into the Container While it makes sense to create a complete Docker image when deploying your code, you don’t need to do it when developing.| vsupalov.com
Docker-compose is just a tool for handling and configuring Docker containers. If you would be comfortable working with plain Docker commands in your environment, you can use docker-compose as well. The docker-compose docs even have a section about using docker-compose in production. But let’s look deeper than this easy answer. Why do some people recommend otherwise? I think it’s important to understand why some people mean when they say “don’t use docker-compose in production” and w...| vsupalov.com
Long waiting times, lots of manual steps, constant worrying that something might break. Deployments come in many forms, and if done wrong they are quite the opposite of enjoyable. The goal of any deployment method, is to get your carefully crafted project online. To share it with the world, and make it possible for people to use it. That’s the bare minimum. Have you ever though about what else your production deployment could be doing for you?| vsupalov.com
AWS offers a LOT of services. Seeing the list of AWS services in the console can feel completely overwhelming the first few times. Just reading through the names of all services takes minutes. Finding out what every single one does would need a lot more effort. And why would you? If you are like most people, there’s only a small subset of services which you really want to know about. Some of them because they are essential, and some because they come in really handy in specific situations.| vsupalov.com
When working with VMs, it’s not uncommon to put everything onto a single box. When deploying to a server, this is a common pattern as well. However, when it comes to Docker, you shouldn’t cram all of your applications into a single container. Let’s try to untangle this issue into small, digestible pieces. The Short Answer Sure, you can put everything into a single container. It can work, but you should reconsider.| vsupalov.com
Using a .env file is one of the many ways fo configure Docker images and containers. If you are using docker-compose, the values from .env are used to replace ${DOLLAR_NOTATION} placeholders in your docker-compose.yml file. But what if you want to change one of the values in the .env file dynamically? You could use something like sed or awk to change the file in-place, but there is a better way.| vsupalov.com
Docker can seem pretty overwhelming. It seems to be doing so much - it’s hard to say what it’s for exactly. That’s because Docker is a tool which takes care of multiple jobs. If you look at each of those responsibilities by themselves, it’s easier to understand Docker and you’ll have an easier time getting your head around Docker. The Three Jobs: Packaging, Distributing and Running It’s easy to mistake a task you want to get done with the most popular tool for it.| vsupalov.com
Permission denied -rw-r--r-- 1 root root ... Is this what you see when accessing files that were created from within your Docker container? The user of the container (root in the worst case) is completely different than the one on the host. The file permissions and ownership are all wrong. One frequent solution, is to “chown” your shared folder again and again. It’s tedious and there is a better way: read on to learn learn how to build, configure and run your Docker containers correctly...| vsupalov.com
Do you feel like your knowledge of development ends with a git push to the remote branch? You’re very comfortable running code on your local development machine, but deployment seems complicated and unapproachable in comparison. Every single project seems to do it differently - a unique tangled-up ball of arcane rituals, scripts and tools. Avoiding deployment topic worked for you so far, but deep down you know that this will come back to bite you someday.| vsupalov.com
Why use a virtualenv if your app runs inside of a Docker container already? Docker is great at packaging OS-level dependencies together with your application. Virtualenv however, is great at making sure that you have a perfectly controlled environment for your Python application. Sure, you could simply install your project’s dependencies inside of your Docker image without using virtualenv. Using a virtual environment with your dependency tooling of choice like pipenv, poetry or good old pi...| vsupalov.com
Deploying your Django project for the first time can seem like a huge task, and a blocking one in addition to that. You can’t move forward until the site is in production. The pressure is on. However, there’s one trick to make deployment way less scary, and way less of a big deal. Just deploy as early as possible. It doesn’t even need to be a publicly accessible location. Just an environment which is distinct from your development environment.| vsupalov.com
Dockerizing your Django application can seem like a daunting task. There is a lot to learn, new exciting mistakes to make and you’ll need to get used to new workflows. You’ll also need to prepare your project to be Docker-ready. You’ll have the best experience if you make your project Docker-ready before you try to cram it into a container. This way you won’t have to fight your application’s setup at the same time as you figure out Docker.| vsupalov.com
I always loved to use Fabric as a tool to automate my dev workflows and deployments. It was so easy to get started, straightforward and uncomplicated. Imagine my surprise, when I got literally stuck trying to use Fabric 2. It all looked different. Commands I got used to simply didn’t exist anymore, and I could not find a clear minimal example to get me started. Even basic things seemed hard to do, as I was so used to the old ways.| vsupalov.com
What does it mean to EXPOSE a port in your Dockerfile? What is it good for, and why doesn’t it make your container available? What EXPOSE Does Writing EXPOSE in your Dockerfile, is merely a hint that a certain port is useful. Docker won’t do anything with that information by itself. EXPOSE 8000 Defining a port as “exposed” doesn’t publish the port by itself. Publishing Ports Docker doesn’t publish exposed ports by itself.| vsupalov.com
It’s easy to take best practices and good design patterns for granted. If everything just works, you don’t even realize that they are there. That is, until you sabotage them without knowing you did. It pays off to know what hidden decisions shape the environment you are working in. “Of course”, you might say - but chances are that you are not aware of many design principles which have shaped your favorite language and web framework.| vsupalov.com
Sometimes, I need a quick reminder of how certain aspects around Django work. My memory is pretty lazy when it comes to details, so after being away from Django for a while I have to revisit the basics every now and then. That’s especially the case when starting a new project. Usually, this means finding the right parts of the official tutorial and docs. A quick reminder is more than enough, but getting to the right place always means doing the same searches to find the same things.| vsupalov.com
You wouldn’t expect to write your Django app perfectly on the first try. There are things you only find out once you are trying to implement them Sometimes getting it right, means rethinking the details and trying different approaches until you find a way which works for you. Getting deployment right is really similar to the process of developing your app. Deployment shouldn’t be an afterthought - in fact you are better off if you start thinking about it early, starting with relaxed const...| vsupalov.com
Deployment can be approached in many ways - most of them are valid and good. It’s not a purely technical problem. Instead, it’s highly subjective and depends on your preferences, your team and your project. A solution which is perfect for one person, could be a very bad fit for you, and vice-versa. The biggest confusion, when it comes to choosing a deployment method, is caused by having the wrong focus (too narrow or too technical), and a lack of general knowledge.| vsupalov.com
python manage.py runserver is not something you want to use in your production setup. After all, runserver is not your production server. However, it’s completely okay to write a Dockerfile, where you use it! You will have a good time running a development server in your Docker container, if you are using them for development instead of deployment. Let’s look at two cool use cases. An automated example development setup Readmes are great!| vsupalov.com
“Operating a piece of technology at a professional level turns out to be really hard. It’s easy to get started with a lot of technology, but harder to do a really good job with it.” “If you decide to try out a new piece of technology, you should figure out low-risk ways to get started.” These quotes are from boringtechnology.club. I love everything about them. Docker is one of those things, which you probably don’t want to start using in production right away.| vsupalov.com
You have been reading books and tutorials about Django - but it feels like something’s missing. How do these pieces come together in the real world? What’s different, and what can you learn from it? There’s also a lot you can get out of exploring other people’s projects. Tools, (missing) best practices, code structure and a glimpse of real-world issues. Everything is there to be looked at, and to help you level up.| vsupalov.com
Tutorials are great to get started with Django, but they feel like something’s missing from them. I’m always very curious to see how other people are getting work done, when tackling real-world projects. You can see how other people are structuring their code, growing their codebase and handling the issues they encounter. But how to find real-world Django projects which are online and have open-source code available? Here are a few techniques you can use for finding cool projects online t...| vsupalov.com
Deploying to production for the first time can feel completely overwhelming. You’re leaving behind the cozy comfort of your development environment, and are sending your little web app off into the unknown. And then there’s that nagging feeling that you’re missing something very important. After all, production is that special place, where everything needs to be perfect. You have to do everything the right way or else. … I don’t think that production has to be a big deal.| vsupalov.com
Do you want the users of your app to be able to login via email? Or would you like to add custom fields about your users? You might need a custom user model for that. But does it mean to use a custom user model? In general, Django’s user models have to do with authentication and storing data about users. When you start a default Django project, your project is configured to use the default user model.| vsupalov.com
You’ve built your Django web app and are working on deploying it. You’ve been running your app locally with python manage.py runserver. That’s a fine command, built for development convenience, but it’s not meant to be used as part of a production setup. The docs are very adamant about this: DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. So the server started with runserver is not guaranteed to be performant (it’s very s...| vsupalov.com
Every version of Python brings along cool new features and improvements. But really recent versions are not available from default system package sources - you need to do some extra work to get to them. Here are complete instructions how to install Python3.8 on Ubuntu 18.04 LTS, and a few more steps to setup an enjoyable Python development environment on a fresh machine. Make Python 3.8 Available Right now (18. May 2019), Python 3.| vsupalov.com
After finishing the first version of your Django project, it’s just a question of time until you stumble into things you didn’t prepare for. Those are real-world challenges which are usually not covered in beginner tutorials. However, all successful Django projects need to deal with these topics sooner or later. Let’s talk about eleven of these challenges. Knowing about those will not resolve them automatically, but you’ll have a bit more time to prepare instead of being disappointed ...| vsupalov.com
This article will help you get started with systemd. You know - that tool you didn’t really knew you would need when you started to work on your Django project. Sometime before you found out that deploying your app can turn into much more work than expected. Let’s make sure you have a broad overview, and enough understanding of useful commands to get going. After reading this, you should have just the right amount of information to interact with systemd and continue climbing the steep dep...| vsupalov.com
When hosting a Python web app in production you can’t get around using a WSGI server and a web server. Gunicorn and Nginx are solid and popular options - but what are those two apps? Why do people run both, and not just one of them? Nginx and Gunicorn work together Nginx is where requests from the internet arrive first. It can handle them very quickly, and is usually configured to only let those requests through, which really need to arrive at your web application.| vsupalov.com
Many people are using Gunicorn (or uWSGI), but don’t really know what they actually do. You take it as a given, and just hope that your web app will work as expected when you deploy it. Let’s take some time and look at deployment best practices, and the job Gunicorn has. A production stack dream team The unix approach is to have small tools which do one thing, and do it well.| vsupalov.com
I like Go and Django. Both are currently very valuable parts of my toolbox when working with web applications. You might wonder why I have bundled up a language and a framework. Why not picking a certain Go framework? Because with Go, there are no must-use third party libraries. You’re completely free to choose and match, depending on the type of project. Go is a amazing for writing flexible web services.| vsupalov.com
This is not an article about setting up a Cookiecutter Django project the right way. It’s about creating a new project and fast forwarding to a state where you can start writing code. Here’s the minimal and most lazy way to start running a brand-new Cookiecutter Django project, and start coding right away. No need to run Docker, no need to setup external databases. Just start a project and start building.| vsupalov.com
Have you stumbled upon some of the following problems with your Django project? You have to hard-reload your site while working on your frontend CSS and JS. Sometimes, you have to tell users to try a hard-reload, because the browser seems to ignore changed CSS. Lots of requests for small CSS and JS files need to be made when loading your site, which makes it slower. You have to work with huge frontend source files which are hard to navigate.| vsupalov.com
When approaching less-obvious coding tasks, I really enjoy building scaffolds around the thing I’m working on. You only zoom out occasionally to see if you’re still on the right track and what’s up next. Then you can tackle the next small, isolated problem at a time. Less things to keep in mind! It’s so nice when you only have to keep a small part of what you’re building in mind at a time!| vsupalov.com
How to connect the frontend and the backend? How do they communicate? There are many different ways how to structure a web application. The frontend can take different forms, and it can be daunting to understand how to connect the two. This article is an overview of what goes on between the backend and the frontend of a web application - how the two communicate. Let’s start with fundamentals.| vsupalov.com
Building cool apps » deploying them in a fancy way. When starting work on a new Django project, I don’t use Docker. Why would it be otherwise? Nothing has to be deployed. Reproducibility is not a crucial topic. Everybody is on the same page. It will get fancier in time, but only when there are real issues which require more work. My development environment is as simple as possible when starting out.| vsupalov.com
Passing context into your templates from class-based views is easy once you know what to look out for. There are two ways to do it - one involves get_context_data, the other is a bit less known, but can be pretty useful. Are you trying to add keys to your context dict, but they are not working as expected? Here’s a quick checklist to see if you’re not missing something important:| vsupalov.com
You can use Vue for a very small parts of a single template in your Django app. If there’s a place where you want to create an interactive element, you could use Vue instead of jQuery or vanilla JavaScript. That wouldn’t be overkill, but a sensible and acceptable way to make use of that frontend framework. With Vue, you don’t have to commit to a too-complicated solution. But depending on the way you choose to setup Vue with your app might lead to an “overkill solution”.| vsupalov.com