Updated docker file for building using the new and simplified plugin system and the cleaner architecture. Added config files to specify which plugins to compile into

This commit is contained in:
2025-08-10 16:33:33 +02:00
parent 396bc007c5
commit 507b9bf5a7
7 changed files with 69 additions and 68 deletions

5
.dockerignore Normal file
View File

@@ -0,0 +1,5 @@
**/.git/**
**/.idea/**
**/.env
**/update.sh
**/compose.yml

View File

@@ -1,17 +1,6 @@
# This defines the way to get the moonlight docker image #
# By default moonlight will build the image locally. To pull # Application Settings
# it from the registry, set the value to 'pull' #
MOONLIGHT_BUILD=build
# This defines the image name to use when building/pulling
# the moonlight docker image
MOONLIGHT_IMAGE=moonlightpanel/panel:2.1
# Specify where the fetch the moonlight source code when building
# Uncomment this if you want to select a specific version of moonlight
# Or you want to deploy a custom fork
# MOONLIGHT_REPOSITORY=https://github.com/Moonlight-Panel/Moonlight
# MOONLIGHT_BRANCH=v2_ChangeArchitecture
# Set this to the url moonlight is accessible through the internet # Set this to the url moonlight is accessible through the internet
MOONLIGHT_URL=http://localhost:9069 MOONLIGHT_URL=http://localhost:9069
@@ -27,3 +16,26 @@ MOONLIGHT_DATA=./data
MOONLIGHT_DATABASE_USER=moonlight MOONLIGHT_DATABASE_USER=moonlight
MOONLIGHT_DATABASE_PASSWORD=s3cret MOONLIGHT_DATABASE_PASSWORD=s3cret
MOONLIGHT_DATABASE_NAME=moonlight MOONLIGHT_DATABASE_NAME=moonlight
#
# Build Settings
#
# This defines the way to get the moonlight docker image
# By default moonlight will build the image locally. To pull
# it from the registry, set the value to 'pull'
MOONLIGHT_BUILD=pull
# This defines the image name to use when building/pulling
# the moonlight docker image
MOONLIGHT_IMAGE=moonlightpanel/panel:2.1
# Moonlight uses githubs nuget registry for development packages
# Due to githubs restrictions you need an access token (classic) with the
# read.packages permission
MOONLIGHT_GITHUB_TOKEN=your-github-access-token-goes-here
MOONLIGHT_NUGET_SOURCE=https://nuget.pkg.github.com/Moonlight-Panel/index.json
# Specify where the fetch the moonlight source code when building
MOONLIGHT_REPOSITORY=https://github.com/Moonlight-Panel/Moonlight
MOONLIGHT_BRANCH=v2_ChangeArchitecture

View File

