From 3c27bac094153c8606ae42f1f99322c1b4dc51e3 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Wed, 16 Jul 2025 09:50:00 +0200 Subject: [PATCH] rm prepare standalone entirely, update dockerfile to use pnpm --- login/apps/login/Dockerfile | 22 +++-- login/apps/login/package.standalone.json | 65 ------------ login/apps/login/prepare-standalone.sh | 57 ----------- login/apps/login/scripts/README.md | 99 ------------------- .../apps/login/scripts/prepare-standalone.js | 93 ----------------- 5 files changed, 13 insertions(+), 323 deletions(-) delete mode 100644 login/apps/login/package.standalone.json delete mode 100755 login/apps/login/prepare-standalone.sh delete mode 100644 login/apps/login/scripts/README.md delete mode 100644 login/apps/login/scripts/prepare-standalone.js diff --git a/login/apps/login/Dockerfile b/login/apps/login/Dockerfile index 06bd053076..824ee97101 100644 --- a/login/apps/login/Dockerfile +++ b/login/apps/login/Dockerfile @@ -1,28 +1,32 @@ # Dockerfile for standalone ZITADEL Login UI FROM node:18-alpine AS base +# Install pnpm +RUN npm install -g pnpm@9.1.2 + # Install dependencies only when needed FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app -# Prepare standalone and install dependencies -COPY prepare-standalone.sh package*.json ./ -COPY *.standalone.* ./ -RUN ./prepare-standalone.sh +# Install dependencies using pnpm +COPY package*.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile --prod # Rebuild the source code only when needed FROM base AS builder WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . -# Prepare standalone configs -RUN ./prepare-standalone.sh --no-install +# Copy package files and install all dependencies (including dev dependencies) +COPY package*.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +# Copy source code +COPY . . # Build application ENV NEXT_TELEMETRY_DISABLED 1 -RUN npm run build:standalone +RUN pnpm run build:login:standalone # Production image, copy all the files and run next FROM base AS runner diff --git a/login/apps/login/package.standalone.json b/login/apps/login/package.standalone.json deleted file mode 100644 index db0c7bbb6f..0000000000 --- a/login/apps/login/package.standalone.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@zitadel/login", - "private": true, - "type": "module", - "scripts": { - "dev": "next dev --turbopack", - "test:unit": "vitest", - "test:unit:watch": "vitest --watch", - "lint": "next lint && prettier --check .", - "lint:fix": "prettier --write .", - "build": "next build", - "build:standalone": "NEXT_PUBLIC_BASE_PATH=/ui/v2/login NEXT_OUTPUT_MODE=standalone next build", - "start": "next start", - "clean": "rm -rf node_modules && rm -rf .next" - }, - "dependencies": { - "@headlessui/react": "^2.1.9", - "@heroicons/react": "2.1.3", - "@tailwindcss/forms": "0.5.7", - "@vercel/analytics": "^1.2.2", - "@zitadel/client": "latest", - "@zitadel/proto": "latest", - "clsx": "1.2.1", - "copy-to-clipboard": "^3.3.3", - "deepmerge": "^4.3.1", - "lucide-react": "0.469.0", - "moment": "^2.29.4", - "next": "15.4.0-canary.86", - "next-intl": "^3.25.1", - "next-themes": "^0.2.1", - "nice-grpc": "2.0.1", - "qrcode.react": "^3.1.0", - "react": "19.1.0", - "react-dom": "19.1.0", - "react-hook-form": "7.39.5", - "tinycolor2": "1.4.2", - "uuid": "^11.1.0" - }, - "devDependencies": { - "@babel/eslint-parser": "^7.23.0", - "@bufbuild/buf": "^1.53.0", - "@testing-library/jest-dom": "^6.6.3", - "@testing-library/react": "^16.3.0", - "@types/node": "^22.14.1", - "@types/react": "19.1.2", - "@types/react-dom": "19.1.2", - "@types/tinycolor2": "1.4.3", - "@types/uuid": "^10.0.0", - "@typescript-eslint/eslint-plugin": "^7.0.0", - "@typescript-eslint/parser": "^7.0.0", - "autoprefixer": "10.4.21", - "eslint": "^8.57.0", - "eslint-config-next": "15.4.0-canary.86", - "eslint-config-prettier": "^9.1.0", - "jsdom": "^26.1.0", - "postcss": "8.5.3", - "prettier": "^3.2.5", - "prettier-plugin-organize-imports": "^3.2.0", - "prettier-plugin-tailwindcss": "0.6.11", - "sass": "^1.87.0", - "tailwindcss": "3.4.14", - "typescript": "^5.8.3", - "vitest": "^2.0.0" - } -} diff --git a/login/apps/login/prepare-standalone.sh b/login/apps/login/prepare-standalone.sh deleted file mode 100755 index 168d6f41bb..0000000000 --- a/login/apps/login/prepare-standalone.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Script to prepare standalone version of the login app -set -e - -echo "šŸ”§ Preparing standalone version..." - -# Parse arguments -INSTALL_DEPS=true -USE_LATEST=false - -for arg in "$@"; do - case $arg in - --no-install) - INSTALL_DEPS=false - shift - ;; - --latest) - USE_LATEST=true - shift - ;; - *) - # Unknown option - ;; - esac -done - -# Build arguments for Node.js script -NODE_ARGS="" -if [ "$INSTALL_DEPS" = true ]; then - NODE_ARGS="$NODE_ARGS --install" -fi -if [ "$USE_LATEST" = true ]; then - NODE_ARGS="$NODE_ARGS --latest" -fi - -# Check if Node.js scripts exist -if [ ! -f "scripts/prepare-standalone.js" ]; then - echo "āŒ scripts/prepare-standalone.js not found!" - echo " Make sure you're in the correct directory" - exit 1 -fi - -# Run the enhanced Node.js prepare script -node scripts/prepare-standalone.js $NODE_ARGS - -echo "" -echo "āœ… Standalone version prepared successfully!" - -if [ "$INSTALL_DEPS" = false ]; then - echo "" - echo "šŸ“ Next steps:" - echo " npm install - Install dependencies" - echo " npm run dev - Start development server" - echo " npm run build - Build for production" - echo " npm run start - Start production server" -fi diff --git a/login/apps/login/scripts/README.md b/login/apps/login/scripts/README.md deleted file mode 100644 index 52e8007e90..0000000000 --- a/login/apps/login/scripts/README.md +++ /dev/null @@ -1,99 +0,0 @@ -# Standalone Build Scripts - -This directory contains the simplified scripts needed for managing the ZITADEL Login UI standalone conversion. - -## šŸ“ File Overview - -### Required Files - -- `package.json` - Main package file (monorepo mode with `workspace:*`) -- `package.standalone.json` - Pre-configured standalone version (uses `latest`) -- `scripts/prepare-standalone.js` - Conversion script - -### Generated/Temporary Files - -- `package.monorepo.backup.json` - Backup when switching to standalone mode - -## šŸ› ļø Scripts Overview - -### `prepare-standalone.js` - -**The main script for converting monorepo to standalone mode.** - -```bash -node scripts/prepare-standalone.js [--install] -``` - -- `--install` - Automatically install dependencies after preparation - -**What it does:** - -- Copies `package.standalone.json` → `package.json` -- Confirms all configurations are unified and ready for standalone use -- Optionally runs `pnpm install` - -## šŸš€ **Simplified Approach** - -This setup now uses a **much simpler approach**: - -1. **Unified Configuration**: All ESLint, Prettier, and Tailwind configs work for both monorepo and standalone modes -2. **Static Configuration**: `package.standalone.json` is pre-configured with `latest` versions -3. **No Duplicate Configs**: No separate `*.standalone.*` config files needed -4. **Faster Setup**: Conversion is instant with just file copying - -## šŸ“‹ **Usage for Customers** - -```bash -# 1. Clone the repository -git clone - -# 2. Prepare standalone mode -node scripts/prepare-standalone.js --install - -# 3. Start developing -pnpm run dev -``` - -## šŸ”§ **Usage for Maintainers** - -```bash -# Update to latest packages manually in package.standalone.json -npm view @zitadel/client version -npm view @zitadel/proto version - -# Then update package.standalone.json with latest versions -``` - -## ✨ **Key Benefits** - -- **Single Config Files**: ESLint, Prettier, and Tailwind configs work for both modes -- **No Duplication**: No need for separate `*.standalone.*` configuration files -- **Faster Conversion**: Only 2 files need to be copied (package.json and tsconfig.json) -- **Simpler Maintenance**: All configuration logic is in one place - -# Switch back to monorepo mode - -node scripts/config-manager.js switch monorepo - -```` - -### `validate-standalone.js` - -**Validates that standalone setup is working correctly.** - -```bash -node scripts/validate-standalone.js -```` - -**Checks:** - -- Required files exist -- Package.json has required scripts and dependencies -- Dependencies can be resolved -- TypeScript compilation works - -## Workflow Examples - -### For Developers (Monorepo) - -1. **Working in monorepo:** diff --git a/login/apps/login/scripts/prepare-standalone.js b/login/apps/login/scripts/prepare-standalone.js deleted file mode 100644 index 666e116edb..0000000000 --- a/login/apps/login/scripts/prepare-standalone.js +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env node - -/** - * Prepare script for standalone version - * This script converts the monorepo version to a standalone version - */ - -import { execSync } from "child_process"; -import fs from "fs/promises"; - -const FILES_TO_REMOVE = [ - // Turbo is not needed for standalone builds since there are no workspace dependencies - { file: "turbo.json", backup: "turbo.monorepo.backup.json" }, -]; - -async function prepareStandalone() { - console.log("šŸ”§ Preparing standalone version...\n"); - - const args = process.argv.slice(2); - const shouldInstall = args.includes("--install"); - - try { - // Step 1: Copy package.standalone.json to package.json - console.log("šŸ“¦ Setting up package.json..."); - const packageStandaloneExists = await fs - .access("package.standalone.json") - .then(() => true) - .catch(() => false); - - if (packageStandaloneExists) { - // Backup current package.json - await fs.copyFile("package.json", "package.monorepo.backup.json"); - console.log( - " šŸ’¾ Backed up package.json → package.monorepo.backup.json", - ); - - // Copy standalone version - await fs.copyFile("package.standalone.json", "package.json"); - console.log(" āœ… package.standalone.json → package.json"); - } else { - throw new Error("package.standalone.json not found!"); - } - - // Step 2: Remove unnecessary files for standalone - console.log("šŸ—‘ļø Removing monorepo-specific files..."); - for (const item of FILES_TO_REMOVE) { - const fileExists = await fs - .access(item.file) - .then(() => true) - .catch(() => false); - - if (fileExists) { - // Backup current file - await fs.copyFile(item.file, item.backup); - console.log(` šŸ’¾ Backed up ${item.file} → ${item.backup}`); - - // Remove the file - await fs.unlink(item.file); - console.log(` šŸ—‘ļø Removed ${item.file} (not needed in standalone)`); - } else { - console.log(` ā„¹ļø ${item.file} not found, skipping`); - } - } - - // Step 3: Install dependencies if requested - if (shouldInstall) { - console.log("\nšŸ“„ Installing dependencies..."); - try { - execSync("pnpm install", { stdio: "inherit" }); - console.log(" āœ… Dependencies installed successfully"); - } catch (error) { - console.warn( - " āš ļø pnpm install failed, you may need to run it manually", - ); - } - } - - console.log("\nšŸŽ‰ Standalone preparation complete!"); - console.log(" ✨ Turbo removed - using standard npm scripts"); - console.log("\nšŸ“‹ Next steps:"); - if (!shouldInstall) { - console.log(" 1. Run: pnpm install"); - } - console.log(" 2. Run: pnpm run dev"); - console.log(" 3. Start developing!\n"); - } catch (error) { - console.error("\nāŒ Failed to prepare standalone version:", error.message); - console.error("Please check the error above and try again.\n"); - process.exit(1); - } -} - -prepareStandalone();