OF-DL/Dockerfile

73 lines
2.1 KiB
Docker

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG VERSION
# Copy source code
COPY ["OF DL.sln", "/src/OF DL.sln"]
COPY ["OF DL.Cli", "/src/OF DL.Cli"]
COPY ["OF DL.Core", "/src/OF DL.Core"]
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
# Generate default config.conf files
RUN /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 && \
mv /src/updated_config.conf /src/config.conf
FROM mcr.microsoft.com/dotnet/runtime:10.0 AS final
# Install dependencies
RUN apt-get update \
&& apt-get install -y \
tini \
ffmpeg \
supervisor \
xvfb \
x11vnc \
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
# 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
# Create directories for configuration and downloaded files
RUN mkdir /data /config /config/logs /default-config
# Copy release
COPY --from=build /src/outcli /app/cli
COPY --from=build /src/outgui /app/gui
# Copy default configuration files
COPY --from=build /src/config.conf /default-config
COPY --from=build ["/src/OF DL.Cli/rules.json", "/default-config"]
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY docker/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
ENV DEBIAN_FRONTEND="noninteractive" \
DISPLAY=:0.0 \
DISPLAY_WIDTH=1366 \
DISPLAY_HEIGHT=768 \
OFDL_DOCKER=true \
PLAYWRIGHT_BROWSERS_PATH=/config/chromium
EXPOSE 8080
WORKDIR /config
ENTRYPOINT ["/usr/bin/tini", "--", "/app/entrypoint.sh"]
CMD []