@@ -11,85 +11,56 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-moonlight
RUN apt-get update && apt-get install nodejs npm git -y && apt-get clean RUN apt-get update && apt-get install nodejs npm git -y && apt-get clean
# === Configuration options === # === Configuration options ===
# Usefull for custom forks # Usefull for custom forks
ARG BUILD_CONFIGURATION=Release ARG BUILD_CONFIGURATION=Release
ARG PACK_BUILD_CONFIGURATION=Debug
ARG MOONLIGHT_REPO=https://github.com/Moonlight-Panel/Moonlight ARG MOONLIGHT_REPO=https://github.com/Moonlight-Panel/Moonlight
ARG MOONLIGHT_BRANCH=v2_ChangeArchitecture ARG MOONLIGHT_BRANCH=v2_ChangeArchitecture
ARG MOONLIGHT_NUGET_SOURCE=https://nuget.pkg.github.com/Moonlight-Panel/index.json
ARG MOONLIGHT_GITHUB_TOKEN=unset
# === Small preparations === # === Small preparations ===
# Prepare directories # Prepare directories
RUN mkdir -p /src && \ RUN mkdir -p /src
mkdir -p /src/Moonlight && \
mkdir -p /src/Plugins && \ # Setup nuget package source
mkdir -p /src/pluginNuget && \ RUN dotnet nuget add source --username Build --password $MOONLIGHT_GITHUB_TOKEN --store-password-in-clear-text --name nuget-moonlight $MOONLIGHT_NUGET_SOURCE
mkdir -p /src/toolNuget && \
mkdir -p /src/moonlightNuget
WORKDIR /src WORKDIR /src
# === Building === # === Building ===
# Clone the main moonlight repo # Clone the main moonlight repo
RUN git clone --branch $MOONLIGHT_BRANCH $MOONLIGHT_REPO /src/Moonlight RUN git clone --branch $MOONLIGHT_BRANCH $MOONLIGHT_REPO /src/.
# Install npm packages # Install npm packages
WORKDIR /src/Moonlight/Moonlight.Client/Styles WORKDIR /src/Moonlight.Client.Runtime/Styles
RUN npm i RUN npm i
WORKDIR /src WORKDIR /src
# Install the scripts project as a dotnet tool and set the env for the dotnet cli to find # Copying plugin references to src
RUN dotnet pack --output /src/toolNuget Moonlight/Resources/Scripts/Scripts.csproj && \ COPY Plugins.ApiServer.props /src/Moonlight.ApiServer.Runtime/Plugins.props
dotnet tool install --add-source /src/toolNuget --global dotnet-moonlight COPY Plugins.Frontend.props /src/Moonlight.Client.Runtime/Plugins.props
ENV PATH="$PATH:~/.dotnet/tools" # Build solution so every build task ran. Especially for tailwind class names etc
RUN dotnet build -c $BUILD_CONFIGURATION
FROM build-moonlight AS build-plugins
# Build moonlight as nuget packages
RUN dotnet moonlight pack /src/Moonlight /src/moonlightNuget --build-configuration $PACK_BUILD_CONFIGURATION
# Make the moonlight nuget accessible for the compilation
RUN dotnet nuget add source /src/moonlightNuget -n moonlightNuget
# Copy plugin links
COPY plugins.txt /src/plugins.txt
# Clone plugins
RUN grep -v '^#' plugins.txt | \
while read -r repo; \
do \
git clone "$repo" /src/Plugins/$(basename "$repo" .git); \
done
# Build plugin nuget packages
RUN dotnet moonlight pack /src/Plugins /src/pluginNuget --build-configuration $PACK_BUILD_CONFIGURATION
# Make the plugin nuget accessible for the compilation and remove the moonlight nuget source
RUN dotnet nuget remove source moonlightNuget
RUN dotnet nuget add source /src/pluginNuget -n pluginNuget
# Prepare moonlight for compilation
RUN dotnet moonlight prebuild /src/Moonlight /src/pluginNuget
FROM build-plugins AS build-final
# Build tailwind # Build tailwind
WORKDIR /src/Moonlight/Moonlight.Client/Styles WORKDIR /src/Moonlight.Client.Runtime/Styles
RUN npm run tailwind-build RUN npm run tailwind-build
# Build moonlight # Build moonlight with the built tailwind assets
WORKDIR "/src/Moonlight/Moonlight.ApiServer" WORKDIR "/src/Moonlight.ApiServer.Runtime"
RUN dotnet build "Moonlight.ApiServer.csproj" -c $BUILD_CONFIGURATION -o /app/build/ RUN dotnet build "Moonlight.ApiServer.Runtime.csproj" -c $BUILD_CONFIGURATION -o /app/build/
# Publish application # Publish application
FROM build-final AS publish FROM build-moonlight AS publish
ARG BUILD_CONFIGURATION=Release ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Moonlight.ApiServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false RUN dotnet publish "Moonlight.ApiServer.Runtime.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Create final minimal image # Create final minimal image
FROM base AS final FROM base AS final
@@ -97,4 +68,4 @@ FROM base AS final
WORKDIR /app WORKDIR /app
COPY --from=publish /app/publish . COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Moonlight.ApiServer.dll"] ENTRYPOINT ["dotnet", "Moonlight.ApiServer.Runtime.dll"]

6
Plugins.ApiServer.props Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<ItemGroup>
<!-- Put your plugin references here -->
<!-- E.g. <PackageReference Include="MoonlightServers.ApiServer" Version="2.1.0" /> -->
</ItemGroup>
</Project>

6
Plugins.Frontend.props Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<ItemGroup>
<!-- Put your plugin references here -->
<!-- E.g. <PackageReference Include="MoonlightServers.Frontend" Version="2.1.0" /> -->
</ItemGroup>
</Project>

View File

@@ -7,8 +7,10 @@ services:
context: . context: .
dockerfile: ./Dockerfile dockerfile: ./Dockerfile
args: args:
- MOONLIGHT_REPO=${MOONLIGHT_REPOSITORY:-https://github.com/Moonlight-Panel/Moonlight} - MOONLIGHT_REPO=${MOONLIGHT_REPOSITORY}
- MOONLIGHT_BRANCH=${MOONLIGHT_BRANCH:-v2_ChangeArchitecture} - MOONLIGHT_BRANCH=${MOONLIGHT_BRANCH}
- MOONLIGHT_GITHUB_TOKEN=${MOONLIGHT_GITHUB_TOKEN}
- MOONLIGHT_NUGET_SOURCE=${MOONLIGHT_NUGET_SOURCE}
ports: ports:
- "${MOONLIGHT_PORT}:8080" - "${MOONLIGHT_PORT}:8080"
depends_on: depends_on:

View File

@@ -1 +0,0 @@
https://github.com/Moonlight-Panel/Servers