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 4, 2024
1 parent 77436fa commit 4df0f9c
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 57 deletions.
109 changes: 69 additions & 40 deletions .devfile.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
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
26 changes: 18 additions & 8 deletions devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,32 @@ components:
- name: runtime
container:
image: quay.io/che-incubator/openwrt-builder:latest
memoryLimit: 20G
memoryLimit: 6656Mi
memoryRequest: 512Mi
cpuLimit: 10000m
cpuRequest: 1000m
mountSources: true
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
Expand Down Expand Up @@ -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
Expand All @@ -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
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"]
17 changes: 12 additions & 5 deletions dockerfiles/qemu.Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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\
Expand Down Expand Up @@ -113,7 +120,7 @@ cat <<EOF\n\
\n\
mkdir /tmp/vmconfig \n\
tar -zxvf /tmp/vmconfig.tgz -C /tmp/vmconfig \n\
sleep 5 \n\
sleep 10 \n\
(cd /tmp/vmconfig && (for f in \$(ls vm.d); do echo "Executing ./vm.d/\$f"; "./vm.d/\$f" || exit 1; done)) && echo -e "\\nVM configuration result: successful." || echo -e "\\nVM configuration result: failed." \n\
poweroff \n\
EOF\n\
Expand Down Expand Up @@ -207,7 +214,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 +224,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 modified output/openwrt-x86-generic-generic-ext4-combined.img.gz
Binary file not shown.
8 changes: 4 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ set -e

cd /projects/openwrt/ && make defconfig && make -j$(nproc)

if [ ! -d "/projects/openwrt-helloworld/output" ]; then
mkdir -p "/projects/openwrt-helloworld/output"
if [ ! -d /projects/openwrt-helloworld/output ]; then
mkdir -p /projects/openwrt-helloworld/output
fi

if [ - f "/projects/openwrt-helloworld/output/image.raw" ]; then
rm -f "/projects/openwrt-helloworld/output/image.raw"
if [ -f /projects/openwrt-helloworld/output/image.raw ]; then
rm -f /projects/openwrt-helloworld/output/image.raw
fi

cp -r /projects/openwrt/bin/targets/*/*/openwrt-*.gz /projects/openwrt-helloworld/output/
26 changes: 26 additions & 0 deletions scripts/copy-prebuilt-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

if [ -f /tmp/pre-install/openwrt/feeds.zip ]; then
if [ -d /projects/openwrt/feeds ]; then
rm -rf /projects/openwrt/feeds
fi
unzip /tmp/pre-install/openwrt/feeds.zip && mv /tmp/pre-install/openwrt/feeds /projects/openwrt/
fi

if [ -f /tmp/pre-install/openwrt/targets.zip ]; then
if [ -d /projects/openwrt/bin/targets ]; then
rm -rf /projects/openwrt/bin/targets
fi
if [ ! -d /projects/openwrt/bin ]; then
mkdir -p /projects/openwrt/bin
fi
unzip /tmp/pre-install/openwrt/targets.zip && mv /tmp/pre-install/openwrt/targets /projects/openwrt/bin
fi

if [ ! -d /projects/openwrt-helloworld/output ]; then
mkdir -p /projects/openwrt-helloworld/output
fi

cp -r /projects/openwrt/bin/targets/*/*/openwrt-*.gz /projects/openwrt-helloworld/output/

0 comments on commit 4df0f9c

Please sign in to comment.