79 lines
2.6 KiB
Docker
79 lines
2.6 KiB
Docker
#
|
|
# Prepare build image for building moonlight
|
|
#
|
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
|
|
|
# Install required packages
|
|
RUN apt-get update; apt-get install unzip -y; apt-get clean
|
|
RUN curl -fsSL https://bun.sh/install | bash
|
|
ENV PATH="/root/.bun/bin:${PATH}"
|
|
|
|
#
|
|
# Build & publish projects
|
|
#
|
|
FROM build AS publish
|
|
|
|
ARG BUILD_CONFIGURATION=Release
|
|
ARG GIT_REPOSITORY=https://git.battlestati.one/Moonlight-Panel/Moonlight
|
|
ARG GIT_BRANCH=v2.1
|
|
|
|
# Setup nuget package source
|
|
COPY ["nuget.config", "/context/nuget.config"]
|
|
|
|
# Clone source code
|
|
WORKDIR /src
|
|
RUN git clone -b $GIT_BRANCH --single-branch $GIT_REPOSITORY .
|
|
|
|
# Save hash of commit
|
|
WORKDIR /src
|
|
RUN mkdir -p "/output" && echo -n $GIT_BRANCH > /output/version
|
|
|
|
# Copy over plugin configuration
|
|
COPY Api.props /src/Hosts/Moonlight.Api.Host/
|
|
COPY Frontend.props /src/Hosts/Moonlight.Frontend.Host/
|
|
|
|
# Install npm packages
|
|
WORKDIR /src/Hosts/Moonlight.Frontend.Host/Styles
|
|
RUN bun install
|
|
|
|
# Install nuget packages
|
|
WORKDIR /src
|
|
RUN dotnet restore --configfile /context/nuget.config "Hosts/Moonlight.Api.Host/Moonlight.Api.Host.csproj"
|
|
RUN dotnet restore --configfile /context/nuget.config "Hosts/Moonlight.Frontend.Host/Moonlight.Frontend.Host.csproj"
|
|
|
|
# Build styles
|
|
# - We need to build the frontend before the tailwind build, so the class lists get generated
|
|
WORKDIR "/src/Hosts/Moonlight.Frontend.Host"
|
|
RUN dotnet build --no-restore "./Moonlight.Frontend.Host.csproj" -c $BUILD_CONFIGURATION -o /output/build-frontend
|
|
|
|
WORKDIR "/src/Hosts/Moonlight.Frontend.Host/Styles"
|
|
RUN bun run build
|
|
|
|
# Build projects
|
|
WORKDIR "/src/Hosts/Moonlight.Api.Host"
|
|
RUN dotnet build --no-restore "./Moonlight.Api.Host.csproj" -c $BUILD_CONFIGURATION -o /output/build-api
|
|
|
|
WORKDIR "/src/Hosts/Moonlight.Frontend.Host"
|
|
RUN dotnet build --no-restore "./Moonlight.Frontend.Host.csproj" -c $BUILD_CONFIGURATION -o /output/build-frontend
|
|
|
|
# Publish projects
|
|
WORKDIR "/src/Hosts/Moonlight.Api.Host"
|
|
RUN dotnet publish --no-restore "./Moonlight.Api.Host.csproj" -c $BUILD_CONFIGURATION -o /output/publish-api /p:UseAppHost=false
|
|
|
|
WORKDIR "/src/Hosts/Moonlight.Frontend.Host"
|
|
RUN dotnet publish --no-restore "./Moonlight.Frontend.Host.csproj" -c $BUILD_CONFIGURATION -o /output/publish-frontend /p:UseAppHost=false
|
|
|
|
#
|
|
# Construct final docker image
|
|
#
|
|
FROM git.battlestati.one/moonlight-panel/app_base:moonlight AS final
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=publish /output/publish-api .
|
|
COPY --from=publish /output/publish-frontend/wwwroot ./wwwroot
|
|
COPY --from=publish /output/version .
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 CMD ["/usr/bin/curl", "-sf", "-o", "/dev/null", "http://localhost:8080/"]
|
|
|
|
ENTRYPOINT ["dotnet", "Moonlight.Api.Host.dll"] |