Add angular web ui to Docker image

This commit is contained in:
Albrecht Lohofener
2025-03-19 21:16:48 +01:00
parent 69718f3418
commit c71c1568d2
4 changed files with 24 additions and 73 deletions
+20 -7
View File
@@ -2,7 +2,7 @@
# Build stage for rust backend
########################################################################################################################
FROM rust:alpine AS builder
FROM rust:alpine AS build-backend
ARG TARGETPLATFORM
@@ -30,12 +30,24 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
cp /usr/src/qemu-backend/target/x86_64-unknown-linux-musl/release/qemu-openwrt-web-backend /usr/local/bin; \
fi
########################################################################################################################
# Build stage for angular frontend
########################################################################################################################
FROM node:latest as build-frontend
WORKDIR /usr/local/app
COPY ./web-frontend /usr/local/app/
RUN npm install
RUN npm run build
########################################################################################################################
# OpenWrt image
########################################################################################################################
FROM alpine:latest
ARG NOVNC_VERSION="1.5.0"
ARG NOVNC_VERSION="1.5.0"
ARG OPENWRT_VERSION="24.10.0"
ARG TARGETPLATFORM
ARG OPENWRT_ROOTFS_IMG
@@ -140,14 +152,14 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \
\
# OpenWrt master uses apk insted of opkg \
&& if [ "$OPENWRT_VERSION" = "master" ]; then \
PACKAGE_UPDATE="apk update"; \
PACKAGE_UPDATE="apk update"; \
PACKAGE_INSTALL="apk add"; \
PACKAGE_REMOVE="apk del"; \
PACKAGE_EXTRA="libudev-zero"; \
else \
PACKAGE_UPDATE="opkg update"; \
PACKAGE_INSTALL="opkg install"; \
PACKAGE_REMOVE="opkg remove"; \
PACKAGE_REMOVE="opkg remove"; \
PACKAGE_EXTRA=""; \
fi \
\
@@ -163,7 +175,7 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \
&& ssh root@localhost -p $SSH_PORT "${PACKAGE_INSTALL} hostapd wpa-supplicant kmod-mt7921u" \
# Download celluar network support \
&& ssh root@localhost -p $SSH_PORT "${PACKAGE_INSTALL} modemmanager kmod-usb-net-qmi-wwan luci-proto-modemmanager qmi-utils" \
# Download basic GPS support \
# Download basic GPS support \
&& ssh root@localhost -p $SSH_PORT "${PACKAGE_INSTALL} kmod-usb-serial minicom gpsd" \
# Add Wireguard support \
&& ssh root@localhost -p $SSH_PORT "${PACKAGE_INSTALL} wireguard-tools luci-proto-wireguard" \
@@ -191,9 +203,10 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \
&& echo "OPENWRT_CPU_ARCH=\"${TARGETPLATFORM}\"" >> /var/vm/openwrt_metadata.conf \
&& echo "CONTAINER_CREATE_DATETIME=\"`date`\"" >> /var/vm/openwrt_metadata.conf
COPY --from=builder /usr/local/bin/qemu-openwrt-web-backend /usr/local/bin/qemu-openwrt-web-backend
COPY --from=build-backend /usr/local/bin/qemu-openwrt-web-backend /usr/local/bin/qemu-openwrt-web-backend
COPY --from=build-frontend /usr/local/app/dist/openwrt-docker-web-gui /var/www/
COPY ./web-frontend/nginx* /var/www/
COPY ./src /run/
COPY ./web-frontend /var/www/
RUN chmod +x /run/*.sh
+2 -2
View File
@@ -45,8 +45,8 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
"maximumWarning": "4MB",
"maximumError": "8MB"
},
{
"type": "anyComponentStyle",
+1 -39
View File
@@ -26,45 +26,7 @@ server {
add_header Cache-Control "no-cache";
location / {
root /var/www;
}
location /novnc {
index vnc.html;
alias /usr/share/novnc;
try_files $uri $uri/ /vnc.html;
if ($request_uri = "/novnc/") {
return 301 ?resize=scale&autoconnect=true&reconnect_delay=2000&reconnect=true;
}
}
location /websockify {
proxy_http_version 1.1;
proxy_set_header Connection 'upgrade';
proxy_set_header Upgrade $http_upgrade;
proxy_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_pass http://127.0.0.1:5700/;
}
location /script-server/ {
proxy_pass_header Server;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:5000/;
# needed for websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Origin http://$proxy_host;
root /var/www/browser;
}
location /api/ {
+1 -25
View File
@@ -26,31 +26,7 @@ server {
add_header Cache-Control "no-cache";
location / {
root /var/www;
}
location /novnc {
index vnc.html;
alias /usr/share/novnc;
try_files $uri $uri/ /vnc.html;
if ($request_uri = "/novnc/") {
return 301 ?resize=scale&autoconnect=true&reconnect_delay=2000&reconnect=true&path=u-os-app-openwrt/websockify;
}
}
location /websockify {
proxy_http_version 1.1;
proxy_set_header Connection 'upgrade';
proxy_set_header Upgrade $http_upgrade;
proxy_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_pass http://127.0.0.1:5700/;
root /var/www/browser;
}
location /api/ {