diff --git a/docs/guide/lxc_migration.md b/docs/guide/lxc_migration.md new file mode 100644 index 0000000000000000000000000000000000000000..240e7a99859398933b0c2e454abe36a3420ccf1d --- /dev/null +++ b/docs/guide/lxc_migration.md @@ -0,0 +1,67 @@ +# LXC Based container migration +SWMODD in release-6.5 branch based releases only has support for LXC based containers, but in devel now it has support support for OCI based containers and LXC based containers both. + +OCI based containers being preferred option for LCM in devel. This document aims to provide guidance for migrating LXC containers from release-6.5 to devel. + +## Bit inside on lxc container handling +1. LXC build root defined in '/etc/lxc/lxc.conf' with "lxc.lxcpath" option +2. Each LXC container mapped to 'Device.SoftwareModules.ExecEnv.' datamodel parameter +3. Additional Installed DU's installed in a container stored in `/etc/swmod/map_du_<container_name>` file + +```bash +config deployment + option name 'bbk_cli' + option version '7b810a69' + option uuid '477a210f-9ed1-401a-b028-717a726e5296' + option duid '9zz0000' + option environment 'test' + option eeid '1' + list service 'bbk_cli' + option description 'To measure connection speed in an environment that is missing a web browser, ' +``` + +4. Auto-start of LXC based containers managed with the help of `lxc-auto` package and is stored in `/etc/config/lxcauto` file +5. LXC based container configuration stored in a `config` file inside build root path + +So, the information is bit scattered and had too many dependencies on external modules, also some information does not persists across factory reset. + +## Bit inside on devel changes +1. Defining the bundle root now moved to swmodd uci (In deployment, its a best practice use a non-root persistent storage path for this option) + +```bash +config globals 'globals' + option lxc_bundle_root '/mnt/container/' + option oci_bundle_root '/mnt/container/' +``` + +- But it still has preference on `lxc.conf` configuration, it works like + - If lxcpath is set in /etc/config/swmodd then swmodd configures the same in lxc.conf through uci-default script + - If not defined in /etc/config/swmodd but lxcpath is present in lxc.conf then uci-default script writes the lxc_bundle_root with the same in swmodd uci + - If not defined in /etc/config/swmodd and also in lxc.conf then uci-default set it with "/srv/" in both lxc.conf and /etc/config/swmodd + +2. LXC containers still mapped to `Device.SoftwareModules.ExecEnv.`, but it start with instance id 2 +3. `Device.SoftwareModules.ExecEnv.1` mapped to system and used for OCI based containers +4. OCI containers mapped to `Device.SoftwareModules.DeploymentUnits.` +5. To make the LXC and OCI containers information persistent across factory reset, now its stored in lxc_bundle_root path in "lxccontainer" (for lxc info) file. +6. auto-boot dependency now moved to swmodd it self based on mappings present in "lxccontainer" uci file. + +```bash +config container + option name '<container_name>' + option type 'lxc' + option autostart '1' +``` + +7. All DU and EU details are stored in lxccontainer uci file as well for LXC based containers + +## Migration notes +1. lxc-auto must not be present as now lxc containers handled by swmodd itself. +2. uci-default script '02-migrate-lxc' added to migrate the lxcauto to new uci file + + +## Summary +Moving forward lxc based container will be deprecated, so its good to update the lxc/config to oci/config.json, so that the lxc container can be run as oci containers. + +- [OCI runtime specs](https://github.com/opencontainers/runtime-spec/blob/main/config.md) +- [LXC runtime specs](https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html) +- [LXC config manpages](https://manpages.ubuntu.com/manpages/trusty/man5/lxc.container.conf.5.html) diff --git a/examples/iowrt/Dockerfile b/examples/iowrt/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f4efd2284d8002b00ad90c402f3d03f1b0b135f1 --- /dev/null +++ b/examples/iowrt/Dockerfile @@ -0,0 +1,64 @@ +# Alpine Base +FROM alpine:latest AS builder + +# Staging area +RUN apk add --no-cache git cmake make clang build-base llvm-static llvm-dev clang-static clang-dev json-c-dev lua5.1-dev + +RUN mkdir -p /opt/dev + +# libubox +RUN \ + cd /opt/dev && \ + git clone https://git.openwrt.org/project/libubox.git && \ + cd libubox && mkdir build && cd build && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE:String="Release" .. && \ + make -j2 && \ + make install + +# uci +RUN \ + cd /opt/dev && \ + git clone https://git.openwrt.org/project/uci.git && \ + cd uci && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" -DBUILD_LUA=OFF . && \ + make -j2 && \ + make install + +# ubus +RUN \ + cd /opt/dev && \ + git clone https://git.openwrt.org/project/ubus.git && \ + cd ubus && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" -DBUILD_LUA=OFF -DBUILD_EXAMPLES=OFF . && \ + make -j2 && \ + make install + +# Final image +FROM alpine:latest + +MAINTAINER Vivek Dutta "vivek.dutta@iopsys.eu" +ENV VERSION=devel +LABEL vendor=IOPSYS \ + org.opencontainers.image.version=$VERSION\ + org.opencontainers.image.vendor="IOPSYS" \ + org.opencontainers.image.description="IOWRT Application container" + +RUN apk add --no-cache json-c libxml2 mosquitto mosquitto-clients + +COPY --from=builder \ + /usr/lib/libuci.so \ + /usr/lib/libblobmsg_json.so \ + /usr/lib/libubus.so \ + /usr/lib/libubox.so \ + /usr/lib/ + +COPY --from=builder \ + /usr/share/libubox/jshn.sh /usr/share/libubox/jshn.sh + +COPY --from=builder \ + /usr/bin/ubus \ + /usr/bin/uci \ + /usr/bin/jshn \ + /usr/bin/ + +CMD ["/bin/sh"]