What happens when buildpack is updated - cloud-foundry

All apps on our team use a buildpack named ruby_latest_buildpack. It's currently a renamed version of ruby_1_7_27_buildpack. We're about to make it become ruby_1_7_28_buildpack.
What will happen to deployed and running applications when we update ruby_latest_buildpack? If we restart an application, will it continue to run under the environment that was created by the buildpack at deploy time, or will it start to pickup features provided by the updated buildpack?

Once droplet is created(created while staging process) all the frameworks and runtime(which are essentially provided by Buildpacks) are already in Image. So if you just restart your application old buildpacks will be used. If you want to use updated buildpacks you will have to restage your application.

Related

Should I use docker in order to be able to run ChomeDriver on Azure Web App Services in Django Server?

Recently I have started a Django server on Azure Web App Service, now I want to add a usage of "ChromoDriver" for web scraping, I have noticed that for that I need to install some additional Linux packages (not python) on the machine. the problem is that it gets erased on every deployment, does it mean that I should switch to Docker ?
Container works, but you can also try to pull down the additional packages in the custom start up file without messing around the machine after the deployment
https://learn.microsoft.com/en-us/azure/developer/python/tutorial-deploy-app-service-on-linux-04

how to run Django locally as a windows executable app

I'm considering building app with Django for only one user that would run application locally on windows. I read about containerizing Django apps, but it's new for me.
My goal is to run Django server on one click like a standard windows app and connect to it on localhost and interact with web browser. It is even possible?
It is possible, but this may not be the best solution. If you want to release a Django app that can be installed on your client computer, you usually need to ensure all the dependencies are shipped with the app.
Containerising your application means it will depends on Docker runtime (or any container system you use). You will have to setup Docker with your app, or ensure your client has Docker on his machine to run it. If the destination machine runs Windows or macOS, you will need to setup docker-desktop which may be more complicated than standard Docker runtime (linux only).
But if you decide to ship your app without containerising it, it will only depends on a Python interpreter and some dependencies (Django, dateutil, etc.). In such case, using python tools like virtualenv, you may prepare a ready-to-run application by creating the venv and installing dependencies at "build time". Then, with a proper setup (MSI for Windows or DMG for macOS), you may be able to distribute the final application so the client can install and run it without any additional step (you do all the hard job yourself).
Django app can be convert into .exe but it wont work as local server while click .exe because runserver command and some of django service wont support on this way as per my experiment.

Creating a virtualenv with already created django app

I am trying to deploy my django app in to production on a centos server. I have an app running on my computer(not server) with a code repository that doesn't utilize a virtual environment, and i wish i had set that up to begin with. I would like the production stage of the django app be run with a virtual environment, and was wondering what was the best way to go about this.
I am very cloudy on how this would work out. Would i need to set up the django app on my computer with a virtual environment, and then move the code repository to the server and go about it that way?
My understanding is the purpose of the virtual environment is to keep tabs and easily install any dependecies and software updates need to run the django app.
So the question is: Should i not worry about setting up a virtual environment on my computer, but start one on my server and start from there? Or would i run into problems when i try to git clone my project to the server because there isnt a virtualenv setup from the repository.
And if i should have it setup up on my local django app on my computer, how to i go about setting it up on an existing webapp?
The app doesn't care whether it's running in a virtualenv or not. You can simply create a new virtualenv on the server and redeploy the app inside it, reinstall the dependencies, then point your web server at the new app.

CloudFoundry - How to understand the operating system(OS) environment of an app?

We push a java app on cloud foundry using cf push with below manifest file
applications:
- name: xyz-api
instances: 1
memory: 1G
buildpack: java_buildpack_offline
path: target/xyz-api-0.1-SNAPSHOT.jar
I understand that, PAAS (ex: cloud foundry) is a layer on top of IAAS(ex:vcenter hosting linux and windows VM's).
In manifest file, buildpack just talks about userspace runtime libraries required to run an app.
Coming from non-cloud background, and reading this manifest file, I would like to understand...
1) How to understand the operating system(OS) environment, that an app is running? On which operating system...
2) How app running on bosh instance different from docker container?
1) How to understand the operating system(OS) environment, that an app is running? On which operating system...
The stack determines the operating system on which your app will run. There is a stack attribute in the manifest or you can use cf push -s to indicate the stack.
You can run cf stacks to see all available stacks.
In most environments at the time of writing, you will have cflinuxfs2. This is Ubuntu Trusty 14.04. It will be replaced by cflinuxfs3 which is Ubuntu Bionic 18.04, because Trusty is only supported through April of 2019. You will always have some cflinuxfs* stack though, the number will just vary depending on when you read this.
In some environments you might also have a Windows based stack. The original Windows based stack is windows2012r2. This is quite old as I write this so you probably won't see it any more. What you're likely to see is windows2016 or possibly something even newer depending on when you read this.
If you need more control than that, you can always push a docker container. That would let you pick the full OS image for your app.
2) How app running on bosh instance different from docker container?
Apps running on Cloud Foundry aren't deployed by BOSH directly. The app runs in a container. The container is scheduled and run by Diego. Diego is a BOSH deployed VM. So there's an extra layer in there.
At the core, the difference between running your app on Cloud Foundry and running an app in a docker container is minimal. They both run in a Linux "container" which has limitations put on it by kernel namespaces & cgroups.
The difference comes in a.) how you build the container and b.) how the container is deployed.
With Cloud Foundry, you don't build the container. You provide your app to CF & CF builds the container image based on the selected stack and the additional software added by buildpacks. The output in CF terminology is called a "droplet", but it basically an OCI image (this will be even more so with buildpacks v3). When you need to upgrade or add new code, you just repeat the process and push again. The stack and buildpacks, which are automatically updated by the platform, will in turn provide you with a patched & up-to-date app image.
With Docker, you manually create your image building it up from scratch or from some trusted base image. You add you own runtimes & application code. When you need to upgrade, that's on you to pull in updates from the base image & runtimes or worse to update your from-scratch image.
When it comes to deployment, CF handles this all for you automatically. It can run any number of instance of your app that you'd like & it will automatically place those so that your app is resilient to failures in the infrastructure & in CF.
With Docker, that's on you or increasingly often on some other tool like Kubernetes.
Hope that helps!

Difference between buildpack and droplet

Here is my understanding of cloudfoundry buildpacks and droplets
buildpack is runtimes(say, jdk) + containers(say, tomcat) + frameworks(say, spring) + service configs (if any) + your apps (if any).
droplet is buildpack deployed on a linux container.
Please correct or add additional information.
A buildpack is a collection of three binaries: detect, compile, and release. When your app bits are pushed to Cloud Foundry, the detect from all the available buildpacks are run against your bits until one returns true. For example, the Ruby buildpack checks to see if there's a Gemfile, the Python buildpack looks for a requirements.txt, etc. Next, the compile phase turns your app bits into a single runnable package, which means compiling the code (if necessary) and bundling in any additional things needed, such as JDK, tomcat, spring, etc; or a Ruby interpreter, gems, etc. That single executable is the droplet. Finally, the release phase presents the droplet and associated metadata so that the stager can upload them to the cloud controller.
To run your app, the droplet is retrieved from the cloud controller and run inside a container.
Basically, a buildpack packages your app into a droplet, which consists of your app + some other stuff, or a compiled binary version of your app, and the droplet is then run in a container.
Buildpacks are scripts which provides run time support for your Application. A build pack is a script which which contains instructions to detect, supply, finalize and release. They essentially provides your application runtime + app framework + related dependency.
Droplet is tarball file which contains Your APP+run time + framework+ dependency . This package is out put of staging and is finally deployed.