Как я могу эффективно разделить свою рабочую среду и среду домашнего пользователя?

956
Victor Polevoy

python-virtualenvРанее я использовал для инструментов Python, но теперь я нашел новую удаленную работу, которая требует много встроенных инструментов в моей системе. Вопрос в том, как я могу отделить свою рабочую среду от среды домашнего пользователя?

Например, мне нужно установить, opencvчто требует значительных изменений среды, но я не хочу постоянно сохранять эти изменения в своей системе, я хочу установить их (и все программное обеспечение, необходимое для удаленной работы) в другой среде и использовать его там, когда мне нужно. Первое, что приходит мне в голову - это простое использование chroot. Но, может быть, существуют классные практики, которых я не знаю?

Я не очень часто использовал chroot, поэтому и спрашиваю.

1

3 ответа на вопрос

1
Matthew O'N.S Jordan

I would suggest any of the following tools;

Docker

or

LXC

I am still learning Docker as I have discovered it recently, but it doesn't take one long to realize that Docker is tool built for developers. Give it spin and enjoy! And note that Docker rocks when it comes to configuring things via Environment Variables.

I have used LXC tools for while and they are pretty okay but, for development they require a lot of setup work. And chroots require even more work too, to me they take away from you development focus. And they are not very portable.

Also you might want to take a look at Vagrant.

Can't post a lot links here since I'm new but Vagrant is so popular if you type it in a google search it will be the first or second result you see.

"Create and configure lightweight, reproducible, and portable development environments."

Also note that Vagrant works with various Virtual Machine or Container Environments. Think of it as a tool to create your virtual development environment with one command "vagrant up". And it's not limited to Linux, it works (exactly the same!) on Linux, Mac OS and Windows.

Not to mention when you docker and/or vagrant you can check your Dockerfile or Vagrantfile into your version control system. So they become part of your project and change with your project.

Hope these tools help.

1
Matty

Docker may work for you but that isn't the best tool for the job.

I would strongly suggest you look at Vagrant. It will do exactly what you I believe and it much easier to deal with.

In a nutshell you have your desktop and then you install virtualbox and vagrant.

Possible workkflow:

  1. Download a prebuilt box that match as close as possible to your needs
  2. Startup vagrant using this box
  3. SSH into the virtual machine(box)
  4. Do your thing
  5. Stop the machine when done.

Some of the advantages to this are you can add a script that will automatically run when you start vagrant, this can configure your environment how you choose and make sure it is always identical every time, Chef/Puppet/Ansible/? can be used as well to great effect.

If you don't feel like keeping a lot of virtual machines around, you have the ability to delete them and then when you need them again you could just download the box again and run the script.

Another good point about this when developing is that if something goes haywire, you can just shutdown the system and bring it back up again and it will be clean and fresh. Shared folders are automatically configured as well so you can drop anything you want into the root vagrant directory on the host and it will be located in /vagrant on the virtual machine.

If you use a tool called packer, you can build the vagrant box and also other types as well including OVF, Digital Ocean, and AWS. Racker is a great addition to packer as well. At some point you may want to deploy and this will ensure the image that is being deployed will match 100% the image you have been working with, in fact Packer is what vagrant and a lot of other companies use to build vagrant boxes.

http://blog.endpoint.com/2014/03/provisioning-development-environment.html

http://blog.codeship.io/2013/11/07/building-vagrant-machines-with-packer.html

0
andrewsh

If you use Debian, I'd recommend you to use debootstrap to create chroots. Also, there's a tool called schroot which allows you to create an arbitrary number of chroots, manage permissions and do all sorts of stuff with them. Unfortunately, it's way too advanced for me, so I'm using only debootstrap alone, and sometimes cowbuilder/pbuilder to recreate a clean build environment.