DEV Community

Cover image for Containerized Cookiecutter
Clemens Kaserer
Clemens Kaserer

Posted on

4

Containerized Cookiecutter

What is cookiecutter?!

A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python package project template.


Cookiecutter as a Container

Wonderful, now let's use cookiecutter from a container instead of installing it on your machine.

Base image

The image is based on python:3 and can be build for any architecture supported by python:3.

Flavors

The cookiecutter container image is available in 2 flavors

  • latest is build daily via travis and if the base images changes
  • version during each travis build the current cookiecutter version is validated and the image is tagged accordingly starting with 1.7.0. More versions can be found on hub.docker.com/r/ckaserer/cookiecutter.

Requirements

  • Bash
  • docker

Getting started

To process any cookiecutter template you can execute

docker run --rm -it -v $(pwd):/cookiecutter ckaserer/cookiecutter TEMPLATE

Or if you like the a more convinient approach you can put following lines in your bashrc

# cookiecutter
function cookiecutter () {
  local command="docker run --rm -it -v $(pwd):/cookiecutter ckaserer/cookiecutter"
  echo "+ ${command} $@" && ${command} $@
}
readonly -f cookiecutter
[ "$?" -eq "0" ] || return $?

and after sourcing your bashrc again to load the newly added function into our shell via

source ~/.bashrc

you can process your template just like you would when installing cookiecutter on your machine via

cookiecutter TEMPLATE

Source

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

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