Simplify Dockerfile to reduce image size

This commit is contained in:
whimsical-c4lic0 2026-03-01 02:35:36 -06:00
parent 26b98b8d31
commit 35ec1f2bfd
5 changed files with 49 additions and 52 deletions

View File

@ -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: |

View File

@ -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 "<!DOCTYPE html><html><head><meta http-equiv=\"Refresh\" content=\"0; url='vnc.html'\" /></head><body></body></html>" > /usr/share/novnc/index.html
&& echo "<!DOCTYPE html><html><head><meta http-equiv=\"Refresh\" content=\"0; url='vnc.html'\" /></head><body></body></html>" > /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

View File

@ -7,6 +7,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationIcon>Icon\download.ico</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
</PropertyGroup>
<ItemGroup>

View File

@ -8,6 +8,8 @@
<Nullable>enable</Nullable>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
</PropertyGroup>
<ItemGroup>

View File

@ -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