Skip to content
forked from coopdevs/devenv

Simple script to create LXC development environments

Notifications You must be signed in to change notification settings

cesarfuerte/devenv

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

devenv

A bash script to create and manage development environments using privileged LXC linux containers.

Requirements

  1. LXC >= 2.1
  2. Network bridge called lxcbr0

Notes:

  1. devenv has been also tested with LXC version 2.0.7 with Debian Stretch. In order to work, one needs to adapt the network configuration using the old keys.
  2. In Ubuntu and Debian lxc gets installed along a systemd unit called lxc-net, configurable at /etc/default/lxc-net.

See the Debian lxc how-to for both requirements.

Install

Run make install with root privileges to install the script in your system. It will copy the executable script to /usr/sbin/devenv and its config to /etc/devenv

Update

If you are keeping a copy of this repo, do: git pull && sudo make install. If you have deleted, clone again this repo and then do sudo make install.

Uninstall

Run make uninstall with root privileges to remove both the config and executable from your system. Beware that if you have substituted any of those files by anything else, they will be removed regardless.

Why in /usr/sbin?

Please give a look at Filesystem Hierarchy.

Execution

To run the devenv script you need to create a .devenv configuration file in your project directory. You can run the init command to generate it containing the following variables:

# <PROJECT_PATH>/.devenv file

NAME="<container name>"
DISTRIBUTION="<SO distribution>"
RELEASE="<SO release>"
ARCH="<SO arch>"
HOST="local.$NAME.coop"

# Optional -- To create a new user and group
DEVENV_USER="<user that will own the project>"
DEVENV_GROUP="<group that will own the project>"

# Optional -- To mount a project.
# Make sure that the directory "../$PROJECT_NAME" exists
# in the host machine before executing this script.
PROJECT_NAME="<project name>"
PROJECT_PATH="${PWD%/*}/$PROJECT_NAME"
BASE_PATH="<base project path>"
PROJECT_POST_PATH="<post project path>"

# Select the python interpeter python2.7 or python3
PYTHON_INTERPRETER=python3

Then run devenv in your project directory.

Description

The script will:

  • Create a container
  • Mount your project directory into container in /<BASE_PATH>/<PROJECT_NAME>/<PROJECT_POST_PATH>
  • Add container IP to /etc/hosts
  • Create a group with same gid of project directory and named $DEVENV_GROUP if DEVENV_GROUP and DEVENV_USER are defined.
  • Create a user with same uid and gid of project directory and named $DEVENV_USER if DEVENV_GROUP and DEVENV_USER are defined.
  • Add system user's SSH public key to user
  • Install python in container

When the execution ends, you'll have a container ready to provision and deploy your project.

About

Simple script to create LXC development environments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 98.6%
  • Makefile 1.4%