-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (48 loc) · 2.07 KB
/
Dockerfile
File metadata and controls
71 lines (48 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Prepare runtime docker image
FROM cgr.dev/chainguard/aspnet-runtime:latest AS base
# Prepare build image
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-moonlight
# === Heavy download/install tasks ===
# should be put here for caching reasons
# Install nodejs and npm so we can build tailwind
RUN apt-get update && apt-get install nodejs npm git -y && apt-get clean
# === Configuration options ===
# Usefull for custom forks
ARG BUILD_CONFIGURATION=Release
ARG MOONLIGHT_REPO=https://github.com/Moonlight-Panel/Moonlight
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 ===
# Prepare directories
RUN mkdir -p /src
# Setup nuget package source
RUN dotnet nuget add source --username Build --password $MOONLIGHT_GITHUB_TOKEN --store-password-in-clear-text --name nuget-moonlight $MOONLIGHT_NUGET_SOURCE
WORKDIR /src
# === Building ===
# Clone the main moonlight repo
RUN git clone --branch $MOONLIGHT_BRANCH $MOONLIGHT_REPO /src/.
# Install npm packages
WORKDIR /src/Moonlight.Client.Runtime/Styles
RUN npm i
WORKDIR /src
# Copying plugin references to src
COPY Plugins.ApiServer.props /src/Moonlight.ApiServer.Runtime/Plugins.props
COPY Plugins.Frontend.props /src/Moonlight.Client.Runtime/Plugins.props
# Build solution so every build task ran. Especially for tailwind class names etc
RUN dotnet build -c $BUILD_CONFIGURATION
# Build tailwind
WORKDIR /src/Moonlight.Client.Runtime/Styles
RUN npm run tailwind-build
# Build moonlight with the built tailwind assets
WORKDIR "/src/Moonlight.ApiServer.Runtime"
RUN dotnet build "Moonlight.ApiServer.Runtime.csproj" -c $BUILD_CONFIGURATION -o /app/build/
# Publish application
FROM build-moonlight AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Moonlight.ApiServer.Runtime.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Create final minimal image
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Moonlight.ApiServer.Runtime.dll"]