Added distroless dockerfile. Updated docker compose
This commit is contained in:
@@ -22,5 +22,9 @@
|
|||||||
**/secrets.dev.yaml
|
**/secrets.dev.yaml
|
||||||
**/values.dev.yaml
|
**/values.dev.yaml
|
||||||
**/storage
|
**/storage
|
||||||
|
**/compose.yml
|
||||||
LICENSE
|
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
|
# Moonlight
|
||||||
storage/
|
storage/
|
||||||
/.idea/.idea.Moonlight/.idea
|
**/.idea/**
|
||||||
style.min.css
|
style.min.css
|
||||||
core.min.css
|
core.min.css
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,53 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
# Prepare runtime docker image
|
||||||
USER $APP_UID
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Prepare build image
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
|
||||||
ARG BUILD_CONFIGURATION=Release
|
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.ApiServer/Moonlight.ApiServer.csproj", "Moonlight.ApiServer/"]
|
||||||
COPY ["Moonlight.Client/Moonlight.Client.csproj", "Moonlight.Client/"]
|
COPY ["Moonlight.Client/Moonlight.Client.csproj", "Moonlight.Client/"]
|
||||||
COPY ["Moonlight.Shared/Moonlight.Shared.csproj", "Moonlight.Shared/"]
|
COPY ["Moonlight.Shared/Moonlight.Shared.csproj", "Moonlight.Shared/"]
|
||||||
|
|
||||||
|
# Restore the nuget packages
|
||||||
RUN dotnet restore "Moonlight.ApiServer/Moonlight.ApiServer.csproj"
|
RUN dotnet restore "Moonlight.ApiServer/Moonlight.ApiServer.csproj"
|
||||||
|
|
||||||
|
# Copy all files
|
||||||
COPY . .
|
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
|
RUN dotnet build "Moonlight.ApiServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
# Publish application
|
||||||
FROM build AS publish
|
FROM build 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.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
# Create final small image with the built content
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
COPY --from=publish /app/publish .
|
||||||
|
|
||||||
# Create storage directory a volume can bind to
|
|
||||||
RUN mkdir -p /app/storage
|
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "Moonlight.ApiServer.dll"]
|
ENTRYPOINT ["dotnet", "Moonlight.ApiServer.dll"]
|
||||||
|
|||||||
38
compose.yml
38
compose.yml
@@ -1,5 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
api-server:
|
api-server:
|
||||||
|
user: 0:0
|
||||||
|
restart: always
|
||||||
image: moonlightpanel/panel:custom
|
image: moonlightpanel/panel:custom
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
@@ -10,31 +12,35 @@ services:
|
|||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
- MOONLIGHT_APP_DATABASE_HOST=db
|
- MOONLIGHT_DATABASE_HOST=db
|
||||||
- MOONLIGHT_APP_DATABASE_PORT=3306
|
- MOONLIGHT_DATABASE_PORT=5432
|
||||||
- MOONLIGHT_APP_DATABASE_USERNAME=moonlight
|
- MOONLIGHT_DATABASE_USERNAME=moonlight
|
||||||
- MOONLIGHT_APP_DATABASE_PASSWORD=s3cret
|
- MOONLIGHT_DATABASE_PASSWORD=s3cret
|
||||||
- MOONLIGHT_APP_DATABASE_DATABASE=moonlight
|
- MOONLIGHT_DATABASE_DATABASE=moonlight
|
||||||
- MOONLIGHT_APP_PUBLICURL=http://localhost:9069
|
- 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:
|
volumes:
|
||||||
- api_data:/app/storage
|
- ./data/moonlight:/app/storage
|
||||||
links:
|
links:
|
||||||
- db
|
- db
|
||||||
pull_policy: build
|
pull_policy: build
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: mysql:latest
|
image: postgres:latest
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "5555:5432"
|
||||||
environment:
|
environment:
|
||||||
- MYSQL_ROOT_PASSWORD=s3cret
|
- POSTGRES_USER=moonlight
|
||||||
- MYSQL_PASSWORD=s3cret
|
- POSTGRES_DB=moonlight
|
||||||
- MYSQL_DATABASE=moonlight
|
- POSTGRES_PASSWORD=s3cret
|
||||||
- MYSQL_USER=moonlight
|
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/mysql
|
- ./data/database:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
|
test: ["CMD-SHELL", "pg_isready"]
|
||||||
timeout: 1s
|
interval: 10s
|
||||||
retries: 10
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
api_data:
|
api_data:
|
||||||
|
|||||||
Reference in New Issue
Block a user