From 3fddbf1b752772e89f3130ca0bacde760b1dc6a7 Mon Sep 17 00:00:00 2001 From: anisharma07 Date: Tue, 12 Aug 2025 01:58:59 +0530 Subject: [PATCH] changes --- DOCKER.md | 248 ----------------- DOCKER_BUILD.md | 456 ------------------------------- DOCKER_STRATEGIES.md | 237 ---------------- Dockerfile | 75 ----- Dockerfile.android | 146 ---------- Dockerfile.full | 59 ---- INVOICE_MODULE_IMPLEMENTATION.md | 154 ----------- audit.md | 128 --------- docker-build.sh | 274 ------------------- docker-compose.android.yml | 77 ------ docker-compose.yml | 96 ------- test-docker-setup.sh | 252 ----------------- test1.txt | 1 - 13 files changed, 2203 deletions(-) delete mode 100644 DOCKER.md delete mode 100644 DOCKER_BUILD.md delete mode 100644 DOCKER_STRATEGIES.md delete mode 100644 Dockerfile delete mode 100644 Dockerfile.android delete mode 100644 Dockerfile.full delete mode 100644 INVOICE_MODULE_IMPLEMENTATION.md delete mode 100644 audit.md delete mode 100755 docker-build.sh delete mode 100644 docker-compose.android.yml delete mode 100644 docker-compose.yml delete mode 100755 test-docker-setup.sh delete mode 100644 test1.txt diff --git a/DOCKER.md b/DOCKER.md deleted file mode 100644 index 0556b49..0000000 --- a/DOCKER.md +++ /dev/null @@ -1,248 +0,0 @@ -# Docker Setup for Ionic React Government Invoice Form - -This project includes multiple Docker configurations for different purposes: - -1. **Web Development & Production** (this file) - For web application deployment -2. **Android APK Building** - For building Android APKs in Docker containers - -## 📱 Android APK Building with Docker - -For building Android APKs using Docker, see the comprehensive guide: **[DOCKER_BUILD.md](./DOCKER_BUILD.md)** - -Features include: - -- đŸŗ Dockerized Android build environment -- 🔄 Automated CI/CD with GitHub Actions -- đŸ› ī¸ Local development tools -- đŸ“Ļ Reproducible builds - -**Quick Start for Android Builds:** - -```bash -# Build Docker image for Android -./docker-build.sh build-image - -# Build APK using Docker -./docker-build.sh build-apk -``` - -## 🌐 Web Development & Production - -This section covers Docker setup for web development and production environments. - -### Prerequisites - -- Docker -- Docker Compose - -## Available Environments - -### Development Environment - -**Option 1: Alpine-based (smaller image)** - -```bash -# Start development environment -docker-compose --profile dev up - -# Or run in detached mode -docker-compose --profile dev up -d -``` - -**Option 2: Full Node.js (more stable for complex builds)** - -```bash -# Start development environment with full Node.js image -docker-compose --profile dev-full up - -# Or run in detached mode -docker-compose --profile dev-full up -d -``` - -Access the application at http://localhost:5173 - -### Production Environment - -**Option 1: Alpine-based (smaller image)** - -```bash -# Start production environment -docker-compose --profile prod up - -# Or run in detached mode -docker-compose --profile prod up -d -``` - -**Option 2: Full Node.js (more stable for complex builds)** - -```bash -# Start production environment with full Node.js image -docker-compose --profile prod-full up - -# Or run in detached mode -docker-compose --profile prod-full up -d -``` - -Access the application at http://localhost:80 - -### Build Only - -Just build the application without running it: - -```bash -# Build the application -docker-compose --profile build up - -# The built files will be available in the ./dist directory -``` - -## Services - -- **ionic-dev**: Development server with Alpine Node.js image -- **ionic-dev-full**: Development server with full Node.js image (recommended for complex builds) -- **ionic-prod**: Production server with Alpine-based build -- **ionic-prod-full**: Production server with full Node.js build (recommended for complex builds) -- **ionic-build**: Build-only service for CI/CD pipelines - -## Dockerfiles - -- **Dockerfile**: Alpine-based multi-stage build (smaller but may have build issues with native dependencies) -- **Dockerfile.full**: Full Node.js-based build (larger but more compatible with native dependencies) - -## Ports - -- Development: `5173` -- Production: `80` - -## Docker Configuration - -Both setups use multi-stage Dockerfiles: - -1. **Development stage**: Node.js with Vite dev server -2. **Build stage**: Compiles TypeScript and builds the application -3. **Production stage**: Nginx serving the built static files - -## Environment Variables - -You can customize the build by setting environment variables in a `.env` file: - -```env -NODE_ENV=development -VITE_API_URL=your_api_url -VITE_APP_NAME=Your App Name -JWT_SECRET=your-secret-key -``` - -**Important:** Create a `.env` file from the example: - -```bash -cp .env.example .env -``` - -### Environment Variable Loading - -The Docker Compose configuration includes `env_file: .env` directive to automatically load environment variables from your `.env` file into the containers. - -## Stopping Services - -```bash -# Stop and remove containers -docker-compose down - -# Stop and remove containers, networks, and volumes -docker-compose down -v -``` - -## Troubleshooting - -### Build Errors with Native Dependencies - -If you encounter Python/gyp errors during build: - -1. **Use the full Node.js image**: Try the `-full` profiles which use the complete Node.js image instead of Alpine -2. **Clear Docker cache**: Run `docker system prune -a` to clear build cache -3. **Check package compatibility**: Some packages may not be compatible with Alpine Linux - -### Common Issues - -- **Permission issues**: Ensure your user has Docker permissions -- **Hot reload not working**: Verify that file watching is enabled in your Docker environment -- **Port conflicts**: Make sure ports 5173 (dev) and 80 (prod) are not already in use -- **Memory issues**: Increase Docker memory limits if builds fail due to insufficient resources -- **Environment variables not loading**: - - Ensure `.env` file exists in the project root (copy from `.env.example`) - - Check file permissions: `chmod 644 .env` - - Verify `.env` file format (no quotes around values for Docker Compose) - - Restart containers after `.env` changes: `docker-compose down && docker-compose --profile [your-profile] up` - -### Checking Logs - -```bash -# View logs for a specific service -docker-compose logs [service-name] - -# Follow logs in real-time -docker-compose logs -f [service-name] - -# View build logs -docker-compose build [service-name] -``` - -### Environment Variables Troubleshooting - -If your `.env` file is not being picked up in Ubuntu: - -1. **Create .env file**: Copy from the example template - - ```bash - cp .env.example .env - ``` - -2. **Check file permissions**: Ensure Docker can read the file - - ```bash - chmod 644 .env - ls -la .env - ``` - -3. **Verify file location**: The `.env` file must be in the same directory as `docker-compose.yml` - - ```bash - pwd - ls -la | grep -E "(docker-compose|\.env)" - ``` - -4. **Check environment variables inside container**: - - ```bash - # Access running container - docker exec -it ionic-govt-billing-dev-full bash - - # Check environment variables - env | grep VITE - echo $VITE_API_URL - ``` - -5. **Restart after changes**: Always restart containers after modifying `.env` - - ```bash - docker-compose down - docker-compose --profile dev-full up - ``` - -6. **Debug with explicit environment**: Test with inline environment variables - ```bash - VITE_API_URL=http://test.com docker-compose --profile dev-full up - ``` - -### Recommended Approach - -For most users, especially those encountering build issues, we recommend using the `-full` profiles: - -```bash -# Development -docker-compose --profile dev-full up - -# Production -docker-compose --profile prod-full up -``` diff --git a/DOCKER_BUILD.md b/DOCKER_BUILD.md deleted file mode 100644 index f932a4a..0000000 --- a/DOCKER_BUILD.md +++ /dev/null @@ -1,456 +0,0 @@ -# đŸŗ Docker-based Android Build Setup - -This document explains how to use Docker for building the Government Invoice Form Android APK. The Docker setup provides a consistent, reproducible build environment that eliminates the common "works on my machine" problems. - -## 📋 Table of Contents - -- [Overview](#overview) -- [Prerequisites](#prerequisites) -- [Quick Start](#quick-start) -- [Docker Setup Files](#docker-setup-files) -- [GitHub Actions Workflow](#github-actions-workflow) -- [Local Development](#local-development) -- [Troubleshooting](#troubleshooting) -- [Advanced Usage](#advanced-usage) - -## đŸŽ¯ Overview - -The Docker setup includes: - -- **Dockerfile.android**: Multi-stage Dockerfile for Android builds -- **docker-compose.android.yml**: Docker Compose configuration -- **docker-build.sh**: Helper script for local development -- **.github/workflows/docker-release-apk.yml**: Automated Docker-based releases - -### Benefits of Docker Build - -✅ **Reproducible**: Same build environment every time -✅ **Isolated**: No conflicts with host system dependencies -✅ **Consistent**: All team members use identical build tools -✅ **Portable**: Can be built on any Docker-capable system -✅ **Automated**: Integrates seamlessly with CI/CD - -## đŸ“Ļ Prerequisites - -### Required Software - -- **Docker**: Version 20.10 or higher -- **Docker Compose**: Version 2.0 or higher (optional, for convenience) -- **Git**: For version control - -### Installation - -#### Ubuntu/Debian - -```bash -# Install Docker -curl -fsSL https://get.docker.com -o get-docker.sh -sudo sh get-docker.sh - -# Install Docker Compose -sudo apt-get update -sudo apt-get install docker-compose-plugin - -# Add user to docker group (logout/login required) -sudo usermod -aG docker $USER -``` - -#### macOS - -```bash -# Install Docker Desktop -brew install --cask docker - -# Or download from: https://www.docker.com/products/docker-desktop -``` - -#### Windows - -Download Docker Desktop from: https://www.docker.com/products/docker-desktop - -## 🚀 Quick Start - -### 1. Clone the Repository - -```bash -git clone -cd Govt-Invoice-Form -``` - -### 2. Build Docker Image - -```bash -# Using helper script (recommended) -./docker-build.sh build-image - -# Or manually -docker build -f Dockerfile.android -t govt-invoice-android:latest . -``` - -### 3. Setup Keystore (for release builds) - -```bash -./docker-build.sh setup-keystore -``` - -### 4. Build APK - -```bash -# Build release APK using Docker -./docker-build.sh build-apk -``` - -The APK will be available in `docker-outputs/apk/release/` - -## 📁 Docker Setup Files - -### Dockerfile.android - -Multi-stage Dockerfile optimized for Android builds: - -```dockerfile -# Key features: -- Ubuntu 22.04 base image -- Android SDK with necessary components -- Node.js 20.x and Yarn -- Java OpenJDK 17 -- Capacitor CLI and build tools -- Automated build script -``` - -**Stages:** - -- `android-builder`: Production build environment -- `android-dev`: Development environment with additional tools - -### docker-compose.android.yml - -Provides convenient service definitions: - -- `android-builder`: For building APKs -- `android-dev`: For development with volume mounts -- `web-dev`: For web development -- `web-prod`: For production web builds - -### docker-build.sh - -Helper script with commands: - -- `build-image`: Build Docker image -- `build-apk`: Build APK using Docker -- `dev`: Start development environment -- `web-dev`: Start web development server -- `clean`: Clean Docker resources -- `setup-keystore`: Setup release keystore - -## 🔄 GitHub Actions Workflow - -### Trigger - -The Docker-based workflow triggers when: - -- A PR is merged to `main` AND has the `docker-release` label -- The `docker-release` label is added to a merged PR - -### Workflow Features - -- **Version Management**: Automatic semantic versioning -- **Docker Build**: Builds APK in isolated container -- **Release Creation**: Creates GitHub release with Docker-built APK -- **Cleanup**: Removes sensitive data and Docker resources -- **Error Handling**: Comprehensive error reporting - -### Usage - -1. Create a PR with your changes -2. Add the `docker-release` label to the PR -3. Merge the PR -4. The workflow will automatically build and release - -## đŸ’ģ Local Development - -### Development Environment - -Start the development environment: - -```bash -# Start Android development container -./docker-build.sh dev - -# Or start web development server -./docker-build.sh web-dev -``` - -### Building APKs Locally - -1. **Setup keystore** (first time only): - - ```bash - ./docker-build.sh setup-keystore - ``` - -2. **Build APK**: - - ```bash - ./docker-build.sh build-apk - ``` - -3. **Find your APK**: - ```bash - ls -la docker-outputs/apk/release/ - ``` - -### Volume Mounts - -The development setup uses volume mounts for: - -- Source code changes (live reload) -- Gradle cache (faster builds) -- Build outputs (persistent artifacts) - -## 🔧 Troubleshooting - -### Common Issues - -#### Docker Image Build Fails - -**Problem**: Android SDK download fails - -```bash -# Solution: Check internet connection and retry -./docker-build.sh build-image -``` - -**Problem**: Out of disk space - -```bash -# Solution: Clean Docker resources -./docker-build.sh clean -docker system prune -a -``` - -#### APK Build Fails - -**Problem**: Keystore not found - -```bash -# Solution: Setup keystore properly -./docker-build.sh setup-keystore -``` - -**Problem**: Permission denied - -```bash -# Solution: Fix file permissions -sudo chown -R $USER:$USER docker-outputs/ -``` - -#### Container Won't Start - -**Problem**: Port already in use - -```bash -# Solution: Kill processes using the port -sudo lsof -ti:5173 | xargs kill -9 -``` - -**Problem**: Docker daemon not running - -```bash -# Solution: Start Docker service -sudo systemctl start docker -``` - -### Debug Mode - -Run containers in debug mode: - -```bash -# Run container interactively -docker run -it --rm govt-invoice-android:latest bash - -# Check container logs -docker logs -``` - -### Logs and Debugging - -View build logs: - -```bash -# During build -docker build -f Dockerfile.android -t govt-invoice-android:latest . --progress=plain - -# Container logs -docker run --rm govt-invoice-android:latest 2>&1 | tee build.log -``` - -## 🔄 Advanced Usage - -### Custom Build Configuration - -#### Environment Variables - -Set custom environment variables: - -```bash -docker run --rm \ - -e ANDROID_HOME=/opt/android-sdk \ - -e JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \ - -v $(pwd)/docker-outputs:/app/android/app/build/outputs \ - govt-invoice-android:latest -``` - -#### Custom Gradle Configuration - -Mount custom gradle configuration: - -```bash -docker run --rm \ - -v $(pwd)/custom-gradle.properties:/app/android/gradle.properties \ - -v $(pwd)/docker-outputs:/app/android/app/build/outputs \ - govt-invoice-android:latest -``` - -### Multi-Platform Builds - -Build for multiple architectures: - -```bash -# Setup buildx -docker buildx create --use - -# Build multi-platform image -docker buildx build \ - --platform linux/amd64,linux/arm64 \ - -f Dockerfile.android \ - -t govt-invoice-android:latest \ - --push . -``` - -### CI/CD Integration - -#### Jenkins - -```groovy -pipeline { - agent any - stages { - stage('Build APK') { - steps { - sh './docker-build.sh build-image' - sh './docker-build.sh build-apk' - archiveArtifacts 'docker-outputs/apk/release/*.apk' - } - } - } -} -``` - -#### GitLab CI - -```yaml -build_apk: - image: docker:20.10 - services: - - docker:20.10-dind - script: - - ./docker-build.sh build-image - - ./docker-build.sh build-apk - artifacts: - paths: - - docker-outputs/apk/release/*.apk -``` - -## 📊 Performance Optimization - -### Build Cache - -Use Docker build cache: - -```bash -# Build with cache mount -docker build \ - --cache-from govt-invoice-android:latest \ - -f Dockerfile.android \ - -t govt-invoice-android:latest . -``` - -### Layer Optimization - -The Dockerfile is optimized for caching: - -1. System packages (rarely change) -2. Android SDK (rarely change) -3. Node.js dependencies (change occasionally) -4. Source code (change frequently) - -### Resource Limits - -Limit Docker resources: - -```bash -docker run --rm \ - --memory=4g \ - --cpus=2 \ - govt-invoice-android:latest -``` - -## 🔒 Security Considerations - -### Keystore Security - -- Never commit keystore files to git -- Use `.docker-build/` directory (gitignored) -- Keystore files are mounted read-only in containers -- Cleanup removes all keystore files - -### Secrets Management - -For CI/CD, use encrypted secrets: - -- `RELEASE_KEYSTORE_BASE64`: Base64 encoded keystore -- `RELEASE_STORE_PASSWORD`: Keystore password -- `RELEASE_KEY_ALIAS`: Key alias -- `RELEASE_KEY_PASSWORD`: Key password - -## 📝 Contributing - -### Adding New Dependencies - -1. Update `package.json` -2. Rebuild Docker image -3. Test build process -4. Update documentation - -### Modifying Build Process - -1. Edit `Dockerfile.android` -2. Test locally with `./docker-build.sh` -3. Update GitHub Actions workflow -4. Update this documentation - -## 🆘 Support - -If you encounter issues: - -1. Check the [Troubleshooting](#troubleshooting) section -2. Review container logs -3. Verify Docker installation -4. Check file permissions -5. Create an issue with: - - Docker version - - Host OS - - Error logs - - Steps to reproduce - -## 📚 Additional Resources - -- [Docker Documentation](https://docs.docker.com/) -- [Android Developer Guide](https://developer.android.com/) -- [Capacitor Documentation](https://capacitorjs.com/) -- [Ionic Framework](https://ionicframework.com/) - ---- - -_This documentation is maintained as part of the Government Invoice Form project._ diff --git a/DOCKER_STRATEGIES.md b/DOCKER_STRATEGIES.md deleted file mode 100644 index 5340c43..0000000 --- a/DOCKER_STRATEGIES.md +++ /dev/null @@ -1,237 +0,0 @@ -# đŸŗ Docker Build Strategies for Government Invoice Form - -This document explains the different Docker strategies available for building Android APKs and when to use each approach. - -## 📋 Available Strategies - -### 1. 🚀 **Lightweight Docker Release** (Recommended for CI/CD) - -**File:** `.github/workflows/lite-docker-release-apk.yml` -**Trigger:** `lite-docker-release` label - -**✅ Pros:** - -- Uses pre-built images (much faster) -- Configurable strategy (build vs. pre-built) -- Optimized for repeated builds -- Minimal GitHub Actions runtime - -**âš ī¸ Cons:** - -- Requires initial image build -- Need to manage image updates - -**Best for:** Production releases, when you have a stable build environment - -### 2. 🔨 **Full Docker Release** (Complete but slower) - -**File:** `.github/workflows/docker-release-apk.yml` -**Trigger:** `docker-release` label - -**✅ Pros:** - -- Always builds fresh image -- No dependencies on pre-built images -- Guaranteed reproducible builds - -**âš ī¸ Cons:** - -- Takes 15-20 minutes per build -- Uses more GitHub Actions minutes -- Rebuilds everything each time - -**Best for:** When you need guaranteed fresh builds, testing new dependencies - -### 3. 🏠 **Local Development** - -**File:** `docker-build.sh` - -**✅ Pros:** - -- Full control over build process -- Can reuse images across builds -- Great for development and testing - -**Best for:** Local development, testing, initial setup - -## đŸŽ¯ Recommended Workflow - -### For Regular Releases (Recommended) - -1. **One-time setup:** Build the Docker image locally or in CI - - ```bash - ./docker-build.sh build-image - ``` - -2. **For releases:** Use the lightweight workflow - - Add `lite-docker-release` label to your PR - - Builds will be much faster (2-5 minutes vs 15-20 minutes) - -### For New Dependencies or Major Changes - -1. **Use full Docker workflow:** - - - Add `docker-release` label to your PR - - This ensures all dependencies are fresh - -2. **Update local image:** - ```bash - ./docker-build.sh build-image - ``` - -## âš™ī¸ Configuration Options - -### Lightweight Docker Release Configuration - -Edit the environment variables in `.github/workflows/lite-docker-release-apk.yml`: - -```yaml -env: - USE_PREBUILT_IMAGE: true # Use existing images - DOCKER_IMAGE: "govt-invoice-android" - DOCKER_TAG: "latest" - # DOCKER_REGISTRY: "ghcr.io/anisharma07" # Uncomment for registry -``` - -**Options:** - -- `USE_PREBUILT_IMAGE: true` - Use existing images (fast) -- `USE_PREBUILT_IMAGE: false` - Build on demand (slower but fresh) - -### Image Registry Setup (Optional) - -To use a container registry for shared images: - -1. **Push to GitHub Container Registry:** - - ```bash - # Build and tag - ./docker-build.sh build-image - docker tag govt-invoice-android:latest ghcr.io/anisharma07/govt-invoice-android:latest - - # Login and push - echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u anisharma07 --password-stdin - docker push ghcr.io/anisharma07/govt-invoice-android:latest - ``` - -2. **Update workflow:** - ```yaml - env: - USE_PREBUILT_IMAGE: true - DOCKER_REGISTRY: "ghcr.io/anisharma07" - DOCKER_IMAGE: "govt-invoice-android" - ``` - -## 🔧 Local Commands - -### Check if image exists - -```bash -./docker-build.sh check-image -``` - -### Build image (one-time, takes 15-20 minutes) - -```bash -./docker-build.sh build-image -``` - -### Build APK (fast if image exists) - -```bash -./docker-build.sh build-apk -``` - -### Development environment - -```bash -./docker-build.sh dev -``` - -## 📊 Performance Comparison - -| Strategy | First Build | Subsequent Builds | GitHub Actions Time | -| --------------- | ----------- | ----------------- | ------------------- | -| **Lightweight** | 15-20 min | 2-5 min | ⭐ Low | -| **Full Docker** | 15-20 min | 15-20 min | ❌ High | -| **Local** | 15-20 min | 2-5 min | N/A | - -## đŸ› ī¸ Troubleshooting - -### "Docker image not found" - -```bash -# Check if image exists -./docker-build.sh check-image - -# Build if needed -./docker-build.sh build-image -``` - -### "APK build failed" - -```bash -# Check Docker logs -docker logs - -# Rebuild image -./docker-build.sh clean -./docker-build.sh build-image -``` - -### GitHub Actions fails to find image - -1. Set `USE_PREBUILT_IMAGE: false` in the workflow -2. Or build and push to a registry - -## 💡 Tips for Optimal Performance - -### 1. Use Lightweight Strategy for Regular Releases - -- Build image once locally or in CI -- Use `lite-docker-release` label for subsequent releases -- 4x faster than full rebuilds - -### 2. Update Images Periodically - -- Rebuild image when dependencies change -- Update monthly for security patches -- Use full Docker strategy after major updates - -### 3. Local Development - -- Build image once: `./docker-build.sh build-image` -- Reuse for multiple APK builds: `./docker-build.sh build-apk` -- Clean when needed: `./docker-build.sh clean` - -### 4. CI/CD Best Practices - -- Use lightweight strategy for feature releases -- Use full strategy for dependency updates -- Consider using container registry for team sharing - -## 🚀 Quick Start - -**For immediate APK building:** - -```bash -# 1. Check setup -./test-docker-setup.sh - -# 2. Build image (one-time) -./docker-build.sh build-image - -# 3. Build APK (repeatable) -./docker-build.sh build-apk -``` - -**For CI/CD releases:** - -1. Build image locally once -2. Use `lite-docker-release` label on PRs -3. Enjoy fast builds! 🚀 - ---- - -_Choose the strategy that best fits your needs. For most users, the lightweight strategy provides the best balance of speed and reliability._ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2f131f8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,75 +0,0 @@ -# Multi-stage build for Ionic React application - -# Development stage -FROM node:18-alpine AS development -WORKDIR /app - -# Install build dependencies for native modules -RUN apk add --no-cache \ - python3 \ - make \ - g++ \ - vips-dev \ - libc6-compat - -# Copy package files -COPY package*.json ./ -COPY ionic.config.json ./ - -# Install dependencies -RUN npm install - -# Copy source code -COPY . . - -# Expose development port -EXPOSE 5173 - -# Start development server -CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] - -# Build stage -FROM node:18-alpine AS build -WORKDIR /app - -# Install build dependencies for native modules -RUN apk add --no-cache \ - python3 \ - make \ - g++ \ - vips-dev \ - libc6-compat - -# Copy package files -COPY package*.json ./ -COPY ionic.config.json ./ -COPY tsconfig*.json ./ -COPY vite.config.ts ./ -COPY capacitor.config.ts ./ -COPY pwa-assets.config.ts ./ - -# Install dependencies (including dev dependencies for build) -RUN npm ci - -# Copy source code -COPY src/ ./src/ -COPY public/ ./public/ -COPY index.html ./ - -# Build the application -RUN npm run build - -# Production stage -FROM nginx:alpine AS production - -# Copy built application from build stage -COPY --from=build /app/dist /usr/share/nginx/html - -# Copy custom nginx configuration if needed -COPY nginx.conf /etc/nginx/conf.d/default.conf - -# Expose port 80 -EXPOSE 80 - -# Start nginx -CMD ["nginx", "-g", "daemon off;"] diff --git a/Dockerfile.android b/Dockerfile.android deleted file mode 100644 index de705f9..0000000 --- a/Dockerfile.android +++ /dev/null @@ -1,146 +0,0 @@ -# Multi-stage Dockerfile for Android APK Build -# This Dockerfile creates a complete Android build environment for Ionic/Capacitor apps - -FROM ubuntu:22.04 AS android-builder - -# Prevent interactive prompts during package installation -ENV DEBIAN_FRONTEND=noninteractive -ENV TZ=UTC - -# Set Android environment variables -ENV ANDROID_HOME=/opt/android-sdk -ENV ANDROID_SDK_ROOT=/opt/android-sdk -ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/build-tools/34.0.0 -ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 - -# Install system dependencies -RUN apt-get update && apt-get install -y \ - curl \ - wget \ - unzip \ - git \ - build-essential \ - python3 \ - python3-pip \ - openjdk-17-jdk \ - gradle \ - && rm -rf /var/lib/apt/lists/* - -# Install Node.js 20 -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ - && apt-get install -y nodejs - -# Create Android SDK directory -RUN mkdir -p ${ANDROID_HOME}/cmdline-tools - -# Download and install Android Command Line Tools -RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -O /tmp/cmdline-tools.zip \ - && unzip -q /tmp/cmdline-tools.zip -d ${ANDROID_HOME}/cmdline-tools \ - && mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest \ - && rm /tmp/cmdline-tools.zip - -# Accept Android SDK licenses -RUN yes | sdkmanager --licenses - -# Install Android SDK components -RUN sdkmanager \ - "platform-tools" \ - "platforms;android-34" \ - "build-tools;34.0.0" \ - "extras;android;m2repository" \ - "extras;google;m2repository" - -# Install Capacitor CLI globally -RUN npm install -g @capacitor/cli @ionic/cli - -# Set working directory -WORKDIR /app - -# Copy package files first for better caching -COPY package*.json ./ -COPY ionic.config.json ./ -COPY capacitor.config.ts ./ -COPY tsconfig*.json ./ -COPY vite.config.ts ./ - -# Install Node.js dependencies -RUN npm ci - -# Copy source code -COPY src/ ./src/ -COPY public/ ./public/ -COPY index.html ./ - -# Build the web application -RUN npm run build - -# Copy Capacitor Android project -COPY android/ ./android/ - -# Sync Capacitor -RUN npx cap sync android - -# Create build script -RUN echo '#!/bin/bash\n\ -set -e\n\ -echo "🚀 Starting Android APK build process..."\n\ -\n\ -# Navigate to android directory\n\ -cd /app/android\n\ -\n\ -# Make gradlew executable\n\ -chmod +x gradlew\n\ -\n\ -# Clean previous builds\n\ -./gradlew clean\n\ -\n\ -# Generate codegen artifacts (if needed)\n\ -echo "🔧 Generating React Native Codegen artifacts..."\n\ -./gradlew generateCodegenArtifactsFromSchema --stacktrace || echo "âš ī¸ Codegen generation completed with warnings"\n\ -\n\ -# Build release APK\n\ -echo "🔨 Building release APK..."\n\ -./gradlew assembleRelease --stacktrace\n\ -\n\ -# Verify APK was created\n\ -if [ -f "app/build/outputs/apk/release/app-release.apk" ]; then\n\ - echo "✅ APK built successfully!"\n\ - ls -la app/build/outputs/apk/release/\n\ -else\n\ - echo "❌ APK build failed!"\n\ - exit 1\n\ -fi\n\ -' > /build-apk.sh && chmod +x /build-apk.sh - -# Default command -CMD ["/build-apk.sh"] - -# Development stage with volume mounts -FROM android-builder AS android-dev - -# Install additional development tools -RUN apt-get update && apt-get install -y \ - vim \ - nano \ - htop \ - && rm -rf /var/lib/apt/lists/* - -# Create entrypoint for development -RUN echo '#!/bin/bash\n\ -echo "🔧 Android Development Environment Ready!"\n\ -echo "📍 Android SDK: $ANDROID_HOME"\n\ -echo "📍 Java Home: $JAVA_HOME"\n\ -echo "📍 Node Version: $(node --version)"\n\ -echo "📍 npm Version: $(npm --version)"\n\ -echo "📍 Capacitor Version: $(npx cap --version)"\n\ -echo ""\n\ -echo "Available commands:"\n\ -echo " /build-apk.sh - Build release APK"\n\ -echo " npm run dev - Start development server"\n\ -echo " npx cap run android - Run on Android device/emulator"\n\ -echo ""\n\ -exec "$@"\n\ -' > /entrypoint.sh && chmod +x /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] -CMD ["bash"] diff --git a/Dockerfile.full b/Dockerfile.full deleted file mode 100644 index 4485ad1..0000000 --- a/Dockerfile.full +++ /dev/null @@ -1,59 +0,0 @@ -# Alternative Dockerfile using full Node.js image (more stable for complex builds) - -# Development stage -FROM node:18 AS development -WORKDIR /app - -# Copy package files -COPY package*.json ./ -COPY ionic.config.json ./ - -# Install dependencies -RUN npm install - -# Copy source code -COPY . . - -# Expose development port -EXPOSE 5173 - -# Start development server -CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] - -# Build stage -FROM node:18 AS build -WORKDIR /app - -# Copy package files -COPY package*.json ./ -COPY ionic.config.json ./ -COPY tsconfig*.json ./ -COPY vite.config.ts ./ -COPY capacitor.config.ts ./ -COPY pwa-assets.config.ts ./ - -# Install dependencies (including dev dependencies for build) -RUN npm ci - -# Copy source code -COPY src/ ./src/ -COPY public/ ./public/ -COPY index.html ./ - -# Build the application -RUN npm run build - -# Production stage -FROM nginx:alpine AS production - -# Copy built application from build stage -COPY --from=build /app/dist /usr/share/nginx/html - -# Copy custom nginx configuration -COPY nginx.conf /etc/nginx/conf.d/default.conf - -# Expose port 80 -EXPOSE 80 - -# Start nginx -CMD ["nginx", "-g", "daemon off;"] diff --git a/INVOICE_MODULE_IMPLEMENTATION.md b/INVOICE_MODULE_IMPLEMENTATION.md deleted file mode 100644 index a5ed472..0000000 --- a/INVOICE_MODULE_IMPLEMENTATION.md +++ /dev/null @@ -1,154 +0,0 @@ -# Invoice Module Implementation - -## Overview - -I have successfully created a comprehensive invoice module for the Government Invoice Form application. This implementation provides a complete form-based interface for managing invoice data with proper mapping to spreadsheet cells. - -## Files Created/Modified - -### 1. Invoice Module (`src/components/socialcalc/modules/invoice.js`) - -- **Purpose**: Core module for handling invoice data operations with SocialCalc spreadsheet -- **Key Functions**: - - `getInvoiceCoordinates()`: Returns mapping of form fields to spreadsheet cell coordinates - - `addInvoiceData(invoiceData)`: Saves form data to spreadsheet cells - - `getInvoiceData()`: Retrieves existing data from spreadsheet cells - - `clearInvoiceData()`: Clears all invoice data from spreadsheet - -### 2. Invoice Form Component (`src/components/InvoiceForm.tsx`) - -- **Purpose**: React component providing a user-friendly form interface -- **Features**: - - Modal-based form with organized sections - - **Reverse Accessibility**: Automatically loads existing data from spreadsheet cells when opened - - **13-Item Limit**: Maximum 13 items enforced with visual indicators and warnings - - Real-time total calculation - - Dynamic item management (add/remove items with count display) - - Data validation and error handling - - Enhanced data loading with comprehensive logging - - Responsive design for mobile and desktop - - Item counter showing current/maximum items (e.g., "Items (3/13)") - - Add Item button shows count and disables at maximum - -### 3. CSS Styling (`src/components/InvoiceForm.css`) - -- **Purpose**: Responsive styling for the invoice form -- **Features**: - - Mobile-first responsive design - - Dark theme support - - Smooth animations - - Professional form styling - -### 4. Home Page Integration (`src/pages/Home.tsx`) - -- **Modifications**: - - Added invoice form import - - Added state management for form visibility - - Added floating action button (FAB) in bottom right corner for invoice editing - - Integrated invoice form modal - - Added responsive FAB styling with hover effects - -## Cell Mapping Structure - -### Bill To Section - -- **Name**: C5 -- **Street Address**: C6 -- **City, State, ZIP**: C7 -- **Phone**: C8 -- **Email**: C9 - -### From Section - -- **Name**: C12 -- **Street Address**: C13 -- **City, State, ZIP**: C14 -- **Phone**: C15 -- **Email**: C16 - -### Invoice Information - -- **Invoice Number**: C18 -- **Date**: D20 - -### Items Section - -- **Description Column**: C (rows 23-35) -- **Amount Column**: F (rows 23-35) -- **Total Rows**: 13 items maximum -- **Total Sum**: F36 (automatically calculated) - -## Key Features - -### 1. Bidirectional Data Flow - -- **Save to Spreadsheet**: Form data is properly mapped and saved to correct cells -- **Load from Spreadsheet**: Existing spreadsheet data is retrieved and displayed in form -- **Real-time Updates**: Changes are reflected immediately -- **Enhanced Reverse Accessibility**: Form automatically loads existing data when opened with comprehensive error handling - -### 2. Form Functionality - -- **Dynamic Items**: Add/remove invoice items dynamically (maximum 13 items) -- **Auto-calculation**: Total automatically updates when item amounts change -- **Validation**: Basic validation for required fields -- **Date Handling**: Auto-populates with current date -- **Item Limit Enforcement**: Visual indicators and warnings for 13-item maximum -- **Smart Data Loading**: Handles edge cases and missing data gracefully - -### 3. User Experience - -- **Modal Interface**: Clean modal popup for better UX -- **Responsive Design**: Works on both desktop and mobile -- **Toast Notifications**: Success/error feedback with detailed messages -- **Refresh Button**: Reload data from spreadsheet with status updates -- **Clear All**: Reset form and spreadsheet data -- **Item Counters**: Visual display of current items vs maximum (e.g., "Items (3/13)") -- **Smart Button States**: Add Item button shows count and disables when at limit - -### 4. Error Handling - -- **SocialCalc Integration**: Proper error handling for spreadsheet operations -- **User Feedback**: Clear error messages and success notifications -- **Fallback Handling**: Graceful degradation when data is missing - -## Usage Instructions - -1. **Opening the Form**: Click the floating action button (FAB) in the bottom right corner -2. **Filling Data**: Complete the Bill To, From, Invoice Information, and Items sections -3. **Managing Items**: Use "Add Item" button to add rows, trash icon to remove -4. **Saving**: Click "Save Invoice" to write data to spreadsheet -5. **Loading Existing Data**: Form automatically loads existing data when opened -6. **Refreshing**: Use refresh button to reload current spreadsheet data -7. **Clearing**: Use "Clear All" to reset both form and spreadsheet - -## Technical Implementation - -### SocialCalc Integration - -- Uses existing SocialCalc workbook control system -- Generates proper SocialCalc commands for cell updates -- Handles both text and numeric data types -- Implements proper error handling and logging - -### React Integration - -- TypeScript interfaces for type safety -- Ionic React components for consistent UI -- State management with React hooks -- Effect hooks for data loading and calculations - -### Data Persistence - -- Data is saved directly to the spreadsheet cells -- Auto-save functionality from existing Home component -- Works with existing file storage system - -## Testing - -- ✅ Application builds successfully -- ✅ Development server starts without errors -- ✅ TypeScript compilation passes -- ✅ All imports and dependencies resolved - -The invoice module is now fully functional and ready for use. Users can access it via the edit button in the toolbar, fill out invoice information, and have it automatically mapped to the correct spreadsheet cells with full bidirectional data synchronization. diff --git a/audit.md b/audit.md deleted file mode 100644 index 9ded9e9..0000000 --- a/audit.md +++ /dev/null @@ -1,128 +0,0 @@ -# Code Audit Report - -This document contains a comprehensive audit of the codebase after removing all Starknet and server features. The app is now fully local-only. - -## Dead Code Analysis - -### 1. Empty Files - -- `src/services/camera-service.ts` - **COMPLETELY EMPTY** - Can be deleted - -### 2. Commented-Out Dead Code - -The following commented-out imports are remnants from the blockchain/server removal: - -#### SettingsPage.tsx (Line 81) - -```typescript -// import { useAccount, useConnect, useDisconnect } from "@starknet-react/core"; -``` - -#### Home.tsx (Line 51) - -```typescript -// import WalletConnection from "../components/wallet/WalletConnection"; -``` - -### 3. Duplicate Helper Functions - -Helper functions are duplicated between `utils/helper.ts` and `components/Menu/Menu.tsx`: - -#### Duplicated in Menu.tsx (Lines 765-780): - -- `generateInvoiceFilename()` - Should use the one from `utils/helper.ts` -- `selectInputText()` - Should use the one from `utils/helper.ts` - -**Recommendation**: Import from `utils/helper.ts` instead of redefining - -### 4. Unused Dependencies Analysis - -#### From package.json, potential unused dependencies: - -- `@capacitor/camera` - May be unused since `camera-service.ts` is empty -- `@capacitor/filesystem` - Used in LocalStorage.ts, so it's needed -- `@capacitor/share` - Used in export functionality, so it's needed -- `xlsx` - Used in export services, so it's needed - -## Used Code Analysis - -### Export Services (All Active) - -✅ **In Use**: - -- `exportAsCsv.ts` - Used in Menu.tsx for CSV export -- `exportAsPdf.ts` - Used in Menu.tsx for PDF export -- `exportAllAsPdf.ts` - Used in Menu.tsx for multi-file PDF export -- `exportAllSheetsAsPdf.ts` - Used in Menu.tsx and MenuDialogs.tsx - -### Storage Services (All Active) - -✅ **In Use**: - -- `components/Storage/LocalStorage.ts` - Used throughout the app for local file management -- `utils/offlineStorage.ts` - Used by PWADemo.tsx for offline storage demo - -### Data Files (All Active) - -✅ **In Use**: - -- `app-data.ts` - Used by Files.tsx, FilesPage.tsx, Home.tsx, FileOptions.tsx, Menu.tsx -- `app-data-new.ts` - Purpose unclear, not found in search results - **POTENTIAL DEAD CODE** - -### Helper Utilities (Mostly Used) - -✅ **In Use**: - -- `generateInvoiceFilename()` - Used in Menu.tsx, MenuDialogs.tsx, Home.tsx -- `selectInputText()` - Used in Menu.tsx, MenuDialogs.tsx -- `isDefaultFileEmpty()` - Used in Home.tsx - -### PWA Components (All Active) - -✅ **In Use**: - -- `PWADemo.tsx` - Used in SettingsPage.tsx -- `PWAUpdatePrompt.tsx` - Used in App.tsx -- `OfflineIndicator.tsx` - Used in App.tsx -- `usePWA.ts` - Used in App.tsx and PWADemo.tsx - -## Recommendations - -### Immediate Actions: - -1. **Delete** `src/services/camera-service.ts` (empty file) -2. **Remove** commented blockchain imports from SettingsPage.tsx and Home.tsx -3. **Investigate** `app-data-new.ts` - appears unused -4. **Refactor** Menu.tsx to import helper functions from `utils/helper.ts` instead of duplicating - -### Code Quality Improvements: - -1. Remove duplicate helper function definitions in Menu.tsx -2. Clean up commented-out wallet/blockchain references -3. Consider removing `@capacitor/camera` dependency if camera functionality is not needed - -### Files That Could Be Simplified: - -- SettingsPage.tsx has many commented-out blockchain sections that could be cleaned up -- PWADemo.tsx has commented-out push notification code that could be removed - -## Summary - -- **1 empty file** to delete ✅ **REMOVED** - `camera-service.ts` deleted -- **2 files** with commented blockchain imports to clean up -- **2 helper functions** duplicated unnecessarily -- **1 data file** potentially unused (app-data-new.ts) -- **1 dependency** potentially unused (@capacitor/camera) -- **1 server feature** ✅ **REMOVED** - "Export as PDF via Server" button and related functionality removed - -## Recent Changes (August 8, 2025) - -✅ **COMPLETED**: Removed "Export as PDF via Server" button and all related server functionality: - -- Removed server PDF button from Menu.tsx -- Removed `doGenerateServerPDF` function -- Removed all server PDF state variables and loading states -- Cleaned up MenuDialogs.tsx to remove server PDF dialog and props -- Removed unused imports (`server` icon, `cloudUpload` for server) - -Overall, the codebase is in excellent shape after the blockchain/server removal. Most services and utilities are actively used. The main cleanup needed is removing the empty camera service file and duplicate helper functions. diff --git a/docker-build.sh b/docker-build.sh deleted file mode 100755 index 931eaff..0000000 --- a/docker-build.sh +++ /dev/null @@ -1,274 +0,0 @@ -#!/bin/bash - -# Government Invoice Form - Docker Build Helper Script -# This script helps you build and test the Android APK using Docker locally - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -# Print colored output -print_info() { - echo -e "${BLUE}â„šī¸ $1${NC}" -} - -print_success() { - echo -e "${GREEN}✅ $1${NC}" -} - -print_warning() { - echo -e "${YELLOW}âš ī¸ $1${NC}" -} - -print_error() { - echo -e "${RED}❌ $1${NC}" -} - -# Function to show usage -show_usage() { - echo "Government Invoice Form - Docker Build Helper" - echo "" - echo "Usage: $0 [COMMAND] [OPTIONS]" - echo "" - echo "Commands:" - echo " build-image Build the Android Docker image" - echo " build-apk Build APK using Docker (requires keystore setup)" - echo " dev Start development environment" - echo " web-dev Start web development server" - echo " clean Clean Docker images and containers" - echo " setup-keystore Setup keystore for release builds" - echo " check-image Check if Docker image exists" - echo " help Show this help message" - echo "" - echo "Examples:" - echo " $0 build-image # Build Docker image" - echo " $0 build-apk # Build release APK" - echo " $0 dev # Start development environment" - echo " $0 web-dev # Start web development server" - echo " $0 check-image # Check if image exists" - echo "" -} - -# Function to check if Docker is installed -check_docker() { - if ! command -v docker &> /dev/null; then - print_error "Docker is not installed. Please install Docker first." - echo "Visit: https://docs.docker.com/get-docker/" - exit 1 - fi - - if ! command -v docker-compose &> /dev/null; then - print_warning "docker-compose not found. Using 'docker compose' instead." - fi -} - -# Function to build Docker image -build_image() { - print_info "Building Android Docker image..." - - docker build -f Dockerfile.android -t govt-invoice-android:latest . \ - --progress=plain \ - --no-cache - - print_success "Docker image built successfully!" - docker images govt-invoice-android:latest -} - -# Function to setup keystore -setup_keystore() { - print_info "Setting up keystore for release builds..." - - if [ ! -d ".docker-build" ]; then - mkdir -p .docker-build - fi - - echo "" - print_warning "You need to provide the following for release builds:" - echo "1. Keystore file (release-key.jks)" - echo "2. Keystore properties (store password, key alias, key password)" - echo "" - - # Check if keystore file exists - if [ ! -f ".docker-build/release-key.jks" ]; then - print_info "Please place your keystore file at: .docker-build/release-key.jks" - read -p "Press Enter when you've placed the keystore file..." - fi - - # Create keystore.properties if it doesn't exist - if [ ! -f ".docker-build/keystore.properties" ]; then - print_info "Creating keystore.properties..." - - read -p "Enter store password: " -s STORE_PASSWORD - echo "" - read -p "Enter key alias: " KEY_ALIAS - read -p "Enter key password: " -s KEY_PASSWORD - echo "" - - cat > .docker-build/keystore.properties << EOF -storeFile=release-key.jks -storePassword=$STORE_PASSWORD -keyAlias=$KEY_ALIAS -keyPassword=$KEY_PASSWORD -EOF - - print_success "Keystore properties created!" - else - print_success "Keystore properties already exist!" - fi -} - -# Function to build APK -build_apk() { - print_info "Building APK using Docker..." - - # Check if keystore is setup - if [ ! -f ".docker-build/release-key.jks" ] || [ ! -f ".docker-build/keystore.properties" ]; then - print_warning "Keystore not found. Setting up keystore first..." - setup_keystore - fi - - # Create output directory - mkdir -p ./docker-outputs - - print_info "Starting Docker container to build APK..." - - # Run Docker container to build APK - docker run --rm \ - -v $(pwd)/.docker-build/release-key.jks:/app/android/app/release-key.jks:ro \ - -v $(pwd)/.docker-build/keystore.properties:/app/android/keystore.properties:ro \ - -v $(pwd)/docker-outputs:/app/android/app/build/outputs \ - --name apk-builder-$(date +%s) \ - govt-invoice-android:latest - - # Verify APK was created - if [ -f "docker-outputs/apk/release/app-release.apk" ]; then - # Get current version from package.json - VERSION=$(node -p "require('./package.json').version" 2>/dev/null || echo "unknown") - - # Copy and rename APK - cp docker-outputs/apk/release/app-release.apk docker-outputs/apk/release/Govt-Invoice-Docker-v${VERSION}.apk - - # Get APK info - APK_SIZE=$(du -h docker-outputs/apk/release/Govt-Invoice-Docker-v${VERSION}.apk | cut -f1) - - print_success "APK built successfully!" - echo "📁 APK Location: docker-outputs/apk/release/Govt-Invoice-Docker-v${VERSION}.apk" - echo "📊 APK Size: $APK_SIZE" - else - print_error "APK build failed!" - exit 1 - fi -} - -# Function to start development environment -start_dev() { - print_info "Starting development environment..." - - if command -v docker-compose &> /dev/null; then - docker-compose -f docker-compose.android.yml up android-dev - else - docker compose -f docker-compose.android.yml up android-dev - fi -} - -# Function to start web development -start_web_dev() { - print_info "Starting web development server..." - - if command -v docker-compose &> /dev/null; then - docker-compose -f docker-compose.android.yml up web-dev - else - docker compose -f docker-compose.android.yml up web-dev - fi -} - -# Function to check if Docker image exists -check_image() { - print_info "Checking for Docker image..." - - if docker images govt-invoice-android:latest | grep -q govt-invoice-android; then - print_success "Docker image exists!" - docker images govt-invoice-android:latest - - # Show image details - IMAGE_SIZE=$(docker images govt-invoice-android:latest --format "table {{.Size}}" | tail -n +2) - IMAGE_CREATED=$(docker images govt-invoice-android:latest --format "table {{.CreatedAt}}" | tail -n +2) - - echo "📊 Image Size: $IMAGE_SIZE" - echo "📅 Created: $IMAGE_CREATED" - - print_success "Ready for APK building! Use: $0 build-apk" - else - print_warning "Docker image not found!" - echo "🔨 Build it with: $0 build-image" - echo "âąī¸ First build takes ~15-20 minutes" - echo "🚀 Subsequent builds are much faster" - fi -} - -# Function to clean Docker resources -clean_docker() { - print_info "Cleaning Docker resources..." - - # Remove containers - docker ps -a | grep govt-invoice | awk '{print $1}' | xargs -r docker rm -f - - # Remove images - docker images | grep govt-invoice-android | awk '{print $3}' | xargs -r docker rmi -f - - # Clean build outputs - rm -rf docker-outputs - - # Prune system - docker system prune -f - - print_success "Docker cleanup completed!" -} - -# Main script logic -main() { - # Check if Docker is available - check_docker - - # Handle commands - case "${1:-help}" in - "build-image") - build_image - ;; - "build-apk") - build_apk - ;; - "dev") - start_dev - ;; - "web-dev") - start_web_dev - ;; - "check-image") - check_image - ;; - "clean") - clean_docker - ;; - "setup-keystore") - setup_keystore - ;; - "help"|"--help"|"-h") - show_usage - ;; - *) - print_error "Unknown command: $1" - echo "" - show_usage - exit 1 - ;; - esac -} - -# Run main function with all arguments -main "$@" diff --git a/docker-compose.android.yml b/docker-compose.android.yml deleted file mode 100644 index 5dd9b1e..0000000 --- a/docker-compose.android.yml +++ /dev/null @@ -1,77 +0,0 @@ -# Docker Compose configuration for Government Invoice Form -version: "3.8" - -services: - # Web development service - web-dev: - build: - context: . - dockerfile: Dockerfile - target: development - ports: - - "5173:5173" - volumes: - - .:/app - - /app/node_modules - environment: - - NODE_ENV=development - networks: - - app-network - - # Web production service - web-prod: - build: - context: . - dockerfile: Dockerfile - target: production - ports: - - "80:80" - networks: - - app-network - - # Android build service - android-builder: - build: - context: . - dockerfile: Dockerfile.android - target: android-builder - volumes: - - ./android/app/build/outputs:/app/android/app/build/outputs - - android-cache:/app/android/.gradle - environment: - - ANDROID_HOME=/opt/android-sdk - - JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 - networks: - - app-network - - # Android development environment - android-dev: - build: - context: . - dockerfile: Dockerfile.android - target: android-dev - volumes: - - .:/app - - /app/node_modules - - android-cache:/app/android/.gradle - - android-sdk:/opt/android-sdk - environment: - - ANDROID_HOME=/opt/android-sdk - - JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 - stdin_open: true - tty: true - networks: - - app-network - ports: - - "5173:5173" # For web dev server - - "8080:8080" # For Android debugging - -volumes: - android-cache: - driver: local - android-sdk: - driver: local - -networks: - app-network: - driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 77c0524..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,96 +0,0 @@ -version: "3.8" - -services: - # Development environment (Alpine-based) - ionic-dev: - build: - context: . - dockerfile: Dockerfile - target: development - container_name: ionic-govt-billing-dev - ports: - - "5173:5173" - volumes: - - .:/app - - /app/node_modules - env_file: - - .env - environment: - - NODE_ENV=development - - VITE_DEV_SERVER_HOST=0.0.0.0 - profiles: - - dev - stdin_open: true - tty: true - - # Development environment (Full Node.js - more stable) - ionic-dev-full: - build: - context: . - dockerfile: Dockerfile.full - target: development - container_name: ionic-govt-billing-dev-full - ports: - - "5173:5173" - volumes: - - .:/app - - /app/node_modules - env_file: - - .env - environment: - - NODE_ENV=development - - VITE_DEV_SERVER_HOST=0.0.0.0 - profiles: - - dev-full - stdin_open: true - tty: true - - # Production environment (Alpine-based) - ionic-prod: - build: - context: . - dockerfile: Dockerfile - target: production - container_name: ionic-govt-billing-prod - ports: - - "80:80" - env_file: - - .env - environment: - - NODE_ENV=production - profiles: - - prod - restart: unless-stopped - - # Production environment (Full Node.js - more stable) - ionic-prod-full: - build: - context: . - dockerfile: Dockerfile.full - target: production - container_name: ionic-govt-billing-prod-full - ports: - - "80:80" - env_file: - - .env - environment: - - NODE_ENV=production - profiles: - - prod-full - restart: unless-stopped - - # Build only service (Alpine-based) - ionic-build: - build: - context: . - dockerfile: Dockerfile - target: build - container_name: ionic-govt-billing-build - volumes: - - ./dist:/app/dist - profiles: - - build - -networks: - default: - name: ionic-govt-billing-network diff --git a/test-docker-setup.sh b/test-docker-setup.sh deleted file mode 100755 index b310b65..0000000 --- a/test-docker-setup.sh +++ /dev/null @@ -1,252 +0,0 @@ -#!/bin/bash - -# Docker Setup Test Script -# This script tests the Docker-based Android build setup - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -print_info() { - echo -e "${BLUE}â„šī¸ $1${NC}" -} - -print_success() { - echo -e "${GREEN}✅ $1${NC}" -} - -print_warning() { - echo -e "${YELLOW}âš ī¸ $1${NC}" -} - -print_error() { - echo -e "${RED}❌ $1${NC}" -} - -print_header() { - echo "" - echo "===========================================" - echo "đŸŗ Docker Setup Test" - echo "===========================================" - echo "" -} - -# Test Docker installation -test_docker() { - print_info "Testing Docker installation..." - - if command -v docker &> /dev/null; then - DOCKER_VERSION=$(docker --version) - print_success "Docker found: $DOCKER_VERSION" - else - print_error "Docker not found! Please install Docker first." - return 1 - fi - - # Test Docker daemon - if docker info &> /dev/null; then - print_success "Docker daemon is running" - else - print_error "Docker daemon is not running!" - return 1 - fi -} - -# Test Docker Compose -test_docker_compose() { - print_info "Testing Docker Compose..." - - if command -v docker-compose &> /dev/null; then - COMPOSE_VERSION=$(docker-compose --version) - print_success "Docker Compose found: $COMPOSE_VERSION" - elif docker compose version &> /dev/null; then - COMPOSE_VERSION=$(docker compose version) - print_success "Docker Compose (plugin) found: $COMPOSE_VERSION" - else - print_warning "Docker Compose not found, but not required for basic builds" - fi -} - -# Test Node.js in Docker -test_node_docker() { - print_info "Testing Node.js in Docker..." - - NODE_VERSION=$(docker run --rm node:20-alpine node --version 2>/dev/null || echo "failed") - if [ "$NODE_VERSION" != "failed" ]; then - print_success "Node.js Docker image works: $NODE_VERSION" - else - print_error "Failed to run Node.js Docker image" - return 1 - fi -} - -# Test building the Android Docker image -test_android_image_build() { - print_info "Testing Android Docker image build..." - print_warning "This will take several minutes on first run..." - - # Build only the first stage to save time - if docker build -f Dockerfile.android --target android-builder -t govt-invoice-android-test:latest . &> /dev/null; then - print_success "Android Docker image builds successfully" - - # Clean up test image - docker rmi govt-invoice-android-test:latest &> /dev/null || true - else - print_error "Android Docker image build failed" - print_info "Run 'docker build -f Dockerfile.android --target android-builder -t test .' to see detailed error" - return 1 - fi -} - -# Test project structure -test_project_structure() { - print_info "Testing project structure..." - - REQUIRED_FILES=( - "package.json" - "android/app/build.gradle" - "capacitor.config.ts" - "Dockerfile.android" - "docker-build.sh" - ".dockerignore" - ) - - for file in "${REQUIRED_FILES[@]}"; do - if [ -f "$file" ]; then - print_success "Found: $file" - else - print_error "Missing: $file" - return 1 - fi - done -} - -# Test helper script -test_helper_script() { - print_info "Testing docker-build.sh helper script..." - - if [ -x "docker-build.sh" ]; then - print_success "docker-build.sh is executable" - - # Test help command - if ./docker-build.sh help &> /dev/null; then - print_success "docker-build.sh help command works" - else - print_error "docker-build.sh help command failed" - return 1 - fi - else - print_error "docker-build.sh is not executable" - print_info "Run: chmod +x docker-build.sh" - return 1 - fi -} - -# Test workflow file -test_workflow() { - print_info "Testing GitHub Actions workflow..." - - WORKFLOW_FILE=".github/workflows/docker-release-apk.yml" - if [ -f "$WORKFLOW_FILE" ]; then - print_success "Docker release workflow found" - - # Basic syntax check - if grep -q "docker-release" "$WORKFLOW_FILE"; then - print_success "Workflow has correct trigger label" - else - print_error "Workflow missing docker-release trigger" - return 1 - fi - else - print_error "Docker release workflow not found" - return 1 - fi -} - -# Main test function -run_tests() { - print_header - - TESTS=( - "test_docker" - "test_docker_compose" - "test_project_structure" - "test_helper_script" - "test_workflow" - "test_node_docker" - ) - - # Add comprehensive test if --full flag is passed - if [ "$1" = "--full" ]; then - TESTS+=("test_android_image_build") - print_warning "Running full tests including Android image build (this will take a while)..." - fi - - PASSED=0 - TOTAL=${#TESTS[@]} - - for test in "${TESTS[@]}"; do - echo "" - if $test; then - ((PASSED++)) - fi - done - - echo "" - echo "===========================================" - echo "📊 Test Results" - echo "===========================================" - print_info "Passed: $PASSED/$TOTAL tests" - - if [ $PASSED -eq $TOTAL ]; then - print_success "All tests passed! 🎉" - echo "" - print_info "Next steps:" - echo "1. ./docker-build.sh build-image # Build Android Docker image" - echo "2. ./docker-build.sh setup-keystore # Setup keystore for release builds" - echo "3. ./docker-build.sh build-apk # Build APK using Docker" - return 0 - else - print_error "Some tests failed. Please fix the issues above." - return 1 - fi -} - -# Show usage -show_usage() { - echo "Docker Setup Test Script" - echo "" - echo "Usage: $0 [OPTIONS]" - echo "" - echo "Options:" - echo " --full Run comprehensive tests including Docker image build" - echo " --help Show this help message" - echo "" - echo "Examples:" - echo " $0 # Run basic tests" - echo " $0 --full # Run all tests including image build" -} - -# Handle command line arguments -case "${1:-}" in - "--help"|"-h") - show_usage - exit 0 - ;; - "--full") - run_tests --full - ;; - "") - run_tests - ;; - *) - print_error "Unknown option: $1" - show_usage - exit 1 - ;; -esac diff --git a/test1.txt b/test1.txt deleted file mode 100644 index 1941a17..0000000 --- a/test1.txt +++ /dev/null @@ -1 +0,0 @@ -afd \ No newline at end of file