diff --git a/.devfile.Dockerfile b/.devfile.Dockerfile index aff2e7e..9807175 100644 --- a/.devfile.Dockerfile +++ b/.devfile.Dockerfile @@ -1,40 +1,69 @@ -FROM quay.io/devfile/universal-developer-image:ubi8-6eb0041 - -# Switching to root user (setting UID to 0) because next -# commands require root privileges. Universal Developer -# Image default user has UID set to 10001. -USER 0 - -RUN dnf -y update && dnf -y install \ - gcc gcc-c++ make ncurses-devel patch rsync tar unzip bzip2 wget which diffutils python2 python3 perl &&\ - dnf -y clean all --enablerepo='*' - -RUN npm install -g http-server -# Switch back to default user -USER 10001 - -ARG OPENWRT_BASE_URL='https://github.com/openwrt/openwrt' -ARG OPENWRT_VERSION='23.05.0-rc1' - -COPY ${PWD}/package/helloworld /tmp/helloworld -COPY ${PWD}/configs/.x86-generic.config /tmp/.config - -RUN mkdir -p /tmp/pre-install /tmp/pre-install/openwrt /tmp/pre-install/openwrt/${OPENWRT_VERSION} \ - && curl "${OPENWRT_BASE_URL}/archive/refs/tags/v${OPENWRT_VERSION}.zip" -L -o "/tmp/pre-install/openwrt-${OPENWRT_VERSION}.zip" \ - && unzip "/tmp/pre-install/openwrt-${OPENWRT_VERSION}.zip" -d /tmp/pre-install \ - && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}.zip \ - && cd /tmp/pre-install/openwrt-${OPENWRT_VERSION} \ - && scripts/feeds update -a -f \ - && scripts/feeds install -a -f \ - && cp /tmp/.config /tmp/pre-install/openwrt-${OPENWRT_VERSION}/.config \ - && cp -r /tmp/helloworld /tmp/pre-install/openwrt-${OPENWRT_VERSION}/package/helloworld \ - && cd /tmp/pre-install/openwrt-${OPENWRT_VERSION} \ - && make defconfig \ - && make -j1 \ - && mv bin /tmp/pre-install/openwrt/${OPENWRT_VERSION}/bin \ - && mv build_dir /tmp/pre-install/openwrt/${OPENWRT_VERSION}/build_dir \ - && mv dl /tmp/pre-install/openwrt/${OPENWRT_VERSION}/dl \ - && mv feeds /tmp/pre-install/openwrt/${OPENWRT_VERSION}/feeds \ - && mv staging_dir /tmp/pre-install/openwrt/${OPENWRT_VERSION}/staging_dir \ - && mv tmp /tmp/pre-install/openwrt/${OPENWRT_VERSION}/tmp \ - && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION} +FROM docker.io/debian:buster + +USER root +# Install openwrt build dependencies +RUN apt-get update &&\ + apt-get install -y \ + sudo ccache time git-core subversion build-essential g++ bash make \ + libssl-dev patch libncurses5 libncurses5-dev zlib1g-dev gawk \ + flex gettext wget zip unzip xz-utils python python-distutils-extra \ + python3 python3-distutils-extra rsync curl libsnmp-dev liblzma-dev \ + libpam0g-dev cpio rsync re2c && \ + wget https://github.com/cli/cli/releases/download/v2.39.2/gh_2.39.2_linux_amd64.deb && \ + apt-get install -f ./gh_2.39.2_linux_amd64.deb && \ + rm -f ./gh_2.39.2_linux_amd64.deb && \ + apt-get clean && \ + useradd -m user && \ + echo 'user ALL=NOPASSWD: ALL' > /etc/sudoers.d/user + +# Install Node.js for che-code editor +ARG NODE_VERSION=v20.12.2 +ARG NODE_DISTRO=linux-x64 +ARG NODE_BASE_URL=https://nodejs.org/dist/${NODE_VERSION} + +RUN curl -fsSL ${NODE_BASE_URL}/node-${NODE_VERSION}-${NODE_DISTRO}.tar.gz -o node-${NODE_VERSION}-${NODE_DISTRO}.tar.gz \ + && mkdir -p /usr/local/lib/nodejs \ + && tar -xzf node-${NODE_VERSION}-${NODE_DISTRO}.tar.gz -C /usr/local/lib/nodejs \ + && rm node-${NODE_VERSION}-${NODE_DISTRO}.tar.gz + +ENV VSCODE_NODEJS_RUNTIME_DIR=/usr/local/lib/nodejs/node-${NODE_VERSION}-${NODE_DISTRO}/bin +ENV PATH=${VSCODE_NODEJS_RUNTIME_DIR}:$PATH + +RUN apt-get install -y npm \ + && npm install -g http-server + +USER user + +# Install OpenWRT build dependencies +#ARG OPENWRT_BASE_URL='https://github.com/openwrt/openwrt' +#ARG OPENWRT_VERSION='23.05.0-rc1' +# +#COPY ${PWD}/package/helloworld /tmp/helloworld +#COPY ${PWD}/configs/.x86-generic.config /tmp/.config +# +#RUN mkdir -p /tmp/pre-install /tmp/pre-install/openwrt /tmp/pre-install/openwrt/${OPENWRT_VERSION} \ +# && curl "${OPENWRT_BASE_URL}/archive/refs/tags/v${OPENWRT_VERSION}.zip" -L -o "/tmp/pre-install/openwrt-${OPENWRT_VERSION}.zip" \ +# && unzip "/tmp/pre-install/openwrt-${OPENWRT_VERSION}.zip" -d /tmp/pre-install \ +# && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}.zip \ +# && cd /tmp/pre-install/openwrt-${OPENWRT_VERSION} \ +# && cp /tmp/.config /tmp/pre-install/openwrt-${OPENWRT_VERSION}/.config \ +# && cp -r /tmp/helloworld /tmp/pre-install/openwrt-${OPENWRT_VERSION}/package/helloworld \ +# && cd /tmp/pre-install/openwrt-${OPENWRT_VERSION} \ +# && make defconfig \ +# && scripts/feeds update -a -f \ +# && scripts/feeds install -a -f \ +# && make -j$(nproc) || true \ +# && zip -r /tmp/pre-install/bin.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/bin || true \ +# && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/bin \ +# && zip -r /tmp/pre-install/build_dir.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/build_dir || true \ +# && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/build_dir \ +# && zip -r /tmp/pre-install/dl.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/dl || true \ +# && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/dl \ +# && zip -r /tmp/pre-install/feeds.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/feeds || true \ +# && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/feeds \ +# && zip -r /tmp/pre-install/staging_dir.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/staging_dir || true \ +# && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/staging_dir \ +# && zip -r /tmp/pre-install/tmp.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/tmp || true \ +# && rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION} + +CMD ["tail", "-f", "/dev/null"] diff --git a/configs/.x86-generic.config b/configs/.x86-generic.config index 4fe85f7..457f07b 100644 --- a/configs/.x86-generic.config +++ b/configs/.x86-generic.config @@ -4,13 +4,40 @@ CONFIG_TARGET_x86_generic_DEVICE_generic=y CONFIG_DEBUG=y # CONFIG_GRUB_CONSOLE is not set # CONFIG_GRUB_EFI_IMAGES is not set +CONFIG_PACKAGE_cgi-io=y CONFIG_PACKAGE_gdb=y CONFIG_PACKAGE_gdbserver=y # CONFIG_PACKAGE_grub2-efi is not set CONFIG_PACKAGE_libgmp=y +CONFIG_PACKAGE_libiwinfo=y +CONFIG_PACKAGE_libiwinfo-data=y +CONFIG_PACKAGE_liblucihttp=y +CONFIG_PACKAGE_liblucihttp-ucode=y CONFIG_PACKAGE_libncurses=y CONFIG_PACKAGE_libreadline=y CONFIG_PACKAGE_libstdcpp=y +CONFIG_PACKAGE_luci=y +CONFIG_PACKAGE_luci-app-firewall=y +CONFIG_PACKAGE_luci-app-opkg=y +CONFIG_PACKAGE_luci-base=y +CONFIG_PACKAGE_luci-light=y +CONFIG_PACKAGE_luci-mod-admin-full=y +CONFIG_PACKAGE_luci-mod-network=y +CONFIG_PACKAGE_luci-mod-status=y +CONFIG_PACKAGE_luci-mod-system=y +CONFIG_PACKAGE_luci-proto-ipv6=y +CONFIG_PACKAGE_luci-proto-ppp=y +CONFIG_PACKAGE_luci-theme-bootstrap=y +CONFIG_PACKAGE_rpcd=y +CONFIG_PACKAGE_rpcd-mod-file=y +CONFIG_PACKAGE_rpcd-mod-iwinfo=y +CONFIG_PACKAGE_rpcd-mod-luci=y +CONFIG_PACKAGE_rpcd-mod-rrdns=y +CONFIG_PACKAGE_rpcd-mod-ucode=y CONFIG_PACKAGE_terminfo=y +CONFIG_PACKAGE_ucode-mod-html=y +CONFIG_PACKAGE_ucode-mod-math=y +CONFIG_PACKAGE_uhttpd=y +CONFIG_PACKAGE_uhttpd-mod-ubus=y CONFIG_PACKAGE_zlib=y # CONFIG_TARGET_ROOTFS_SQUASHFS is not set \ No newline at end of file diff --git a/devfile.yaml b/devfile.yaml index 69f875f..43f27f0 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -15,7 +15,7 @@ components: - name: runtime container: image: quay.io/che-incubator/openwrt-builder:latest - memoryLimit: 20G + memoryLimit: 6656Mi memoryRequest: 512Mi cpuLimit: 10000m cpuRequest: 1000m @@ -23,22 +23,24 @@ components: endpoints: - exposure: public name: file-server - protocol: http + protocol: https targetPort: 8080 path: /bin/targets - name: qemu container: image: quay.io/che-incubator/openwrt-runner:latest - command: ['tail', '-f', '/dev/null'] - memoryLimit: 2G + memoryLimit: 1536Mi memoryRequest: 256Mi - cpuLimit: 1000m + cpuLimit: 1500m cpuRequest: 500m mountSources: true + env: + - name: KUBEDOCK_ENABLED + value: "true" endpoints: - exposure: public name: luci - protocol: http + protocol: https targetPort: 30080 commands: - id: installpackagedefinitions @@ -77,8 +79,8 @@ commands: exec: label: "Save diff-config to openwrt-helloworld" component: runtime - workingDir: ${PROJECTS_ROOT} - commandLine: "/projects/openwrt/scripts/diffconfig.sh > /projects/openwrt-helloworld/configs/.x86-generic.config" + workingDir: ${PROJECTS_ROOT}/openwrt + commandLine: "scripts/diffconfig.sh > /projects/openwrt-helloworld/configs/.x86-generic.config" group: kind: build - id: buildhelloworldpackage @@ -97,6 +99,14 @@ commands: commandLine: "scripts/build.sh" group: kind: build + - id: copyprebuiltdata + exec: + label: "Copy prebuilt data" + component: runtime + workingDir: ${PROJECTS_ROOT}/openwrt-helloworld + commandLine: "scripts/copy-prebuilt-data.sh" + group: + kind: build - id: qemustart exec: label: Running OpenWRT in a QEMU VM diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile new file mode 100644 index 0000000..d68050f --- /dev/null +++ b/dockerfiles/Dockerfile @@ -0,0 +1,15 @@ +FROM scratch +ADD output/openwrt-x86-generic-generic-rootfs.tar.gz / + +EXPOSE 80 + +RUN mkdir /var/lock && \ + opkg update && \ + opkg install uhttpd-mod-lua && \ + uci set uhttpd.main.interpreter='.lua=/usr/bin/lua' && \ + uci set uhttpd.main.redirect_https=1 && \ + uci commit uhttpd + +USER root + +CMD ["/sbin/init"] \ No newline at end of file diff --git a/dockerfiles/qemu.Dockerfile b/dockerfiles/qemu.Dockerfile index 649c16d..3321558 100644 --- a/dockerfiles/qemu.Dockerfile +++ b/dockerfiles/qemu.Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/alpine:3.19 +FROM docker.io/library/alpine:3.16 # Install QEMU, remove large unnecessary files RUN apk add --no-cache \ @@ -32,6 +32,13 @@ fi \n\ # Provision VM disk image RUN echo -e '#!/bin/sh\n\ set -ex \n\ +if [ ! -f /projects/openwrt-helloworld/output/image.raw ]; then \n\ + echo "No `/projects/openwrt-helloworld/output/image.raw` file." \n\ + exit 1 \n\ +fi \n\ +if [ -f /var/lib/qemu/image.qcow2 ]; then \n\ + rm /var/lib/qemu/image.qcow2 \n\ +fi \n\ qemu-img convert -f raw -O qcow2 /projects/openwrt-helloworld/output/image.raw /var/lib/qemu/image.qcow2 \n\ rm /projects/openwrt-helloworld/output/image.raw \n\ if [ -n "${QEMU_STORAGE}" ]; then \n\ @@ -113,7 +120,7 @@ cat <