revert npm logic
This commit is contained in:
@@ -38,7 +38,8 @@
|
|||||||
"Bash(git checkout:*)",
|
"Bash(git checkout:*)",
|
||||||
"Bash(git push:*)",
|
"Bash(git push:*)",
|
||||||
"Bash(Start-Sleep -Seconds 10)",
|
"Bash(Start-Sleep -Seconds 10)",
|
||||||
"Bash(npm install:*)"
|
"Bash(npm install:*)",
|
||||||
|
"Bash(npm config get:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -94,5 +94,7 @@ frontend/.angular/
|
|||||||
frontend/dist/
|
frontend/dist/
|
||||||
frontend/package-lock.json
|
frontend/package-lock.json
|
||||||
frontend/package-lock*.json
|
frontend/package-lock*.json
|
||||||
# package-lock.json is machine-specific and depends on npm registry
|
frontend/.npmrc
|
||||||
# Each environment will generate its own based on local .npmrc
|
frontend/.npmrc.*
|
||||||
|
# package-lock.json and .npmrc are machine-specific and depend on npm registry
|
||||||
|
# Each environment will generate its own based on local npm configuration
|
||||||
|
|||||||
13
Dockerfile
13
Dockerfile
@@ -9,10 +9,17 @@ WORKDIR /frontend
|
|||||||
# Copy package files
|
# Copy package files
|
||||||
COPY frontend/package*.json ./
|
COPY frontend/package*.json ./
|
||||||
|
|
||||||
|
# Copy .npmrc from frontend directory if it exists (using glob pattern to avoid errors)
|
||||||
|
# This allows different environments to use different npm registries
|
||||||
|
# To use: copy your user-level .npmrc to frontend/.npmrc before building
|
||||||
|
# Unix/Mac: cp ~/.npmrc frontend/.npmrc
|
||||||
|
# Windows: copy %USERPROFILE%\.npmrc frontend\.npmrc
|
||||||
|
COPY frontend/.npmr[c] ./ 2>/dev/null || :
|
||||||
|
|
||||||
# Install dependencies using npm install
|
# Install dependencies using npm install
|
||||||
# This will use the Docker build environment's npm configuration (.npmrc)
|
# This will use the .npmrc configuration if present and generate a package-lock.json
|
||||||
# and generate a package-lock.json appropriate for the configured registry
|
# appropriate for the configured registry (Artifactory or public npm)
|
||||||
RUN npm install --legacy-peer-deps
|
RUN npm install
|
||||||
|
|
||||||
# Copy frontend source
|
# Copy frontend source
|
||||||
COPY frontend/src ./src
|
COPY frontend/src ./src
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[switch]$Rebuild,
|
[switch]$Rebuild,
|
||||||
[switch]$Bsf,
|
|
||||||
[switch]$Help
|
[switch]$Help
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,11 +15,11 @@ if ($Help) {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Options:" -ForegroundColor Yellow
|
Write-Host "Options:" -ForegroundColor Yellow
|
||||||
Write-Host " -Rebuild Force rebuild of all containers" -ForegroundColor White
|
Write-Host " -Rebuild Force rebuild of all containers" -ForegroundColor White
|
||||||
Write-Host " -Bsf Use Artifactory npm registry instead of public npm" -ForegroundColor White
|
|
||||||
Write-Host " -Help Show this help message" -ForegroundColor White
|
Write-Host " -Help Show this help message" -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Environment Variables (when using -Bsf):" -ForegroundColor Yellow
|
Write-Host "NPM Registry:" -ForegroundColor Yellow
|
||||||
Write-Host ' $env:ARTIFACTORY_AUTH_TOKEN Authentication token for Artifactory' -ForegroundColor White
|
Write-Host " Create frontend/.npmrc to configure custom npm registry" -ForegroundColor White
|
||||||
|
Write-Host " The Docker build will use this file if present" -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Brings up the complete stack: database, backend API, and frontend" -ForegroundColor Green
|
Write-Host "Brings up the complete stack: database, backend API, and frontend" -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
@@ -32,26 +31,24 @@ Write-Host "Obsidian - Quick Start" -ForegroundColor Cyan
|
|||||||
Write-Host "=========================================" -ForegroundColor Cyan
|
Write-Host "=========================================" -ForegroundColor Cyan
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# Determine npm registry and build arguments
|
# Copy user's .npmrc to frontend directory if it exists and frontend/.npmrc doesn't
|
||||||
$NpmRegistry = "public"
|
$UserNpmrc = Join-Path $env:USERPROFILE ".npmrc"
|
||||||
$BuildArgs = @()
|
$FrontendNpmrc = "frontend\.npmrc"
|
||||||
|
|
||||||
if ($Bsf) {
|
if (Test-Path $UserNpmrc) {
|
||||||
$NpmRegistry = "artifactory"
|
if (-not (Test-Path $FrontendNpmrc)) {
|
||||||
$BuildArgs += "--build-arg"
|
Write-Host "[INFO] Copying npm registry config from $UserNpmrc" -ForegroundColor Yellow
|
||||||
$BuildArgs += "NPM_REGISTRY=artifactory"
|
Copy-Item $UserNpmrc $FrontendNpmrc
|
||||||
|
Write-Host "[OK] Using custom npm registry configuration" -ForegroundColor Green
|
||||||
Write-Host "Using Artifactory npm registry" -ForegroundColor Yellow
|
|
||||||
|
|
||||||
if ($env:ARTIFACTORY_AUTH_TOKEN) {
|
|
||||||
Write-Host "[OK] Artifactory auth token detected" -ForegroundColor Green
|
|
||||||
$BuildArgs += "--build-arg"
|
|
||||||
$BuildArgs += "ARTIFACTORY_AUTH_TOKEN=$env:ARTIFACTORY_AUTH_TOKEN"
|
|
||||||
} else {
|
} else {
|
||||||
Write-Host "[WARNING] ARTIFACTORY_AUTH_TOKEN not set (may be required for authentication)" -ForegroundColor Yellow
|
Write-Host "[OK] Using existing frontend\.npmrc" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Using public npm registry (registry.npmjs.org)" -ForegroundColor Green
|
if (Test-Path $FrontendNpmrc) {
|
||||||
|
Write-Host "[OK] Using frontend\.npmrc" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "[INFO] Using default npm registry (no .npmrc found)" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
@@ -101,40 +98,20 @@ if ($Rebuild) {
|
|||||||
Write-Host "Removing existing images for rebuild..." -ForegroundColor White
|
Write-Host "Removing existing images for rebuild..." -ForegroundColor White
|
||||||
& docker compose down --rmi local
|
& docker compose down --rmi local
|
||||||
Write-Host "Building and starting all services..." -ForegroundColor White
|
Write-Host "Building and starting all services..." -ForegroundColor White
|
||||||
if ($BuildArgs.Count -gt 0) {
|
& docker compose up -d --build
|
||||||
& docker compose build $BuildArgs
|
|
||||||
& docker compose up -d
|
|
||||||
} else {
|
|
||||||
& docker compose up -d --build
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
& docker-compose down
|
& docker-compose down
|
||||||
Write-Host "Removing existing images for rebuild..." -ForegroundColor White
|
Write-Host "Removing existing images for rebuild..." -ForegroundColor White
|
||||||
& docker-compose down --rmi local
|
& docker-compose down --rmi local
|
||||||
Write-Host "Building and starting all services..." -ForegroundColor White
|
Write-Host "Building and starting all services..." -ForegroundColor White
|
||||||
if ($BuildArgs.Count -gt 0) {
|
& docker-compose up -d --build
|
||||||
& docker-compose build $BuildArgs
|
|
||||||
& docker-compose up -d
|
|
||||||
} else {
|
|
||||||
& docker-compose up -d --build
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Starting all services..." -ForegroundColor Green
|
Write-Host "Starting all services..." -ForegroundColor Green
|
||||||
if ($ComposeCmd -eq "docker compose") {
|
if ($ComposeCmd -eq "docker compose") {
|
||||||
if ($BuildArgs.Count -gt 0) {
|
& docker compose up -d
|
||||||
& docker compose build $BuildArgs
|
|
||||||
& docker compose up -d
|
|
||||||
} else {
|
|
||||||
& docker compose up -d
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ($BuildArgs.Count -gt 0) {
|
& docker-compose up -d
|
||||||
& docker-compose build $BuildArgs
|
|
||||||
& docker-compose up -d
|
|
||||||
} else {
|
|
||||||
& docker-compose up -d
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ fi
|
|||||||
|
|
||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
REBUILD=false
|
REBUILD=false
|
||||||
USE_ARTIFACTORY=false
|
|
||||||
NPM_REGISTRY="public"
|
|
||||||
BUILD_ARGS=""
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
@@ -36,22 +33,16 @@ while [[ $# -gt 0 ]]; do
|
|||||||
REBUILD=true
|
REBUILD=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-bsf)
|
|
||||||
USE_ARTIFACTORY=true
|
|
||||||
NPM_REGISTRY="artifactory"
|
|
||||||
BUILD_ARGS="--build-arg NPM_REGISTRY=artifactory"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--help)
|
--help)
|
||||||
echo "Usage: $0 [OPTIONS]"
|
echo "Usage: $0 [OPTIONS]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --rebuild Force rebuild of all containers"
|
echo " --rebuild Force rebuild of all containers"
|
||||||
echo " -bsf Use Artifactory npm registry instead of public npm"
|
|
||||||
echo " --help Show this help message"
|
echo " --help Show this help message"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Environment Variables (when using -bsf):"
|
echo "NPM Registry:"
|
||||||
echo " ARTIFACTORY_AUTH_TOKEN Authentication token for Artifactory"
|
echo " Create frontend/.npmrc to configure custom npm registry"
|
||||||
|
echo " The Docker build will use this file if present"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Brings up the complete stack: database, backend API, and frontend"
|
echo "Brings up the complete stack: database, backend API, and frontend"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -65,17 +56,24 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# If using Artifactory, add auth token to build args if available
|
# Copy user's .npmrc to frontend directory if it exists and frontend/.npmrc doesn't
|
||||||
if [ "$USE_ARTIFACTORY" = true ]; then
|
USER_NPMRC="${HOME}/.npmrc"
|
||||||
echo "Using Artifactory npm registry"
|
FRONTEND_NPMRC="frontend/.npmrc"
|
||||||
if [ -n "$ARTIFACTORY_AUTH_TOKEN" ]; then
|
|
||||||
echo "✓ Artifactory auth token detected"
|
if [ -f "$USER_NPMRC" ]; then
|
||||||
BUILD_ARGS="$BUILD_ARGS --build-arg ARTIFACTORY_AUTH_TOKEN=$ARTIFACTORY_AUTH_TOKEN"
|
if [ ! -f "$FRONTEND_NPMRC" ]; then
|
||||||
|
echo "ℹ Copying npm registry config from $USER_NPMRC"
|
||||||
|
cp "$USER_NPMRC" "$FRONTEND_NPMRC"
|
||||||
|
echo "✓ Using custom npm registry configuration"
|
||||||
else
|
else
|
||||||
echo "⚠ Warning: ARTIFACTORY_AUTH_TOKEN not set (may be required for authentication)"
|
echo "✓ Using existing frontend/.npmrc"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Using public npm registry (registry.npmjs.org)"
|
if [ -f "$FRONTEND_NPMRC" ]; then
|
||||||
|
echo "✓ Using frontend/.npmrc"
|
||||||
|
else
|
||||||
|
echo "ℹ Using default npm registry (no .npmrc found)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -98,20 +96,10 @@ if [ "$REBUILD" = true ]; then
|
|||||||
echo "Removing existing images for rebuild..."
|
echo "Removing existing images for rebuild..."
|
||||||
$COMPOSE_CMD down --rmi local 2>/dev/null || true
|
$COMPOSE_CMD down --rmi local 2>/dev/null || true
|
||||||
echo "Building and starting all services..."
|
echo "Building and starting all services..."
|
||||||
if [ -n "$BUILD_ARGS" ]; then
|
$COMPOSE_CMD up -d --build
|
||||||
$COMPOSE_CMD build $BUILD_ARGS
|
|
||||||
$COMPOSE_CMD up -d
|
|
||||||
else
|
|
||||||
$COMPOSE_CMD up -d --build
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "Starting all services..."
|
echo "Starting all services..."
|
||||||
if [ -n "$BUILD_ARGS" ]; then
|
$COMPOSE_CMD up -d
|
||||||
$COMPOSE_CMD build $BUILD_ARGS
|
|
||||||
$COMPOSE_CMD up -d
|
|
||||||
else
|
|
||||||
$COMPOSE_CMD up -d
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user