forked from sim0n00ps/OF-DL
Simplify Dockerfile to reduce image size
This commit is contained in:
parent
26b98b8d31
commit
35ec1f2bfd
@ -31,18 +31,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:Version=${{ steps.version.outputs.version }} \
|
dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:Version=${{ steps.version.outputs.version }} \
|
||||||
-p:PackageVersion=${{ steps.version.outputs.version }} \
|
-p:PackageVersion=${{ steps.version.outputs.version }} \
|
||||||
-p:WarningLevel=0 -c Release -r win-x86 \
|
-p:WarningLevel=0 -c Release -r win-x86 -o outwin-cli
|
||||||
--self-contained true -p:PublishSingleFile=true -o outwin-cli
|
|
||||||
|
|
||||||
dotnet publish "OF DL.Gui/OF DL.Gui.csproj" -p:Version=${{ steps.version.outputs.version }} \
|
dotnet publish "OF DL.Gui/OF DL.Gui.csproj" -p:Version=${{ steps.version.outputs.version }} \
|
||||||
-p:PackageVersion=${{ steps.version.outputs.version }} \
|
-p:PackageVersion=${{ steps.version.outputs.version }} \
|
||||||
-p:WarningLevel=0 -c Release -r win-x86 \
|
-p:WarningLevel=0 -c Release -r win-x86 -o outwin-gui
|
||||||
--self-contained true -p:PublishSingleFile=true -o outwin-gui
|
|
||||||
|
|
||||||
dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:Version=${{ steps.version.outputs.version }} \
|
dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:Version=${{ steps.version.outputs.version }} \
|
||||||
-p:PackageVersion=${{ steps.version.outputs.version }} \
|
-p:PackageVersion=${{ steps.version.outputs.version }} \
|
||||||
-p:WarningLevel=0 -c Release -r linux-x64 \
|
-p:WarningLevel=0 -c Release -r linux-x64 -o outlin-cli
|
||||||
--self-contained true -p:PublishSingleFile=true -o outlin-cli
|
|
||||||
|
|
||||||
- name: Copy and patch extra files
|
- name: Copy and patch extra files
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
33
Dockerfile
33
Dockerfile
@ -11,17 +11,16 @@ COPY ["OF DL.Gui", "/src/OF DL.Gui"]
|
|||||||
WORKDIR "/src"
|
WORKDIR "/src"
|
||||||
|
|
||||||
# Build release
|
# 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.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
|
&& dotnet publish "OF DL.Cli/OF DL.Cli.csproj" -p:WarningLevel=0 -p:Version=$VERSION -c Release -o outcli \
|
||||||
|
|
||||||
# Generate default config.conf files
|
# 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
|
# 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
|
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
|
# Install dependencies
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
@ -34,22 +33,20 @@ RUN apt-get update \
|
|||||||
novnc \
|
novnc \
|
||||||
npm \
|
npm \
|
||||||
openbox \
|
openbox \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& npx playwright install-deps \
|
||||||
|
&& apt-get remove --purge -y npm \
|
||||||
RUN npx playwright install-deps
|
&& apt-get autoremove -y \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
RUN apt-get remove --purge -y npm \
|
|
||||||
&& apt-get autoremove -y
|
|
||||||
|
|
||||||
# Redirect webroot to vnc.html instead of displaying directory listing
|
# 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
|
# 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 release
|
||||||
COPY --from=build /src/outcli /app/cli
|
COPY --from=build /src/outgui /app
|
||||||
COPY --from=build /src/outgui /app/gui
|
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 default configuration files
|
||||||
COPY --from=build /src/config.conf /default-config
|
COPY --from=build /src/config.conf /default-config
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ApplicationIcon>Icon\download.ico</ApplicationIcon>
|
<ApplicationIcon>Icon\download.ico</ApplicationIcon>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -12,6 +12,31 @@ if [ ! -f /config/rules.json ]; then
|
|||||||
cp /default-config/rules.json /config/rules.json
|
cp /default-config/rules.json /config/rules.json
|
||||||
fi
|
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
|
# Check if --cli flag was passed
|
||||||
if [[ " $@ " =~ " --cli " ]]; then
|
if [[ " $@ " =~ " --cli " ]]; then
|
||||||
# CLI mode - no need for X server
|
# CLI mode - no need for X server
|
||||||
@ -24,33 +49,7 @@ if [[ " $@ " =~ " --cli " ]]; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
/app/cli/OF\ DL.Cli "${filtered_args[@]}"
|
/app/OF\ DL.Cli "${filtered_args[@]}"
|
||||||
else
|
else
|
||||||
# GUI mode - start X server and window manager
|
/app/OF\ DL.Gui "$@"
|
||||||
{
|
|
||||||
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 "$@"
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user