Add docker and build scripts
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,6 +17,7 @@ logs
|
||||
.DS_Store
|
||||
.fleet
|
||||
.idea
|
||||
docker-build.ps1
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
|
||||
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@@ -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
|
||||
58
docker-build.example.ps1
Normal file
58
docker-build.example.ps1
Normal file
@@ -0,0 +1,58 @@
|
||||
# Docker Build and Push Script
|
||||
# Builds the dashlio image and pushes it to private registry
|
||||
|
||||
param(
|
||||
[string]$ImageName = "<imageName>",
|
||||
[string]$RegistryUrl = "<registryUrl>",
|
||||
[string]$Tag = "<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
|
||||
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user