Added distroless dockerfile. Updated docker compose
This commit is contained in:
@@ -22,5 +22,9 @@
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
**/storage
|
||||
**/compose.yml
|
||||
LICENSE
|
||||
README.md
|
||||
README.md
|
||||
|
||||
# For the people who run moonlight inside the main repo with the relative data path
|
||||
data
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -422,7 +422,7 @@ FodyWeavers.xsd
|
||||
|
||||
# Moonlight
|
||||
storage/
|
||||
/.idea/.idea.Moonlight/.idea
|
||||
**/.idea/**
|
||||
style.min.css
|
||||
core.min.css
|
||||
|
||||
|
||||
@@ -1,37 +1,53 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
# Prepare runtime docker image
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled AS base
|
||||
WORKDIR /app
|
||||
|
||||
# Prepare build image
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
|
||||
WORKDIR /src
|
||||
# Install nodejs and npm so we can build tailwind
|
||||
RUN apt-get update && apt-get install nodejs npm -y && apt-get clean
|
||||
|
||||
# Copy package.json file
|
||||
WORKDIR /src
|
||||
COPY ["Moonlight.Client/Styles/package.json", "Moonlight.Client/Styles/"]
|
||||
|
||||
# Install npm packages
|
||||
WORKDIR /src/Moonlight.Client/Styles/
|
||||
RUN npm i
|
||||
|
||||
# Copy project configuration files
|
||||
WORKDIR /src
|
||||
COPY ["Moonlight.ApiServer/Moonlight.ApiServer.csproj", "Moonlight.ApiServer/"]
|
||||
COPY ["Moonlight.Client/Moonlight.Client.csproj", "Moonlight.Client/"]
|
||||
COPY ["Moonlight.Shared/Moonlight.Shared.csproj", "Moonlight.Shared/"]
|
||||
|
||||
# Restore the nuget packages
|
||||
RUN dotnet restore "Moonlight.ApiServer/Moonlight.ApiServer.csproj"
|
||||
|
||||
# Copy all files
|
||||
COPY . .
|
||||
|
||||
WORKDIR "/src/Moonlight.ApiServer"
|
||||
# Build tailwindcss
|
||||
WORKDIR "/src/Moonlight.Client/Styles"
|
||||
RUN npx tailwindcss -i style.css -o ../wwwroot/css/core.min.css --minify
|
||||
|
||||
# Build ApiServer project
|
||||
WORKDIR "/src/Moonlight.ApiServer"
|
||||
RUN dotnet build "Moonlight.ApiServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# Publish application
|
||||
FROM build AS publish
|
||||
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
|
||||
RUN dotnet publish "Moonlight.ApiServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# Create final small image with the built content
|
||||
FROM base AS final
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
# Create storage directory a volume can bind to
|
||||
RUN mkdir -p /app/storage
|
||||
|
||||
ENTRYPOINT ["dotnet", "Moonlight.ApiServer.dll"]
|
||||
|
||||
38
compose.yml
38
compose.yml
@@ -1,5 +1,7 @@
|
||||
services:
|
||||
api-server:
|
||||
user: 0:0
|
||||
restart: always
|
||||
image: moonlightpanel/panel:custom
|
||||
build:
|
||||
context: .
|
||||
@@ -10,31 +12,35 @@ services:
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- MOONLIGHT_APP_DATABASE_HOST=db
|
||||
- MOONLIGHT_APP_DATABASE_PORT=3306
|
||||
- MOONLIGHT_APP_DATABASE_USERNAME=moonlight
|
||||
- MOONLIGHT_APP_DATABASE_PASSWORD=s3cret
|
||||
- MOONLIGHT_APP_DATABASE_DATABASE=moonlight
|
||||
- MOONLIGHT_APP_PUBLICURL=http://localhost:9069
|
||||
- MOONLIGHT_DATABASE_HOST=db
|
||||
- MOONLIGHT_DATABASE_PORT=5432
|
||||
- MOONLIGHT_DATABASE_USERNAME=moonlight
|
||||
- MOONLIGHT_DATABASE_PASSWORD=s3cret
|
||||
- MOONLIGHT_DATABASE_DATABASE=moonlight
|
||||
- MOONLIGHT_PUBLICURL=http://localhost:9069
|
||||
- MOONLIGHT_AUTHENTICATION_OAUTH2_ACCESSENDPOINT=http://localhost:8080 # Use this when moonlight is using local oauth2 and a different port as the public url
|
||||
volumes:
|
||||
- api_data:/app/storage
|
||||
- ./data/moonlight:/app/storage
|
||||
links:
|
||||
- db
|
||||
pull_policy: build
|
||||
|
||||
db:
|
||||
image: mysql:latest
|
||||
image: postgres:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "5555:5432"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=s3cret
|
||||
- MYSQL_PASSWORD=s3cret
|
||||
- MYSQL_DATABASE=moonlight
|
||||
- MYSQL_USER=moonlight
|
||||
- POSTGRES_USER=moonlight
|
||||
- POSTGRES_DB=moonlight
|
||||
- POSTGRES_PASSWORD=s3cret
|
||||
volumes:
|
||||
- db_data:/var/lib/mysql
|
||||
- ./data/database:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
|
||||
timeout: 1s
|
||||
retries: 10
|
||||
test: ["CMD-SHELL", "pg_isready"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
api_data:
|
||||
|
||||
Reference in New Issue
Block a user