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.
Related
My Python App Engine Flex application needs to connect to an external Oracle database. Currently I'm using the cx_Oracle Python package which requires me to install the Oracle Instant Client.
I have successfully run this locally (on macOS) by following the Instant Client installation steps. The steps required me to do the following:
Make a directory called /opt/oracle
Create a symlink from /opt/oracle/instantclient_12_2/libclntsh.dylib.12.1 to ~/lib/
However, I am confused about how to do the same thing in App Engine Flex (instructions). Specifically, here's what I'm confused about:
The instructions say I should run sudo yum install libaio to install the libaio package. How do I do this on GAE Flex? Or is this package already available?
I think I can add the Instant Client files to GAE (a whopping ~100MB!), then set the LD_LIBRARY_PATH environment variable in app.yaml to export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH. Will this work?
Is this even feasible without using custom Docker containers on App Engine Flex?
Overall I'm not sure if I'm on the right track. Would love to hear from someone who has managed this before :)
If any of your dependencies is not available in the base GAE flex images provided by Google and cannot be installed via pip (because it's not a python package or it's not available in PyPI or whatever other reason) then you can't use the requirements.txt file to get it installed in your GAE flex app.
The proper way to satisfy such dependencies would be to build your own custom runtime. From About Custom Runtimes:
Custom runtimes allow you to define new runtime environments, which
might include additional components like language interpreters or
application servers.
Yes, that means providing a custom Docker file. In your particular case you'd be installing the Instant Client and libaio inside this Dockerfile. See also Building Custom Runtimes.
Answering your first question, I think that the instructions in the oracle website just show that you have to install said library for your application to work.
In the case of App engine flex, they way to ensure that the libraries are present in the deployment is with the requirements.txt textfile. There is a documentation page which does explain how to do so.
On the other hand, I will assume that "Instant Client Files" are not libraries, but necessary data for your App to run. You should use Google Cloud Storage to serve them, or any other alternative of Storage within Google Cloud.
I believe that, if this is all what you need for your App to work, pushing your own custom container should not be necessary.
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?
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.
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.
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.