
Show HN: Develop your Python applications easily in clean Docker environments - macostea
https://github.com/macostea/cage
======
rockostrich
Pretty simple to set up and use, but I'm not sure if it's better than learning
`docker` and `docker-compose`. Also, the default `python <file>.py` doesn't
remove the container after the file is done running and the image is tagged as
`cage/<name of project>` instead of allowing the user to tag it with their own
name. Both of these are easy to fix with `docker` commands, but if this is
meant to be a library that helps you avoid `docker` then it's not doing its
job.

~~~
gshulegaard
I was going to say something similar. With venv moved into the stdlib in
Python3 and ongoing development and improvements to the `docker-compose`
workflow I am not sure where a tool like this fits.

* venv is lighter and more or less fairly standardized

* `docker-compose` is more general and language agnostic

So something like `cage` is somewhere between...it's neat, no doubt, but not
sure where I would use it personally.

------
wtvanhest
Slightly off-topic, but does anyone develop Django/Python on a windows
machine, and may want to offer any general advice or tips?

I am using virtualenv, but wondering what else I should be doing to make it
easier. Previously I used cloud9 (cloud IDE) for rails development. In both
cases, I am pretty much a hobbiest, but don't mind spending some money to make
things easier since I'd rather spend my time doing the fun part, rather than
developer ops.

~~~
goodoldboys
I just switched from Mac to Windows 10, and I work on a lot of Django
projects.

I use PyCharm (love jetbrains) + Vagrant and it's working great so far. I'd
highly recommend spending the time learning Vagrant - it can be incredibly
frustrating at times (on both mac and windows), but once you get it working
right it's really rewarding. Being able to re-instantiate a VM when something
gets really botched is a great feeling. I don't have to worry about my host
machine getting messed up, so I'm free to tinker around in the VM and that
speeds up my learning.

The one downside I've encountered so far is how many different "terminal"
style apps I need to run to get everything working. Currently I need
powershell (as admin) for spinning up the VM, putty to SSH into it, and git
bash for source control. I can probably simplify them all into powershell but
for now it works.

~~~
my_ghola
You can use ssh from git bash so there's no need for putty. And might want to
look into Console2 or ConEmu both of which allow you to open multiple tabs for
multiple shells.

~~~
goodoldboys
Yep, you're right. I just added git to my path so that I can now do it all
from powershell, so that's cool!

------
crazyhatfish
Although I'm not sure I would use this, this is the kind of stuff I've been
waiting for. Where nice clean containers are used as part of an active dev
cycle rather than just the production push.

The ultimate dream of the end user using a desktop comprising only of
containers seems to be still a bit far off yet...

~~~
bschwindHN
About a year ago I switched our dev environments from Vagrant to docker-
compose environments with a "helper" shell script to run the most common
docker-compose operations you'd do in a day. It starts up so much faster than
Vagrant, it's easy to add new services, and it's easy to add and remove test
data. Here's an example of the kind of setup I have:

[https://github.com/bschwind/api-starter-
kit/blob/master/help...](https://github.com/bschwind/api-starter-
kit/blob/master/helper.sh)

What's funny is I don't currently use docker in production, but I love it for
dev environments.

------
civodul
Docker sounds heavyweight for this purpose, given that it essentially spawns a
complete userland separate from the host.

I work on Guix; it provides a 'guix environment' command, which is sort of a
generic 'virtualenv', and IMO is a simple lightweight alternative:
[https://gnu.org/s/guix/manual/html_node/Invoking-guix-
enviro...](https://gnu.org/s/guix/manual/html_node/Invoking-guix-
environment.html) .

------
symlinkk
Why would you want to take a cross-platform interpreted language and run it
under a pseudo-VM like Docker?

~~~
Spivak
Docker is less of an pseudo-VM and more like a linker. No matter what the
environment is like on the host you can be sure that it's identical to yours
within the container.

------
brudgers
If it meets the guidelines, this might make a good 'Show HN'. Show HN
guidelines:
[https://news.ycombinator.com/showhn.html](https://news.ycombinator.com/showhn.html)

~~~
macostea
Thanks for the suggestion! I'll try it out

------
viraptor
So apart from having separate disk+network namespace, how is this different
from a virtualenv? I feel like configurable sockets and paths should provide
everything this can, but with less overhead.

~~~
cookiecaper
Less system resource overhead, more human overhead. VirtualEnvs can bleed over
if they're not configured properly or if you forget to deactivate. They're
harder to fully encapsulate and carry around (have to initiate with a special
flag or there's a bunch of manual find+replace when changing paths). They
sometimes end up with system dependencies (though `--no-site-packages` has
been the default for a long time now).

This would be a shortcut that bypasses the need for venvs entirely. I'm not
sure I would use it, but that's the difference I see.

~~~
falsedan
There are a couple of tools to automatically manage virtualenv
activation/deactivation, like autoenv[0] & detect_virtualenv[1];

[0]:
[https://github.com/kennethreitz/autoenv](https://github.com/kennethreitz/autoenv)
[1]:
[https://github.com/dgholz/detect_virtualenv](https://github.com/dgholz/detect_virtualenv)

------
rch
> The current version of Cage only supports dependencies written in a
> requirements file

It might be worth looking at pipfile.

Great project though!

------
miloshadzic
Docker runs pretty slow on macOS so you'll be paying a pretty high price for
cleanliness.

------
alrs
Mac-first development strikes again: pycage requires Python 3.5, which hasn't
landed in Debian stable yet. Bummer.

~~~
oblio
I don't see the connection between the 2. I'm pretty sure MacOS only ships
with Python 2...

~~~
alrs
It's par-for-the-course to "brew install" random stuff on a dev box. You lose
a lot when you ditch distro-packaged Python and start relying on varying
third-party schemes to drop something that may-or-may not be getting security
updates and may-or-may-not have been compiled against the same libraries as
the ones on your production system.

------
0wl3x
Could someone please explain why this might be useful? It seems like something
that a crypto developer might like but if I'm developing something innocuous
why would it matter if it runs inside a container?

~~~
apetresc
Why would a crypto developer be especially interested in this?

~~~
_joel
I have feeling the OP is thinking of air-gapping or clean room builds, but I
could be wrong.

~~~
0wl3x
yeah that's exactly the kind of use case I was thinking of.

