From 7fa65a9ee3a640e3851488244ebcbecb1ad0f9f3 Mon Sep 17 00:00:00 2001 From: Daryn Date: Wed, 29 Apr 2026 10:01:33 +0100 Subject: [PATCH] Add docker and build scripts --- .gitignore | 1 + Dockerfile | 21 +++++++++++++++ docker-build.example.ps1 | 58 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 14 ++++++++++ 4 files changed, 94 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-build.example.ps1 create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 4a7f73a..d3041fb 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ logs .DS_Store .fleet .idea +docker-build.ps1 # Local env files .env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1a61d0f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM node:20-alpine + +# Enable corepack for pnpm +#RUN corepack enable && corepack prepare pnpm@latest --activate + +WORKDIR /app + +# Copy package files +COPY package.json pnpm-lock.yaml ./ + +# Install dependencies +RUN pnpm install + +# Copy application code +COPY . . + +# Expose Nuxt default port +EXPOSE 3000 + +# Ensure the application rebuilds each time the container is launched +CMD pnpm run build && node .output/server/index.mjs diff --git a/docker-build.example.ps1 b/docker-build.example.ps1 new file mode 100644 index 0000000..5bc049f --- /dev/null +++ b/docker-build.example.ps1 @@ -0,0 +1,58 @@ +# Docker Build and Push Script +# Builds the dashlio image and pushes it to private registry + +param( + [string]$ImageName = "", + [string]$RegistryUrl = "", + [string]$Tag = "", + [string]$Dockerfile = "Dockerfile", + [string]$BuildContext = "." +) + +# Colors for output +$ErrorColor = "Red" +$SuccessColor = "Green" +$InfoColor = "Cyan" + +Write-Host "Docker Build and Push Script" -ForegroundColor $InfoColor +Write-Host "======================================" -ForegroundColor $InfoColor + +# Variables +$FullImageName = "$RegistryUrl/$ImageName" +$TaggedImage = "$FullImageName" + ":$Tag" + +Write-Host "Registry: $RegistryUrl" -ForegroundColor $InfoColor +Write-Host "Image Name: $ImageName" -ForegroundColor $InfoColor +Write-Host "Tag: $Tag" -ForegroundColor $InfoColor +Write-Host "Full Image: $TaggedImage" -ForegroundColor $InfoColor +Write-Host "Dockerfile: $Dockerfile" -ForegroundColor $InfoColor +Write-Host "Context: $BuildContext" -ForegroundColor $InfoColor +Write-Host "======================================" -ForegroundColor $InfoColor +Write-Host "" + +# Step 1: Build the image +Write-Host "Step 1: Building Docker image..." -ForegroundColor $InfoColor +docker build -f $Dockerfile -t $TaggedImage $BuildContext + +if ($LASTEXITCODE -ne 0) { + Write-Host "ERROR: Docker build failed!" -ForegroundColor $ErrorColor + exit 1 +} + +Write-Host "Build successful!" -ForegroundColor $SuccessColor +Write-Host "" + +# Step 2: Push the image +Write-Host "Step 2: Pushing image to registry..." -ForegroundColor $InfoColor +docker push $TaggedImage + +if ($LASTEXITCODE -ne 0) { + Write-Host "ERROR: Docker push failed!" -ForegroundColor $ErrorColor + exit 1 +} + +Write-Host "Push successful!" -ForegroundColor $SuccessColor +Write-Host "" +Write-Host "======================================" -ForegroundColor $SuccessColor +Write-Host "Image $TaggedImage is ready!" -ForegroundColor $SuccessColor +Write-Host "======================================" -ForegroundColor $SuccessColor \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5b2b894 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + dashlio: + build: . + container_name: dashlio + ports: + - "3000:3000" + volumes: + # Mount dashboard.yml so user can edit it outside the container + - ./app/dashboard.yml:/app/app/dashboard.yml + environment: + - NUXT_HOST=0.0.0.0 + - NUXT_PORT=3000