Skip to content

Commit

Permalink
fixup! fix: github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
olexii4 committed May 2, 2024
1 parent 77436fa commit d6cd27e
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 27 deletions.
65 changes: 45 additions & 20 deletions .devfile.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
FROM quay.io/devfile/universal-developer-image:ubi8-6eb0041
FROM docker.io/debian:buster

# 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
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 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 && \
apt-get clean && \
useradd -m user && \
echo 'user ALL=NOPASSWD: ALL' > /etc/sudoers.d/user

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='*'
# Install Node.js for che-code editor
ENV NODE_VERSION=v18.18.2
ENV NODE_DISTRO=linux-x64
ENV NODE_BASE_URL=https://nodejs.org/dist/${NODE_VERSION}

RUN npm install -g http-server
# Switch back to default user
USER 10001
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

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'

Expand All @@ -24,17 +44,22 @@ RUN mkdir -p /tmp/pre-install /tmp/pre-install/openwrt /tmp/pre-install/openwrt/
&& 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 \
&& scripts/feeds update -a -f \
&& scripts/feeds install -a -f \
&& make -j$(nproc) > /dev/null 2>&1 \
&& zip -r /tmp/pre-install/bin.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/bin \
&& 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 \
&& rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/build_dir \
&& zip -r /tmp/pre-install/dl.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/dl\
&& rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/dl \
&& zip -r /tmp/pre-install/feeds.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/feeds \
&& 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 \
&& rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}/staging_dir \
&& zip -r /tmp/pre-install/tmp.zip /tmp/pre-install/openwrt-${OPENWRT_VERSION}/tmp \
&& rm -rf /tmp/pre-install/openwrt-${OPENWRT_VERSION}
27 changes: 27 additions & 0 deletions configs/.x86-generic.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 19 additions & 4 deletions devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ components:
- name: runtime
container:
image: quay.io/che-incubator/openwrt-builder:latest
memoryLimit: 20G
memoryLimit: 7G
memoryRequest: 512Mi
cpuLimit: 10000m
cpuRequest: 1000m
mountSources: true
env:
- name: KUBEDOCK_ENABLED
value: "true"
endpoints:
- exposure: public
name: file-server
Expand All @@ -30,7 +33,7 @@ components:
container:
image: quay.io/che-incubator/openwrt-runner:latest
command: ['tail', '-f', '/dev/null']
memoryLimit: 2G
memoryLimit: 1280Mi
memoryRequest: 256Mi
cpuLimit: 1000m
cpuRequest: 500m
Expand All @@ -40,6 +43,10 @@ components:
name: luci
protocol: http
targetPort: 30080
- exposure: public
name: ssh
protocol: tcp
targetPort: 30022
commands:
- id: installpackagedefinitions
exec:
Expand Down Expand Up @@ -77,8 +84,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
Expand All @@ -97,6 +104,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
Expand Down
15 changes: 15 additions & 0 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
22 changes: 19 additions & 3 deletions dockerfiles/qemu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ RUN apk add --no-cache \
&& \
rm -f /usr/share/qemu/edk2-*

# Download OpenWRT image
ENV IMAGE_URL="https://downloads.openwrt.org/releases/21.02.3/targets/x86/64/openwrt-21.02.3-x86-64-generic-ext4-combined.img.gz"
ENV IMAGE_FILE="openwrt-21.02.3-x86-64-generic-ext4-combined.img.gz"
ENV IMAGE_SHA256="f5a0401048d6fb3f707581c4914086093fecea642c86507714caea967a4a6a32"

WORKDIR /var/lib/qemu-image

RUN curl -L "${IMAGE_URL}" -o "${IMAGE_FILE}" && \
sh -x -c '[ "$(sha256sum "${IMAGE_FILE}")" = "${IMAGE_SHA256} ${IMAGE_FILE}" ]'

# Support Arbitrary User IDs in container
RUN echo -e '#!/bin/sh\n\
set -ex \n\
Expand All @@ -29,6 +39,12 @@ fi \n\
chmod g=u /etc/passwd && \
chmod g=u /etc/group

RUN mkdir -p /projects /projects/openwrt-helloworld /projects/openwrt-helloworld/output

COPY ${PWD}/output/openwrt-x86-generic-generic-ext4-combined.img.gz /projects/openwrt-helloworld/output/openwrt-x86-generic-generic-ext4-combined.img.gz

RUN gunzip --stdout "/projects/openwrt-helloworld/output/openwrt-x86-generic-generic-ext4-combined.img.gz" > /projects/openwrt-helloworld/output/image.raw || true

# Provision VM disk image
RUN echo -e '#!/bin/sh\n\
set -ex \n\
Expand Down Expand Up @@ -207,7 +223,7 @@ ENV QEMU_STORAGE="1G"
ENV QEMU_SMP="2"
ENV QEMU_LAN_OPTIONS=""
ENV QEMU_WAN_NETWORK="172.16.0.0/24"
ENV QEMU_WAN_OPTIONS="hostfwd=tcp::30088-:88,hostfwd=tcp::30022-:22,hostfwd=tcp::30080-:80,hostfwd=tcp::30443-:443,hostfwd=udp::51820-:51820"
ENV QEMU_WAN_OPTIONS="hostfwd=tcp::30022-:22,hostfwd=tcp::30080-:80,hostfwd=tcp::30443-:443,hostfwd=udp::51820-:51820"
ENV QEMU_PASSWORD="pass1234"
ENV QEMU_CONFIG_TIMEOUT="300"
ENV QEMU_CONFIG_NO_DEFAULTS=""
Expand All @@ -217,12 +233,12 @@ ENV QEMU_ARGS=""
EXPOSE 5900/tcp
EXPOSE 30022/tcp
EXPOSE 30080/tcp
EXPOSE 30088/tcp
EXPOSE 30443/tcp
EXPOSE 51820/udp
HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 CMD [ "/usr/local/bin/healthcheck-vm.sh" ]
VOLUME /var/lib/vmconfig
VOLUME /var/lib/qemu
WORKDIR /tmp
USER 1001
USER 1001
CMD ["tail", "-f", "/dev/null"]
Binary file not shown.
27 changes: 27 additions & 0 deletions scripts/copy-prebuilt-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

if [ - f "/tmp/pre-install/bin.zip" ]; then
unzip "/tmp/pre-install/bin.zip" -d /projects/openwrt/bin
fi

if [ - f "/tmp/pre-install/build_dir.zip" ]; then
unzip "/tmp/pre-install/build_dir.zip" -d /projects/openwrt/build_dir
fi

if [ - f "/tmp/pre-install/dl.zip" ]; then
unzip "/tmp/pre-install/dl.zip" -d /projects/openwrt/dl
fi

if [ - f "/tmp/pre-install/feeds.zip" ]; then
unzip "/tmp/pre-install/feeds.zip" -d /projects/openwrt/feeds
fi

if [ - f "/tmp/pre-install/staging_dir.zip" ]; then
unzip "/tmp/pre-install/staging_dir.zip" -d /projects/openwrt/staging_dir
fi

if [ - f "/tmp/pre-install/tmp.zip" ]; then
unzip "/tmp/pre-install/tmp.zip" -d /projects/openwrt/tmp
fi

0 comments on commit d6cd27e

Please sign in to comment.