From 35ec1f2bfd82b49173a4d3857edebece4c5a89e7 Mon Sep 17 00:00:00 2001 From: whimsical-c4lic0 Date: Sun, 1 Mar 2026 02:35:36 -0600 Subject: [PATCH] Simplify Dockerfile to reduce image size --- .gitea/workflows/publish-release.yml | 9 ++--- Dockerfile | 33 ++++++++--------- OF DL.Cli/OF DL.Cli.csproj | 2 + OF DL.Gui/OF DL.Gui.csproj | 2 + docker/entrypoint.sh | 55 ++++++++++++++-------------- 5 files changed, 49 insertions(+), 52 deletions(-) diff --git a/.gitea/workflows/publish-release.yml b/.gitea/workflows/publish-release.yml index 5f83003..8986c9c 100644 --- a/.gitea/workflows/publish-release.yml +++ b/.gitea/workflows/publish-release.yml @@ -31,18 +31,15 @@ jobs: run: | dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:Version=${{ steps.version.outputs.version }} \ -p:PackageVersion=${{ steps.version.outputs.version }} \ - -p:WarningLevel=0 -c Release -r win-x86 \ - --self-contained true -p:PublishSingleFile=true -o outwin-cli + -p:WarningLevel=0 -c Release -r win-x86 -o outwin-cli dotnet publish "OF DL.Gui/OF DL.Gui.csproj" -p:Version=${{ steps.version.outputs.version }} \ -p:PackageVersion=${{ steps.version.outputs.version }} \ - -p:WarningLevel=0 -c Release -r win-x86 \ - --self-contained true -p:PublishSingleFile=true -o outwin-gui + -p:WarningLevel=0 -c Release -r win-x86 -o outwin-gui dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:Version=${{ steps.version.outputs.version }} \ -p:PackageVersion=${{ steps.version.outputs.version }} \ - -p:WarningLevel=0 -c Release -r linux-x64 \ - --self-contained true -p:PublishSingleFile=true -o outlin-cli + -p:WarningLevel=0 -c Release -r linux-x64 -o outlin-cli - name: Copy and patch extra files run: | diff --git a/Dockerfile b/Dockerfile index b7a03ff..10f4193 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,17 +11,16 @@ COPY ["OF DL.Gui", "/src/OF DL.Gui"] WORKDIR "/src" # Build release -RUN dotnet publish "OF DL.Gui/OF DL.Gui.csproj" -p:WarningLevel=0 -p:Version=$VERSION -c Release -o outgui -RUN dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:WarningLevel=0 -p:Version=$VERSION -c Release -o outcli - +RUN dotnet publish "OF DL.Gui/OF DL.Gui.csproj" -p:WarningLevel=0 -p:Version=$VERSION -c Release -o outgui \ + && dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:WarningLevel=0 -p:Version=$VERSION -c Release -o outcli \ # Generate default config.conf files -RUN /src/outcli/OF\ DL.Cli --non-interactive || true && \ + && /src/outcli/OF\ DL.Cli --non-interactive || true && \ # Set download path in default config.conf to /data - sed -e 's/DownloadPath = ""/DownloadPath = "\/data"/' /src/config.conf > /src/updated_config.conf && \ + sed -e 's/DownloadPath = ""/DownloadPath = "\/OF-DL\/data"/' /src/config.conf > /src/updated_config.conf && \ mv /src/updated_config.conf /src/config.conf -FROM mcr.microsoft.com/dotnet/runtime:10.0 AS final +FROM ubuntu:noble AS final # Install dependencies RUN apt-get update \ @@ -34,22 +33,20 @@ RUN apt-get update \ novnc \ npm \ openbox \ - && rm -rf /var/lib/apt/lists/* - -RUN npx playwright install-deps - -RUN apt-get remove --purge -y npm \ - && apt-get autoremove -y - + && npx playwright install-deps \ + && apt-get remove --purge -y npm \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* \ # Redirect webroot to vnc.html instead of displaying directory listing -RUN echo "" > /usr/share/novnc/index.html - + && echo "" > /usr/share/novnc/index.html \ # Create directories for configuration and downloaded files -RUN mkdir /data /config /config/logs /default-config + && mkdir -p /data /config /config/logs /default-config # Copy release -COPY --from=build /src/outcli /app/cli -COPY --from=build /src/outgui /app/gui +COPY --from=build /src/outgui /app +ARG cli_src="/src/outcli/OF DL.Cli" +ARG cli_target="/app/OF DL.Cli" +COPY --from=build ${cli_src} ${cli_target} # Copy default configuration files COPY --from=build /src/config.conf /default-config diff --git a/OF DL.Cli/OF DL.Cli.csproj b/OF DL.Cli/OF DL.Cli.csproj index 91a1154..3833cff 100644 --- a/OF DL.Cli/OF DL.Cli.csproj +++ b/OF DL.Cli/OF DL.Cli.csproj @@ -7,6 +7,8 @@ enable enable Icon\download.ico + true + true diff --git a/OF DL.Gui/OF DL.Gui.csproj b/OF DL.Gui/OF DL.Gui.csproj index 0484a9b..10f48ea 100644 --- a/OF DL.Gui/OF DL.Gui.csproj +++ b/OF DL.Gui/OF DL.Gui.csproj @@ -8,6 +8,8 @@ enable true Assets\icon.ico + true + true diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index c0f4af3..cd2b52b 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -12,6 +12,31 @@ if [ ! -f /config/rules.json ]; then cp /default-config/rules.json /config/rules.json fi +{ + supervisord -c /etc/supervisor/conf.d/supervisord.conf & +} &> /dev/null + +# Wait for the 4 supervisor programs to start: X11 (Xvfb), openbox, X11vnc, and noVNC +NUM_RUNNING_SERVICES=$(supervisorctl -c /etc/supervisor/conf.d/supervisord.conf status | grep RUNNING | wc -l) +while [ $NUM_RUNNING_SERVICES != "4" ]; do + sleep 1 + NUM_RUNNING_SERVICES=$(supervisorctl -c /etc/supervisor/conf.d/supervisord.conf status | grep RUNNING | wc -l) +done + +# Wait for X server to be ready to accept connections +echo "Waiting for X server to be ready..." +timeout=30 +elapsed=0 +until xdpyinfo -display "$DISPLAY" >/dev/null 2>&1; do + if [ $elapsed -ge $timeout ]; then + echo "Timeout waiting for X server" + exit 1 + fi + sleep 1 + elapsed=$((elapsed + 1)) +done +echo "X server is ready" + # Check if --cli flag was passed if [[ " $@ " =~ " --cli " ]]; then # CLI mode - no need for X server @@ -24,33 +49,7 @@ if [[ " $@ " =~ " --cli " ]]; then fi done - /app/cli/OF\ DL.Cli "${filtered_args[@]}" + /app/OF\ DL.Cli "${filtered_args[@]}" else - # GUI mode - start X server and window manager - { - supervisord -c /etc/supervisor/conf.d/supervisord.conf & - } &> /dev/null - - # Wait for the 4 supervisor programs to start: X11 (Xvfb), openbox, X11vnc, and noVNC - NUM_RUNNING_SERVICES=$(supervisorctl -c /etc/supervisor/conf.d/supervisord.conf status | grep RUNNING | wc -l) - while [ $NUM_RUNNING_SERVICES != "4" ]; do - sleep 1 - NUM_RUNNING_SERVICES=$(supervisorctl -c /etc/supervisor/conf.d/supervisord.conf status | grep RUNNING | wc -l) - done - - # Wait for X server to be ready to accept connections - echo "Waiting for X server to be ready..." - timeout=30 - elapsed=0 - until xdpyinfo -display "$DISPLAY" >/dev/null 2>&1; do - if [ $elapsed -ge $timeout ]; then - echo "Timeout waiting for X server" - exit 1 - fi - sleep 1 - elapsed=$((elapsed + 1)) - done - echo "X server is ready" - - /app/gui/OF\ DL.Gui "$@" + /app/OF\ DL.Gui "$@" fi