mirror of
https://github.com/YunoHost/ynh-dev.git
synced 2024-09-03 20:05:59 +02:00
Remove support for LXD, update Readme accordingly.
This commit is contained in:
parent
2ca61a909f
commit
0da012335f
2 changed files with 45 additions and 81 deletions
57
README.md
57
README.md
|
@ -51,11 +51,11 @@ your capacities and resources when aiming to setup a development environment.
|
||||||
Yunohost can be developed on using a combination of the following technologies:
|
Yunohost can be developed on using a combination of the following technologies:
|
||||||
|
|
||||||
- Git (any version is sufficient)
|
- Git (any version is sufficient)
|
||||||
- LXD (>= 2.x) (though only tested with 3.x for now)
|
- Incus
|
||||||
|
|
||||||
Because LXC are containers, they are typically lightweight and quick to start and stop.
|
Because LXC are containers, they are typically lightweight and quick to start and stop.
|
||||||
But you may find the initial setup complex (in particular network configuration).
|
But you may find the initial setup complex (in particular network configuration).
|
||||||
LXD makes managing an LXC ecosystem much simpler.
|
Incus makes managing an LXC ecosystem much simpler.
|
||||||
|
|
||||||
This local development path allows to work without an internet connection,
|
This local development path allows to work without an internet connection,
|
||||||
but be aware that it will *not* allow you to easily test your email stack
|
but be aware that it will *not* allow you to easily test your email stack
|
||||||
|
@ -86,7 +86,7 @@ Yunohost can be deployed as a typical install on a remote VPS. You can then use
|
||||||
This method can potentially be faster than the local development environment
|
This method can potentially be faster than the local development environment
|
||||||
assuming you have familiarity with working on VPS machines, if you always have
|
assuming you have familiarity with working on VPS machines, if you always have
|
||||||
internet connectivity when working, and if you're okay with paying a fee. It
|
internet connectivity when working, and if you're okay with paying a fee. It
|
||||||
is also a good option if the required system dependencies (LXD/LXC, Vagrant,
|
is also a good option if the required system dependencies (Incus/LXC, Vagrant,
|
||||||
Virtualbox, etc.) are not easily available to you on your distribution.
|
Virtualbox, etc.) are not easily available to you on your distribution.
|
||||||
|
|
||||||
Please be aware that this method should **not** be used for a end-user facing
|
Please be aware that this method should **not** be used for a end-user facing
|
||||||
|
@ -107,43 +107,38 @@ Here is the development flow:
|
||||||
|
|
||||||
First you need to install the system dependencies.
|
First you need to install the system dependencies.
|
||||||
|
|
||||||
`ynh-dev` essentially requires Git and the LXD/LXC ecosystem. Be careful that
|
`ynh-dev` essentially requires Git and the Incus/LXC ecosystem. Be careful that
|
||||||
**LXD can conflict with other installed virtualization technologies such as
|
**Incus/LXC can conflict with other installed virtualization technologies such as
|
||||||
libvirt or vanilla LXCs**, especially because they all require a daemon based
|
libvirt or vanilla LXCs**, especially because they all require a daemon based
|
||||||
on DNSmasq and therefore require to listen on port 53.
|
on DNSmasq and therefore require to listen on port 53.
|
||||||
|
|
||||||
On a Debian-based system (regular Debian, Ubuntu, Mint ...), LXD can be
|
Incus can be installed with your Linux distribution package manager, such as:
|
||||||
installed using `snapd`. On other systems like Archlinux, you will probably also
|
|
||||||
be able to install `snapd` using the system package manager (or even
|
|
||||||
`lxd` directly).
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apt install git snapd
|
apt install incus
|
||||||
sudo snap install core
|
|
||||||
sudo snap install lxd
|
|
||||||
|
|
||||||
## Adding lxc/lxd to /usr/local/bin to make sure we can use them easily even
|
|
||||||
## with sudo for which the PATH is defined in /etc/sudoers and probably doesn't
|
|
||||||
## include /snap/bin
|
|
||||||
sudo ln -s /snap/bin/lxc /usr/local/bin/lxc
|
|
||||||
sudo ln -s /snap/bin/lxd /usr/local/bin/lxd
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then you shall initialize LXD which will ask you a bunch of question. Usually
|
You then need to add yourself in the incus-admin group, to run incus without sudo every time:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo usermod -a -G incus-admin $(whoami)
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you shall initialize Incus which will ask you a bunch of question. Usually
|
||||||
answering the default (just pressing enter) to all questions is fine.
|
answering the default (just pressing enter) to all questions is fine.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo lxd init
|
incus admin init
|
||||||
```
|
```
|
||||||
|
|
||||||
Pre-built images are centralized on `devbaseimgs.yunohost.org` and we'll download them from there to speed things up:
|
Pre-built images are centralized on `devbaseimgs.yunohost.org` and we'll download them from there to speed things up:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo lxc remote add yunohost https://devbaseimgs.yunohost.org --public
|
incus remote add yunohost https://devbaseimgs.yunohost.org --public
|
||||||
```
|
```
|
||||||
|
|
||||||
On Archlinux-based distributions (Arch, Manjaro, ...) it was found that it's needed
|
On Archlinux-based distributions (Arch, Manjaro, ...) it was found that it's needed
|
||||||
that LXC/LXD will throw some error about "newuidmap failed to write mapping / Failed
|
that Incus/LXC will throw some error about "newuidmap failed to write mapping / Failed
|
||||||
to set up id mapping" ... It can be [fixed with the following](https://discuss.linuxcontainers.org/t/solved-arch-linux-containers-only-run-when-security-privileged-true/4006/4) :
|
to set up id mapping" ... It can be [fixed with the following](https://discuss.linuxcontainers.org/t/solved-arch-linux-containers-only-run-when-security-privileged-true/4006/4) :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -175,11 +170,17 @@ cd ynh-dev # if not already done
|
||||||
./ynh-dev start
|
./ynh-dev start
|
||||||
```
|
```
|
||||||
|
|
||||||
This should automatically download from `devbaseimgs.yunohost.org` a pre-build ynh-dev LXC image running Yunohost unstable, and create a fresh container from it.
|
This should automatically download from `devbaseimgs.yunohost.org` a pre-build
|
||||||
|
ynh-dev LXC image running Yunohost unstable, and create a fresh container from it.
|
||||||
|
|
||||||
After starting the LXC, your terminal will automatically be attached to it. If you later disconnect from the LXC, you can go back in with `./ynh-dev attach`. Later, you might want to destroy the LXC. You can do so with `./ynh-dev destroy`.
|
After starting the LXC, your terminal will automatically be attached to it. If you
|
||||||
|
later disconnect from the LXC, you can go back in with `./ynh-dev attach`. Later,
|
||||||
|
you might want to destroy the LXC. You can do so with `./ynh-dev destroy`.
|
||||||
|
|
||||||
If you container **doesn't have an ip address nor access to internet**, this is likely because you either have a conflict with another virtualization system or that a program running on the host is using the port 53 and therefore prevent LXD's dnsmasq to run correctly (as stated before in the setup section.)
|
If you container **doesn't have an ip address nor access to internet**, this is
|
||||||
|
likely because you either have a conflict with another virtualization system or
|
||||||
|
that a program running on the host is using the port 53 and therefore prevent
|
||||||
|
Incus's dnsmasq to run correctly (as stated before in the setup section.)
|
||||||
|
|
||||||
### 3. Development and container testing
|
### 3. Development and container testing
|
||||||
|
|
||||||
|
@ -215,7 +216,7 @@ Note that `./ynh-dev use-git yunohost-admin` has a particular behavior: it start
|
||||||
|
|
||||||
### Advanced: using snapshots
|
### Advanced: using snapshots
|
||||||
|
|
||||||
You can check `lxc snapshot --help` to learn how to manage lxc snapshots.
|
You can check `incus snapshot --help` to learn how to manage incus snapshots.
|
||||||
|
|
||||||
### Alternative: Using Only Virtualbox
|
### Alternative: Using Only Virtualbox
|
||||||
|
|
||||||
|
@ -226,9 +227,9 @@ for more.
|
||||||
|
|
||||||
### Troubleshooting
|
### Troubleshooting
|
||||||
|
|
||||||
If you experiment network issues with your lxd during rebuild container steps. Probably your container are not able to get a local IP with DHCP.
|
If you experiment network issues with your incus during rebuild container steps. Probably your container are not able to get a local IP with DHCP.
|
||||||
|
|
||||||
It could be due to bridge conflict (for example if you have lxc installed too) or dnsmasq port already used.
|
It could be due to bridge conflict (for example if you have incus installed too) or dnsmasq port already used.
|
||||||
|
|
||||||
This [ticket](https://github.com/YunoHost/issues/issues/1664) could help.
|
This [ticket](https://github.com/YunoHost/issues/issues/1664) could help.
|
||||||
|
|
||||||
|
|
69
ynh-dev
69
ynh-dev
|
@ -11,8 +11,6 @@ function show_usage() {
|
||||||
destroy [DIST] [NAME] [YNH_BRANCH] Destroy the ynh-dev box (DIST=bookworm, NAME=ynh-dev and YNH_BRANCH=unstable by default)
|
destroy [DIST] [NAME] [YNH_BRANCH] Destroy the ynh-dev box (DIST=bookworm, NAME=ynh-dev and YNH_BRANCH=unstable by default)
|
||||||
rebuild [DIST] [NAME] [YNH_BRANCH] Rebuild a fresh, up-to-date box (DIST=bookworm, NAME=ynh-dev and YNH_BRANCH=unstable by default)
|
rebuild [DIST] [NAME] [YNH_BRANCH] Rebuild a fresh, up-to-date box (DIST=bookworm, NAME=ynh-dev and YNH_BRANCH=unstable by default)
|
||||||
|
|
||||||
Pass YNHDEV_BACKEND=incus to use incus instead of lxd.
|
|
||||||
|
|
||||||
${BLUE}Inside the dev instance${NORMAL}
|
${BLUE}Inside the dev instance${NORMAL}
|
||||||
${BLUE}=======================${NORMAL}
|
${BLUE}=======================${NORMAL}
|
||||||
|
|
||||||
|
@ -153,23 +151,6 @@ function prepare_cache_and_deps() {
|
||||||
# Actions #
|
# Actions #
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
function check_lxd_setup()
|
|
||||||
{
|
|
||||||
# Check lxd is installed somehow
|
|
||||||
[[ -e /snap/bin/lxd ]] || which lxd &>/dev/null \
|
|
||||||
|| critical "You need to have LXD installed for ynh-dev to be usable from the host machine. Refer to the README to know how to install it."
|
|
||||||
|
|
||||||
# Check that we'll be able to use lxc/lxd using sudo (for which the PATH is defined in /etc/sudoers and probably doesn't include /snap/bin)
|
|
||||||
if [[ ! -e /usr/bin/lxc ]] && [[ ! -e /usr/bin/lxd ]] && [[ -e /snap ]]
|
|
||||||
then
|
|
||||||
[[ -e /usr/local/bin/lxc ]] && [[ -e /usr/local/bin/lxd ]] \
|
|
||||||
|| critical "You might want to add lxc and lxd inside /usr/local/bin so that there's no tricky PATH issue with sudo. If you installed lxd/lxc with snapd, this should do the trick: sudo ln -s /snap/bin/lxc /usr/local/bin/lxc && sudo ln -s /snap/bin/lxd /usr/local/bin/lxd"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ip a | grep -q lx[cd]br0 \
|
|
||||||
|| critical "There is no 'lxcbr0' or 'lxdbr0' interface... Did you ran 'lxd init' ?"
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_incus_setup()
|
function check_incus_setup()
|
||||||
{
|
{
|
||||||
# Check incus is installed somehow
|
# Check incus is installed somehow
|
||||||
|
@ -194,43 +175,25 @@ function set_incus_remote()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_setup()
|
|
||||||
{
|
|
||||||
if [[ "${YNHDEV_BACKEND:-}" == "incus" ]]; then
|
|
||||||
check_incus_setup
|
|
||||||
else
|
|
||||||
check_lxd_setup
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function backend()
|
|
||||||
{
|
|
||||||
if [[ "${YNHDEV_BACKEND:-}" == "incus" ]]; then
|
|
||||||
incus "$@"
|
|
||||||
else
|
|
||||||
sudo lxc "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_ynhdev()
|
function start_ynhdev()
|
||||||
{
|
{
|
||||||
check_setup
|
check_incus_setup
|
||||||
|
|
||||||
local DIST=${1:-bookworm}
|
local DIST=${1:-bookworm}
|
||||||
local YNH_BRANCH=${3:-unstable}
|
local YNH_BRANCH=${3:-unstable}
|
||||||
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
||||||
|
|
||||||
if ! backend info $BOX &>/dev/null
|
if ! incus info $BOX &>/dev/null
|
||||||
then
|
then
|
||||||
if ! backend image info $BOX-base &>/dev/null
|
if ! incus image info $BOX-base &>/dev/null
|
||||||
then
|
then
|
||||||
LXC_BASE="ynh-dev-$DIST-amd64-$YNH_BRANCH-base"
|
LXC_BASE="ynh-dev-$DIST-amd64-$YNH_BRANCH-base"
|
||||||
backend launch yunohost:$LXC_BASE $BOX -c security.nesting=true -c security.privileged=true \
|
incus launch yunohost:$LXC_BASE $BOX -c security.nesting=true -c security.privileged=true \
|
||||||
|| critical "Failed to launch the container ?"
|
|| critical "Failed to launch the container ?"
|
||||||
else
|
else
|
||||||
backend launch $BOX-base $BOX -c security.nesting=true -c security.privileged=true
|
incus launch $BOX-base $BOX -c security.nesting=true -c security.privileged=true
|
||||||
fi
|
fi
|
||||||
backend config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$(readlink -f $(pwd))"
|
incus config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$(readlink -f $(pwd))"
|
||||||
info "Now attaching to the container"
|
info "Now attaching to the container"
|
||||||
else
|
else
|
||||||
info "Attaching to existing container"
|
info "Attaching to existing container"
|
||||||
|
@ -245,8 +208,8 @@ function attach_ynhdev()
|
||||||
local DIST=${1:-bookworm}
|
local DIST=${1:-bookworm}
|
||||||
local YNH_BRANCH=${3:-unstable}
|
local YNH_BRANCH=${3:-unstable}
|
||||||
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
||||||
backend start $BOX 2>/dev/null || true
|
incus start $BOX 2>/dev/null || true
|
||||||
backend exec $BOX --cwd /ynh-dev -- /bin/bash
|
incus exec $BOX --cwd /ynh-dev -- /bin/bash
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy_ynhdev()
|
function destroy_ynhdev()
|
||||||
|
@ -255,8 +218,8 @@ function destroy_ynhdev()
|
||||||
local DIST=${1:-bookworm}
|
local DIST=${1:-bookworm}
|
||||||
local YNH_BRANCH=${3:-unstable}
|
local YNH_BRANCH=${3:-unstable}
|
||||||
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
||||||
backend stop $BOX
|
incus stop $BOX
|
||||||
backend delete $BOX
|
incus delete $BOX
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebuild_ynhdev()
|
function rebuild_ynhdev()
|
||||||
|
@ -268,14 +231,14 @@ function rebuild_ynhdev()
|
||||||
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH}
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
backend info $BOX-rebuild >/dev/null && backend delete $BOX-rebuild --force
|
incus info $BOX-rebuild >/dev/null && incus delete $BOX-rebuild --force
|
||||||
backend launch images:debian/$DIST/amd64 $BOX-rebuild -c security.nesting=true -c security.privileged=true
|
incus launch images:debian/$DIST/amd64 $BOX-rebuild -c security.nesting=true -c security.privileged=true
|
||||||
sleep 5
|
sleep 5
|
||||||
backend exec $BOX-rebuild -- apt install curl -y
|
incus exec $BOX-rebuild -- apt install curl -y
|
||||||
INSTALL_SCRIPT="https://install.yunohost.org/$DIST"
|
INSTALL_SCRIPT="https://install.yunohost.org/$DIST"
|
||||||
backend exec $BOX-rebuild -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $YNH_BRANCH"
|
incus exec $BOX-rebuild -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $YNH_BRANCH"
|
||||||
backend stop $BOX-rebuild
|
incus stop $BOX-rebuild
|
||||||
backend publish $BOX-rebuild --alias $BOX-base
|
incus publish $BOX-rebuild --alias $BOX-base
|
||||||
set +x
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue