### Start Commands for Python and Node.js Applications Source: https://docs.leapcell.io/overview Examples of start commands used to run Python and Node.js applications. These commands are executed after the build process to launch the service. ```bash gunicorn -b :$PORT app:app ``` ```bash node server.js ``` -------------------------------- ### Build and Start Commands for FastAPI on Leapcell Source: https://docs.leapcell.io/examples/python/fastapi Configuration commands for building and starting a FastAPI application on Leapcell. The build command installs dependencies from `requirements.txt`, and the start command uses `uvicorn` to run the application. ```bash pip install -r requirements.txt ``` ```bash uvicorn app:app --host 0.0.0.0 --port 8080 ``` -------------------------------- ### Node.js Build and Start Commands for Leapcell Source: https://docs.leapcell.io/examples/nodejs/express These commands are used to configure the build and start process for a Node.js application on Leapcell. 'npm install' installs project dependencies, and 'node app.js' starts the application server. ```bash npm install ``` ```bash node app.js ``` -------------------------------- ### Build Commands for Python and Node.js Source: https://docs.leapcell.io/overview Examples of build commands used to install dependencies for Python and Node.js applications. These commands are executed during the build phase of the deployment process. ```bash pip install -r requirements.txt ``` ```bash npm install ``` -------------------------------- ### Go Gin Build and Start Commands for Leapcell Source: https://docs.leapcell.io/examples/golang/gin Commands required for building and starting a Go Gin application on Leapcell. The build command ensures dependencies are managed and compiles the application, while the start command executes the compiled binary. ```bash go mod tidy && go build -tags netgo -ldflags '-s -w' -o app ``` ```bash ./app ``` -------------------------------- ### Flask App Example (Python) Source: https://docs.leapcell.io/examples/python/flask A basic Flask application demonstrating a simple route that returns 'Hello Leapcell'. This serves as a starting point for deployment on Leapcell. It requires the Flask library. ```python from flask import Flask app = Flask(__name__) @app.route("/") def index(): return "Hello Leapcell" if __name__ == "__main__": app.run(debug=True) ``` -------------------------------- ### Build and Start Commands for Flask App Deployment Source: https://docs.leapcell.io/examples/python/flask Commands required for building and starting a Flask application on Leapcell. The build command installs Python dependencies from requirements.txt, and the start command uses Gunicorn to run the Flask app. ```shell pip install -r requirements.txt ``` ```shell gunicorn -w 1 -b :8080 app:app ``` -------------------------------- ### Starting Flask App with Gunicorn (Shell) Source: https://docs.leapcell.io/examples/video/ffmpeg A shell command to start the Flask application using Gunicorn, a production-ready WSGI HTTP server. It specifies the number of worker processes and the binding address and port. This is used as the start command for deployment. ```bash gunicorn -w 1 -b :8080 app:app ``` -------------------------------- ### Build and Install Dependencies Source: https://docs.leapcell.io/examples/testing/playwright Command to execute the environment preparation script and install Node.js modules. This is used as the build command in Leapcell. ```bash sh prepare_playwright_env.sh && npm install ``` -------------------------------- ### FFmpeg Installation and Dependency Installation (Shell) Source: https://docs.leapcell.io/examples/video/ffmpeg A shell command to update package lists, install FFmpeg, and install Python dependencies from requirements.txt. This is used as a build command for deploying the application on Leapcell. ```bash apt-get update && apt-get install -y ffmpeg && pip install -r requirements.txt ``` -------------------------------- ### Start Web Service Source: https://docs.leapcell.io/examples/testing/playwright Command to start the web service. The service will be available on http://localhost:8080 and can scrape links from a given URL. ```bash npm start ``` -------------------------------- ### Node.js Start Command for Express.js Apps Source: https://docs.leapcell.io/service Starts an Express.js application using Node.js. ```javascript node app.js ``` -------------------------------- ### FastAPI Application Example Source: https://docs.leapcell.io/examples/python/fastapi A basic FastAPI application demonstrating a root endpoint. This code serves as a simple example for deployment on Leapcell. It requires the `fastapi` and `uvicorn` libraries. ```python from typing import Union from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} ``` -------------------------------- ### Python Dependency Installation for Web Apps Source: https://docs.leapcell.io/service Installs Python package dependencies from a requirements file for web applications. ```bash pip install -r requirements.txt ``` -------------------------------- ### Python Dependency Installation Source: https://docs.leapcell.io/service Installs Python packages using pip. ```bash pip install requests ``` -------------------------------- ### Complete Build Command for Hugging Face Models Source: https://docs.leapcell.io/examples/ai/hg-image This command installs the CPU-only PyTorch, installs all project dependencies from requirements.txt, and then executes the Python script to load the model. It ensures all necessary components are in place for the application to run. ```bash pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu && pip install -r requirements.txt && python load_model.py ``` -------------------------------- ### Python Dependency Installation for AI Apps Source: https://docs.leapcell.io/service Installs TensorFlow and Pillow for AI applications using Python, along with system dependencies for rendering. ```bash apt-get update && apt-get install -y libsm6 libxext6 libxrender-dev pip install tensorflow pillow ``` -------------------------------- ### Prepare Puppeteer Environment Script (Bash) Source: https://docs.leapcell.io/examples/testing/puppeteer This bash script sets up the necessary environment for Puppeteer. It installs Node.js dependencies, common fonts and libraries, and then installs either Google Chrome (for amd64) or Chromium (for arm64) based on the system architecture. Finally, it moves the browser executable to a standardized location. ```bash #!/bin/bash # Exit immediately if a command exits with a non-zero status set -e # --- 1. Common Setup --- # Install Puppeteer without downloading its bundled Chromium PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install puppeteer # Update apt list and install common fonts and libraries required by both browsers echo "INFO: Installing common fonts and libraries..." apt-get update apt-get install -y fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends # --- 2. Install Browser Based on Architecture --- ARCH=$(dpkg --print-architecture) echo "INFO: Detected architecture: $ARCH" if [ "$ARCH" = "amd64" ]; then # For amd64 (x86_64) architecture, install Google Chrome echo "INFO: Installing Google Chrome for amd64..." apt-get install -y wget gnupg wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list apt-get update apt-get install -y google-chrome-stable --no-install-recommends BROWSER_EXEC="google-chrome-stable" elif [ "$ARCH" = "arm64" ]; then # For arm64 architecture, install Chromium # Google Chrome is not available for arm64, so we install the open-source version, Chromium echo "INFO: Installing Chromium for arm64..." apt-get install -y chromium --no-install-recommends BROWSER_EXEC="chromium" else echo "ERROR: Unsupported architecture: $ARCH" >&2 exit 1 fi # --- 3. Cleanup and Verification --- # Clean up apt cache to reduce image size echo "INFO: Cleaning up apt cache..." rm -rf /var/lib/apt/lists/* # Find the path of the installed browser executable chrome_path=$(which "$BROWSER_EXEC") # Verify if the browser was installed successfully and move the executable if [ -n "$chrome_path" ]; then echo "INFO: Browser executable found at: $chrome_path" # --- START: MODIFICATION --- # On arm64, rename 'chromium' to 'google-chrome-stable' for compatibility with the JS code. # On amd64, this just moves 'google-chrome-stable' to the current directory. mv "$chrome_path" ./google-chrome-stable echo "INFO: Moved executable to ./google-chrome-stable" # --- END: MODIFICATION --- else echo "ERROR: Browser executable '$BROWSER_EXEC' not found in PATH." >&2 exit 1 fi echo "✅ Setup complete. The browser executable is now available at ./google-chrome-stable" ``` -------------------------------- ### Prepare Environment and Download Whisper Model (Shell) Source: https://docs.leapcell.io/examples/audio/whisper This script sets up the Python environment by installing necessary packages like Flask, Gunicorn, PyTorch (CPU version), and the OpenAI Whisper library. It also downloads the required Whisper model using a separate Python script. The `set -e` command ensures the script exits immediately if any command fails. ```shell #!/bin/sh # Exit immediately if a command exits with a non - zero status set -e # Install Flask, python - multipart and Gunicorn pip install flask python-multipart gunicorn # Install PyTorch and related libraries (torchvision, torchaudio) # from the CPU - only wheel index of PyTorch pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu # Install or update the OpenAI Whisper library pip install -U openai-whisper # Run a Python script to download the necessary Whisper model # This script will download the model in build step python download_model.py ```