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. Off-the-shelf images for backing services (PostgreSQL, Redis, MailHog) running alongside it.

Nope, there’s no script to backup database data. Nor is the entrypoint script too fancy (well, apart from the part which waits for the database to be ready).

It Doesn’t Need To Be Perfect

When it’s a Django application, my first docker-compose stack runs the development server (aka python manage.py runserver, yeah it’s not what you want to do forever). It runs as root. I do the bare minimum to make image rebuilds less tedious and focus on getting the development server to run.

This is not the time to make everything shiny. There’s no need to. I just want to see my project be able to run in a non-dev environment.

It Doesn’t Need To Be Completely Automated

Once the development server runs, manual management commands are required to get it in a working stage. Usually, I copy and paste them from a temporary README section. Yes, the command to exec a bash in the application container is found there as well.

This is a lab to figure out what I need to keep in mind when deploying the application. It’s not final. It’s a first draft, which will inform my future efforts and be iterated on itself. It’s fine as it is.

Your First Stack

If you have a project, which needs to be deployed soon, or where you’d like to capture the environment requirements in a easier-validated way - consider creating a docker-compose.yml for your project. It’s relatively low effort, you’ll be able to reuse the work down the line, it will inform your future actions to make your project easier to setup and handle.

Alternatively, consider using Vagrant in a similar fashion.

In any case, I hope that having a pre-deployment lab will help you a lot to have an easier time making your application deploy-friendly, and to get it working smoother when the time to ship comes around.

Go ahead, and create your first docker-compose stack!

Subscribe to my newsletter!
You'll get notified via e-mail when new articles are published. I mostly write about Docker, Kubernetes, automation and building stuff on the web. Sometimes other topics sneak in as well.

Your e-mail address will be used to send out summary emails about new articles, at most weekly. You can unsubscribe from the newsletter at any time.

Für den Versand unserer Newsletter nutzen wir rapidmail. Mit Ihrer Anmeldung stimmen Sie zu, dass die eingegebenen Daten an rapidmail übermittelt werden. Beachten Sie bitte auch die AGB und Datenschutzbestimmungen .

vsupalov.com

© 2024 vsupalov.com. All rights reserved.