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