Distributing Docker Container Application for Desktop Environment - python

I have developed a web-based application for end-users that resides in a docker container. The container itself hosts a few python dependencies, a few public repositories, and a flask based web front-end with a MongoDB back-end that is started when the container is initialized.
It's fairly straightforward to download the container and run it on a docker host. However, most docker hosts (if not all) are not free.
Therefore, if an end-user wanted to use my application off the cloud they would have to download and install docker and associated dependencies on their local machine prior to being able to use the image (which is even more complicated on a system like Windows or Mac OSX)
With that being said, my question is: Is there any tool that has been developed to help ease this requirement on the end-user for deployment to users local desktop environments? I understand installing and using docker is not THAT hard, but some people are still very afraid of command-lines and I was hoping to find a method that would help alleviate some of these 'scary' requirements.

Did you look at Boot2Docker? It packages up the Docker CLI compiled for Windows or OSX, a VirtualBox VM to run Linux for the containers, with an easy-to-use installer.
Also https://kitematic.com adds more point-and-click for Mac users.
Overall, however, Docker is a developer/devops tool, and I haven't seen much aimed at helping non-technical folks use it.

Related

Using Docker for development and sharing dependencies for features such as IDE auto-completion

Say we have a Docker container with all the dependencies that our application needs, and the code for the application lives on a shared volume. This seems to be a common setup to reasonably isolate the application and its dependencies.
Now say we edit the code located on the shared volume using a locally installed IDE. How can the IDE find the dependencies (which are not installed on the shared volume) for features such as auto-completion to work?
I'm aware of certain IDEs such as PyCharm that has built-in support for Docker but I'm curious if there is another method for "sharing" dependencies. Do some people just NFS mount the whole container onto the host or does that go against the Docker philosophy?

Can I distribute a python application with docker?

I am developing a python application (a package) that can be distributed with distutils.
I need to share it with someone that does not have python installed.
Is it possible to bundle the entire package and distribute it with docker?
If they have docker then you can distribute your whole application as a docker image. This is the main docker use-case.
Yes, you can distribute the app through an image in a registry. Given your description and comments, it sounds like Docker Cloud would be a good place to do that. Cloud is the more modern interface to Docker Hub. Then they can just do a docker pull yourusername/yourimagename and use the app. And they don't have to have python installed.

How to deploy python applications to remote machines running Windows

I develop a distributed application which is based on RabbitMQ and multiple python applications. System is pretty complex so it is very likely that we will need to update deployed solution multiple times. Customer wants that we use his servers which are running windows. So the question is how to deploy and update python part of this system. And as sub-question is it better to deploy sources or use pyinstaller to get executables and then deploy them? On my test server I just use git pull when I have some changes which is probably not the case for production system.
I was in a similar position and i combine pyinstaller with fabric. So i build a "compile" version of the project and with fabric, i deploy like the client wants.
Fabric support roles definition, several configuration for several clients.

Workflow for Python with Docker + IDE for non-web applications

I am currently trying to insert Docker in my Python development workflow of non-web applications.
What are the current best practices in Python development using Docker and an IDE?
I need the possibility to isolate my environments with Docker and debug my code.
On the web I found many articles about the use of Docker to deploy your code:
Production deployments: how to build Docker images ready to spin with your application already packaged inside
Development environments that mirror production: extension of the above, where you can use a container to fully QA the current status of a project before deploying to production while developing
I found a lot less about an actual development workflow, apart from some tips on how to use containers with shared volumes mapped to the directories on the host while developing web applications. This approach does not apply to non-web applications and it has some issues where a simple reload (with a LiveReload-like mechanism) is not enough so you need to restart your container(s).
The closest writing I could find is this "Eight Docker Development Patterns" blog post, but it does not consider an IDE (like PyCharm I am using now).
Maybe this question is the result of the 3-4 hours (and counting) spent configuring PyCharm to use a remote Python interpreter running in a Docker container. I expected a much better integration between the two.
Actually, I believe that using the Docker interpreter in PyCharm is the way to go. Which version of PyCharm do you have? If you have the 2016 version, it should be set up within seconds. You just have to make sure your docker machine is running and you must have your image built that you would like to use with your project. PyCharm will find the Docker machine in the "add remote interpreter" dialog automatically. Then select your image and you're all set up.
You can run your code as usual then, almost without any delay.
Here's what worked for me: https://www.jetbrains.com/help/pycharm/2016.1/configuring-remote-interpreters-via-docker.html
And make sure to update PyCharm, that solved some issues I had.

Using vagrant as part of development environment

I'm investigating ways to add vagrant to my development environment. I do most of my web development in python, and I'm interested in python-related specifics, however the question is more general.
I like the idea of having all development-related stuff isolated in virtual machine, but I haven't yet discovered an effective way to work with it. Basically, I see 3 ways to set it up:
Have all services (such as database server, MQ, etc) as well as an application under development to run in VM. Developer would ssh to VM and edit sources there, run app, tests, etc, all in an ssh terminal.
Same as 1), but edit sources on host machine in mapped directory with normal GUI editor. Run application and tests on vagrant via ssh. This seems to be most popular way to use vagrant.
Host only external services in VM. Install app dependencies into virtualenv on host machine and run app and tests from there.
All of these approaches have their own flaws:
Developing in text console is just too inconvenient, and this is the show-stopper for me. While I'm experienced ViM user and could live with it, I can't recommend this approach to anyone used to work in any graphical IDE.
You can develop with your familiar tools, but you cannot use autocompletion, since all python libs are installed in VM. Your tracebacks will point to non-local files. You will not be able to open library sources in your editor, ctags will not work.
Losing most of "isolation" feature: you have to install all compilers, *-dev libraries yourself to install python dependencies and run an app. It is pretty easy on linux, but it might be much harder to set them all up on OSX and on Windows it is next to impossible I guess.
So, the question is: is there any remedy for problems of 2nd and 3rd approaches? More specifically, how is it possible to create an isolated and easily replicatable environment, and yet enjoy all the comfort of development on host machine?
In most IDE you can add "library" path which are outside the project so that your code completion etc works. About the traceback, I'm unfamiliar with python but this sounds like issue that are resolved by "mapping" paths between servers and dev machine. This is generally the reason why #2 is often the way to go (Except when you have a team willing to do #1).

Categories