From a4c59b23dbc9df30af87abefe6d01382a83aa1cd Mon Sep 17 00:00:00 2001 From: ChiaraBm Date: Mon, 9 Feb 2026 10:53:01 +0100 Subject: [PATCH] Added container helper to compose. Updated dockerfile to use bun. Smaller adjustments --- .env.example | 4 +++- Dockerfile | 10 +++++---- compose.yml | 58 ++++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.env.example b/.env.example index 6b8c763..f88bd71 100644 --- a/.env.example +++ b/.env.example @@ -7,4 +7,6 @@ OIDC_AUTHORITY=http://localhost:8092 OIDC_AUTHORITY=http://localhost:8092 OIDC_CLIENT_ID=client_id OIDC_CLIENT_SECRET=client_secret -OIDC_REQUIRE_HTTPS_METADATA=false \ No newline at end of file +OIDC_REQUIRE_HTTPS_METADATA=false +DOCKER_GID=989 +DATA_PATH=./data \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 92b1362..c34594e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,9 @@ FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build # Install required packages -RUN apt-get update; apt-get install nodejs npm -y; apt-get clean +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 @@ -24,13 +26,13 @@ RUN git clone -b $GIT_BRANCH --single-branch $GIT_REPOSITORY . # Save hash of commit WORKDIR /src -RUN mkdir -p "/output" && git log -1 --pretty=format:"%H" > /output/version +RUN mkdir -p "/output" && echo -n $GIT_BRANCH > /output/version # TODO: Implement plugin loading here # Install npm packages WORKDIR /src/Hosts/Moonlight.Frontend.Host/Styles -RUN npm install +RUN bun install # Install nuget packages WORKDIR /src @@ -43,7 +45,7 @@ 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 npm run build +RUN bun run build # Build projects WORKDIR "/src/Hosts/Moonlight.Api.Host" diff --git a/compose.yml b/compose.yml index 531f104..4fd6c46 100644 --- a/compose.yml +++ b/compose.yml @@ -11,6 +11,7 @@ args: HTTP_PROXY: ${HTTP_PROXY} HTTPS_PROXY: ${HTTPS_PROXY} + GIT_BRANCH: ${GIT_BRANCH:-v2.1} # Requirements depends_on: @@ -40,31 +41,66 @@ - "Moonlight__OIDC__Scopes__0=openid" - "Moonlight__OIDC__Scopes__1=identify" - "Moonlight__OIDC__Scopes__2=email" + + # Container Helper + - "Moonlight__ContainerHelper__IsEnabled=true" + - "Moonlight__ContainerHelper__Url=http://helper:8080" # Logging - "Logging__LogLevel__Default=Information" - "Logging__LogLevel__Microsoft.AspNetCore=Warning" + - "Logging__LogLevel__System.Net.Http.HttpClient=Warning" + + # HTTP Proxy + - "HTTP_PROXY=${HTTP_PROXY}" + - "HTTPS_PROXY=${HTTPS_PROXY}" + - "NO_PROXY=database,helper" database: image: postgres:18.1 + + networks: + - moonlight + + environment: + - "POSTGRES_USER=${DATABASE_USERNAME}" + - "POSTGRES_PASSWORD=${DATABASE_PASSWORD}" + - "POSTGRES_DB=${DATABASE_DATABASE}" + + volumes: + - ${DATA_PATH}/database:/var/lib/postgresql + + healthcheck: + test: [ "CMD", "pg_isready", "-q", "-d", "${DATABASE_DATABASE}", "-U", "${DATABASE_USERNAME}" ] + interval: 10s + timeout: 5s + retries: 5 + + helper: + image: git.battlestati.one/moonlight-panel/container_helper + + group_add: + - "${DOCKER_GID}" networks: - moonlight environment: - - "POSTGRES_USER=${DATABASE_USERNAME}" - - "POSTGRES_PASSWORD=${DATABASE_PASSWORD}" - - "POSTGRES_DB=${DATABASE_DATABASE}" - - "PGDATA=/pgdata" + # Logging + - "Logging__LogLevel__Default=Information" + - "Logging__LogLevel__Microsoft.AspNetCore=Warning" + + # Compose + - "ContainerHelper__Compose__Directory=${PWD}" + - "ContainerHelper__Compose__Binary=docker-compose" + + # HTTP Proxy + - "HTTP_PROXY=${HTTP_PROXY}" + - "HTTPS_PROXY=${HTTPS_PROXY}" volumes: - - ./data/database:/var/lib/postgresql/data - - healthcheck: - test: [ "CMD", "pg_isready", "-q", "-d", $DATABASE_DATABASE, "-U", $DATABASE_USERNAME] - interval: 10s - timeout: 5s - retries: 5 + - "${PWD}:${PWD}" + - "/var/run/docker.sock:/var/run/docker.sock" networks: moonlight: \ No newline at end of file