### Install Dependencies and Start Development Server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-tanstack-start/README.md Run these commands in your terminal to install project dependencies and start the development server. The app will rebuild assets as you make file changes. ```sh pnpm install pnpm dev ``` -------------------------------- ### Install Dependencies and Run Development Server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-tanstack-start/README.md After cloning the repositories, navigate into the tanstack.com directory, install its dependencies, and start the development server. The app will be accessible at https://localhost:3000 by default. ```sh cd tanstack.com pnpm i pnpm dev ``` -------------------------------- ### Example Build Commands Configuration Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/file.mdx Illustrates how to define commands within a build step, including copying files and installing dependencies. Ensure 'package.json' is present in the local context for the copy command. ```json { "commands": [ // Copy the package.json file from the local context into the build { "src": "package.json", "dest": "package.json" }, // Install dependencies { "cmd": "npm install", "customName": "Install dependencies" } // Make the node_modules/.bin directory available in the PATH { "path": "node_modules/.bin" } ] } ``` -------------------------------- ### Build Example from within Example Directory Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md When inside a specific example directory (e.g., `examples/node-angular/`), use this command to build the example, specifying the current directory as the source. ```bash cd examples/node-angular/ mise run cli build $(pwd) ``` -------------------------------- ### Setup Phoenix Project Dependencies Source: https://github.com/railwayapp/railpack/blob/main/examples/elixir-phoenix/README.md Run this command to install and set up project dependencies for a Phoenix application. ```bash mix setup ``` -------------------------------- ### Install Apt Packages for Build and Deployment Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/installing-packages.md Use RAILPACK_BUILD_APT_PACKAGES to install Apt packages during the build step and RAILPACK_DEPLOY_APT_PACKAGES for runtime dependencies. This example installs build-essential at build time and ffmpeg at runtime. ```bash RAILPACK_BUILD_APT_PACKAGES="build-essential" RAILPACK_DEPLOY_APT_PACKAGES="ffmpeg" ``` -------------------------------- ### Local Docker Compose Service Setup Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Example of how to run a container locally to manually test it. Define services in a docker-compose.yml file in a test directory. ```shell docker compose up -d docker run -it --network python-django_default --env DATABASE_URL="postgresql://django_user:django_password@postgres:5432/django_db" python-django ``` -------------------------------- ### Mise Start Docs Dev Server Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Start the documentation development server using mise. ```bash # Start the docs dev server mise run docs-dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/railwayapp/railpack/blob/main/examples/node-vite-react-router-spa/README.md Run this command in your terminal to install all necessary project dependencies. ```bash npm install ``` -------------------------------- ### Start Development Server with Bun Source: https://github.com/railwayapp/railpack/blob/main/docs/README.md Run this command to start the development server for the Railpack project. ```bash bun run dev ``` -------------------------------- ### Build Example with BuildKit and Verbose Output Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Build a specific example project using the Railpack CLI with verbose output enabled. This command requires a running BuildKit instance. ```bash mise run cli --verbose build examples/node-bun ``` -------------------------------- ### Start Svelte development server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-svelte-kit/README.md Run 'npm run dev' to start the development server. Add '-- --open' to automatically open the application in a new browser tab. ```bash npm run dev ``` ```bash npm run dev -- --open ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/railwayapp/railpack/blob/main/docs/README.md Use this command to install project dependencies using Bun. ```bash bun i ``` -------------------------------- ### Basic railpack.json Configuration Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/file.mdx Defines the basic structure for build steps, including commands for installation and building, and specifies the start command for deployment. ```json { "$schema": "https://schema.railpack.com", "steps": { "install": { "commands": ["npm install"] }, "build": { "inputs": [{ "step": "install" }], "commands": ["...", "./my-custom-build.sh"] } }, "deploy": { "startCommand": "node dist/index.js" } } ``` -------------------------------- ### Start BuildKit GRPC Frontend Server Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/reference/cli.md Use the `frontend` command to start the BuildKit GRPC frontend server, which is used internally by the build system. ```bash railpack frontend ``` -------------------------------- ### Start Remix Production Server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-remix/README.md After building the application, use this command to run the production-ready server. Ensure you have completed the build step first. ```sh npm start ``` -------------------------------- ### Web Application Procfile Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/procfile.mdx Example of a Procfile defining a web process type for starting a Node.js server. ```yaml web: node server.js ``` -------------------------------- ### Start Nuxt Development Server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-nuxt/README.md Run these commands to start the Nuxt development server, typically accessible at http://localhost:3000. Choose the command corresponding to your package manager. ```bash # npm npm run dev ``` ```bash # pnpm pnpm dev ``` ```bash # yarn yarn dev ``` ```bash # bun bun run dev ``` -------------------------------- ### Start Local Development Server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-angular/README.md Run this command to start a local development server. The application will auto-reload on source file changes. ```bash ng serve ``` -------------------------------- ### Start Phoenix Server Source: https://github.com/railwayapp/railpack/blob/main/examples/elixir-phoenix/README.md Use this command to start the Phoenix server. It can be run directly in the terminal or within an IEx session. ```bash mix phx.server ``` ```bash iex -S mix phx.server ``` -------------------------------- ### Run Development Server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-next/README.md Use these commands to start the development server for your Next.js project. Open http://localhost:3000 in your browser to view the result. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Run Integration Test for Current Directory Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md When located within an example directory (e.g., `examples/python-uv-tool-versions`), use this command to run the integration test specifically for that example. ```bash cd examples/python-uv-tool-versions mise run test-integration-cwd ``` -------------------------------- ### Generate Build Plan for an App Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Create a build plan JSON file for a specific application example, which can then be used with Docker buildx. ```bash mise run cli plan examples/node-bun --out test/railpack-plan.json ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/railwayapp/railpack/blob/main/examples/node-nuxt/README.md Use these commands to install project dependencies based on your preferred package manager (npm, pnpm, yarn, or bun). ```bash # npm npm install ``` ```bash # pnpm pnpm install ``` ```bash # yarn yarn install ``` ```bash # bun bun install ``` -------------------------------- ### Frontend Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/reference/cli.md Starts the BuildKit GRPC frontend server for internal build system use. ```APIDOC ## POST /frontend ### Description Starts the BuildKit GRPC frontend server for internal build system use. ### Method POST ### Endpoint /frontend ``` -------------------------------- ### Root Configuration with Provider, Packages, and Apt Packages Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/file.mdx Sets the deployment provider to 'node', specifies Node.js and Python versions to install, and lists apt packages required for the build. ```json { "provider": "node", "buildAptPackages": ["git", "curl"], "packages": { "node": "22", "python": "3.13" }, } ``` -------------------------------- ### Rust Application Start Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/languages/rust.md The command to start your compiled Rust application. Replace with your actual project name. ```sh ./bin/ ``` -------------------------------- ### Full Example Script for Building with Railpack Frontend Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/running-railpack-in-production.mdx A bash script demonstrating the preparation of an app directory and the computation of a secrets hash for use with the Railpack frontend. ```sh #!/bin/bash APP_DIR=my-app # Prepare the app and generate the build plan railpack prepare $APP_DIR --plan-out ./railpack-plan.json --info-out ./railpack-info.json # Compute the hash of the secret values secrets_hash=$(echo -n "STRIPE_LIVE_KEY=sk_live_asdf" | sha256sum | awk '{print $1}') ``` -------------------------------- ### Setup Local Environment with Mise Source: https://github.com/railwayapp/railpack/blob/main/CONTRIBUTING.md Run this command to set up your local development environment for Railpack using Mise. ```bash mise run setup ``` -------------------------------- ### Start BuildKit Container Source: https://github.com/railwayapp/railpack/blob/main/README.md Starts a privileged BuildKit container and sets the BUILDKIT_HOST environment variable. This is necessary for railpack to function. ```bash docker run --rm --privileged -d --name buildkit moby/buildkit export BUILDKIT_HOST='docker-container://buildkit' ``` -------------------------------- ### Install Railpack with Custom Options via Curl Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/installation.md Customize the installation by specifying the version and binary directory when using curl to download and execute the script. ```sh curl -sSL https://railpack.com/install.sh | RAILPACK_VERSION=0.2.3 sh -s -- --bin-dir ~/.local/bin ``` -------------------------------- ### Step Layer Configuration Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/file.mdx Defines a layer for a step that uses the output of another step ('install') as its filesystem, including all files except 'node_modules'. ```json { "step": "install", "include": ["."], // "." represents the working directory (/app) "exclude": ["node_modules"] } ``` -------------------------------- ### Run Remix Development Server Source: https://github.com/railwayapp/railpack/blob/main/examples/node-remix/README.md Use this command to start the local development server for your Remix application. It typically includes features like hot module replacement. ```shellscript npm run dev ``` -------------------------------- ### FastAPI Application Start Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/languages/python.md When FastAPI is detected as a dependency and uvicorn is available, Railpack configures the application to start using this command. It binds to all network interfaces on the specified port. ```shell uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000} ``` -------------------------------- ### Add app_gleam Package Source: https://github.com/railwayapp/railpack/blob/main/examples/gleam/README.md Install the app_gleam package version 1 using the Gleam package manager. ```sh gleam add app_gleam@1 ``` -------------------------------- ### Go Library: Programmatic Build Plan Generation Source: https://context7.com/railwayapp/railpack/llms.txt Use Railpack as a Go library to programmatically generate build plans. This example demonstrates creating an app from a directory, setting up environment variables, configuring build options, and outputting the plan as JSON. ```go package main import ( "encoding/json" "fmt" "log" "github.com/railwayapp/railpack/core" "github.com/railwayapp/railpack/core/app" ) func main() { // Create app from directory application, err := app.NewApp("./my-project") if err != nil { log.Fatal(err) } // Create environment with variables env, err := app.FromEnvs([]string{ "NODE_ENV=production", "DATABASE_URL=postgres://localhost/db", }) if err != nil { log.Fatal(err) } // Configure build options options := &core.GenerateBuildPlanOptions{ RailpackVersion: "1.0.0", BuildCommand: "npm run build", StartCommand: "node dist/server.js", PreviousVersions: map[string]string{"node": "20.10.0"}, ConfigFilePath: "railpack.json", ErrorMissingStartCommand: true, } // Generate build plan result := core.GenerateBuildPlan(application, env, options) if !result.Success { for _, logMsg := range result.Logs { fmt.Printf("[%s] %s\n", logMsg.Level, logMsg.Message) } log.Fatal("Build plan generation failed") } // Output the plan as JSON planJSON, err := json.MarshalIndent(result.Plan, "", " ") if err != nil { log.Fatal(err) } fmt.Println(string(planJSON)) // Access metadata fmt.Printf("Detected providers: %v\n", result.DetectedProviders) fmt.Printf("Resolved packages: %v\n", result.ResolvedPackages) } ``` -------------------------------- ### Basic Gleam Project Structure Source: https://github.com/railwayapp/railpack/blob/main/examples/gleam/README.md A minimal Gleam program structure. This serves as a starting point for projects using the app_gleam package. ```gleam import app_gleam pub fn main() -> Nil { // TODO: An example of the project in use } ``` -------------------------------- ### Opt-in to Precompiled Ruby with Mise Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/mise.md To enable non-default features such as precompiled Ruby, include a `mise.toml` file in your repository. This example configures the Ruby tool and sets the compile setting to false. ```toml [tools] ruby = "3" [settings] ruby.compile = false ``` -------------------------------- ### Railpack Frontend Command Source: https://context7.com/railwayapp/railpack/llms.txt Start the BuildKit GRPC frontend server for platform integration. Used internally by the railpack-frontend Docker image. ```APIDOC ## POST /railpack frontend ### Description Start the BuildKit GRPC frontend server for platform integration. Used internally by the railpack-frontend Docker image. ### Method POST ### Endpoint /railpack frontend ### Parameters No parameters required. ### Request Example ```bash # Start frontend server (typically run inside BuildKit) railpack frontend ``` ### Response #### Success Response (200) Indicates the frontend server has started successfully. No specific JSON response body is typically returned, but logs will show server status. #### Response Example (No JSON response body, check logs for confirmation) ``` Frontend server started on port 1234 ``` ``` -------------------------------- ### Install Mise Packages Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/installing-packages.md Set the RAILPACK_PACKAGES environment variable to install specified packages from Mise. This example installs the latest versions of Node and Bun, along with Python 3.10. ```bash RAILPACK_PACKAGES="node bun@latest python@3.10" ``` -------------------------------- ### BuildKit Frontend Integration with buildctl Source: https://context7.com/railwayapp/railpack/llms.txt Pull the Railpack frontend image and use it with buildctl for container builds. This example shows direct integration and an approach using a generated plan file. ```bash # Pull the frontend image docker pull ghcr.io/railwayapp/railpack-frontend:latest # Use with buildctl buildctl build \ --frontend gateway.v0 \ --opt source=ghcr.io/railwayapp/railpack-frontend:latest \ --local context=. --local dockerfile=. --opt filename=railpack-plan.json \ --opt build-arg:secrets-hash="abc123" \ --opt build-arg:cache-key="my-project" \ --output type=docker,name=my-app | docker load # Generate plan first, then build with frontend railpack prepare --plan-out railpack-plan.json ./my-app buildctl build \ --frontend gateway.v0 \ --opt source=ghcr.io/railwayapp/railpack-frontend:latest \ --local context=./my-app \ --local dockerfile=. --opt filename=railpack-plan.json \ --output type=docker,name=my-app | docker load ``` -------------------------------- ### Run Project with Bun Source: https://github.com/railwayapp/railpack/blob/main/examples/config-file/README.md Execute your project's entry point file using the Bun runtime. ```bash bun run index.ts ``` -------------------------------- ### Get Project Information with Railpack Info Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/reference/cli.md The `info` command provides detailed information about a project's detected configuration, dependencies, and build requirements. Output can be formatted as 'pretty' or 'json' and directed to a file. ```bash railpack info [options] DIRECTORY ``` -------------------------------- ### Create Astro Project with Basics Template Source: https://github.com/railwayapp/railpack/blob/main/examples/node-astro/README.md Use this command to initialize a new Astro project with the 'basics' template. This sets up a foundational project structure for you to build upon. ```sh npm create astro@latest -- --template basics ``` -------------------------------- ### Common Astro Project Commands Source: https://github.com/railwayapp/railpack/blob/main/examples/node-astro/README.md These npm commands are essential for managing your Astro project. Use 'npm run dev' to start a local development server, 'npm run build' to create a production build, and 'npm run preview' to test the build locally. ```sh npm install ``` ```sh npm run dev ``` ```sh npm run build ``` ```sh npm run preview ``` ```sh npm run astro ... ``` ```sh npm run astro -- --help ``` -------------------------------- ### Custom Installation Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/languages/shell.md Set the RAILPACK_INSTALL_CMD environment variable to execute a custom command before the build step. This can be used for setup tasks like creating directories or configuration files. ```bash RAILPACK_INSTALL_CMD="mkdir -p config && echo 'production=true' > config/settings.conf" ``` ```bash RAILPACK_INSTALL_CMD="bash setup.sh" ``` -------------------------------- ### Multiple Process Types Procfile Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/procfile.mdx Example of a Procfile with multiple process types including web, worker, and scheduler. Railpack will use the 'web' command as the container start command due to priority. ```yaml web: gunicorn app:application worker: celery worker -A app.celery scheduler: celery beat -A app.celery ``` -------------------------------- ### Install mise & Railpack Source: https://github.com/railwayapp/railpack/blob/main/README.md Installs mise and the latest version of railpack. Ensure you have mise installed first. ```bash curl -sSL https://mise.run | sh mise install github:railwayapp/railpack@latest ``` -------------------------------- ### Install Railpack with curl Source: https://context7.com/railwayapp/railpack/llms.txt Install Railpack using a curl script. You can also specify a version and installation directory. ```bash curl -sSL https://railpack.com/install.sh | sh ``` ```bash curl -sSL https://railpack.com/install.sh | RAILPACK_VERSION=0.2.3 sh -s -- --bin-dir ~/.local/bin ``` -------------------------------- ### Build Railpack from Source Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/installation.md Clone the repository, navigate to the directory, build the binary, and then run the help command. This method is useful for development or if you need a specific version not available via other methods. ```sh git clone https://github.com/railwayapp/railpack.git cd railpack go build -o railpack ./cmd/... ./railpack --help ``` -------------------------------- ### Verify Railpack Installation Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/getting-started.mdx Confirms that Railpack has been installed correctly by checking its help command. This is a good first step after installation. ```sh railpack --help ``` -------------------------------- ### Install Railpack Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/getting-started.mdx Installs Railpack on Mac or Linux using a curl script. Ensure you have the necessary permissions. ```sh curl -sSL https://railpack.com/install.sh | sh ``` -------------------------------- ### Install Railpack using mise Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/installation.md Use this command to install the latest version of Railpack with the mise package manager. ```sh mise use github:railwayapp/railpack@latest ``` -------------------------------- ### Equivalent Deploy Configuration Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/adding-steps.mdx This configuration is equivalent to using `deployOutputs`. It explicitly defines that the 'dist' directory from 'new-step' should be included in the deploy inputs. ```json { "$schema": "https://schema.railpack.com", "steps": { "new-step": { "commands": ["echo 'Hello, world!'"], "deployOutputs": [] }, }, "deploy": { "inputs": [ { "step": "new-step", "include": ["dist"] } ] } } ``` -------------------------------- ### Install Additional Packages Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/languages/shell.md Specify additional packages to be installed using environment variables. RAILPACK_PACKAGES is for Mise-supported tools, while RAILPACK_BUILD_APT_PACKAGES and RAILPACK_DEPLOY_APT_PACKAGES are for system packages. ```bash RAILPACK_PACKAGES="jq@latest python@3.11" RAILPACK_DEPLOY_APT_PACKAGES="ffmpeg" ``` -------------------------------- ### Build with Custom Configuration and Options Source: https://context7.com/railwayapp/railpack/llms.txt Use environment variables to set custom configuration files and enable verbose logging. Build your application with specific environment variables, previous Node.js versions, and the application path. ```bash export RAILPACK_CONFIG_FILE="config/railpack-prod.json" export RAILPACK_VERBOSE=1 railpack build \ --env DATABASE_URL="$DATABASE_URL" \ --env API_KEY="$API_KEY" \ --previous "node@20.10.0" \ ./my-app ``` -------------------------------- ### Verbose Build with Progress Plan Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Run a verbose build command with mise, showing the build plan and progress in a plain format. ```bash `mise run cli -- --verbose build --show-plan --progress plain examples/node-bun` ``` -------------------------------- ### Build Project for Production Source: https://github.com/railwayapp/railpack/blob/main/examples/node-angular/README.md Compiles the project and stores build artifacts in the 'dist/' directory. Optimizes for performance and speed. ```bash ng build ``` -------------------------------- ### Define a New Build Step Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/adding-steps.mdx Add a new step named 'new-step' with a simple 'echo' command. This step will run with default inputs, providing access to Mise and build apt packages. ```json { "$schema": "https://schema.railpack.com", "steps": { "new-step": { "commands": ["echo 'Hello, world!'"] }, } } ``` -------------------------------- ### Flask Application Start Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/languages/python.md If Flask is detected as a dependency and gunicorn is available, Railpack uses this command to start the application. It binds to all network interfaces on the specified port. ```shell gunicorn --bind 0.0.0.0:${PORT:-8000} main:app ``` -------------------------------- ### Install Packages with RAILPACK_PACKAGES Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/environment-variables.md Use the RAILPACK_PACKAGES environment variable to install additional Mise packages. Versions are optional; if omitted, the latest version is used. Multiple packages can be specified. ```sh RAILPACK_PACKAGES="pipx:httpie jq@latest" ``` -------------------------------- ### Create a new Svelte project Source: https://github.com/railwayapp/railpack/blob/main/examples/node-svelte-kit/README.md Use 'npx sv create' to initialize a new Svelte project. Specify a directory name to create the project in a specific folder. ```bash npx sv create ``` ```bash npx sv create my-app ``` -------------------------------- ### Docker Build and Run Source: https://github.com/railwayapp/railpack/blob/main/examples/node-vite-react-router-spa/README.md Builds a Docker image for your application and runs it as a container. The application will be exposed on port 3000. ```bash docker build -t my-app . # Run the container docker run -p 3000:3000 my-app ``` -------------------------------- ### Deploy Layer Configuration with Docker Image and Step Inputs Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/file.mdx Configures the deploy section to use a Docker image as the base filesystem and includes outputs from other steps, specifying which files to include. ```json "deploy": { "base": { "image": "ghcr.io/railwayapp/railpack-runtime:mise-2026.2.22" }, "inputs": [ { "step": "packages:mise", "include": [ "/mise/shims", "/mise/installs", "// ..." ] }, { "step": "build", "include": ["."] } ] } ``` -------------------------------- ### Specify Step Dependencies Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/adding-steps.mdx Configure 'new-step' to run after the 'build' step by specifying 'build' in the `inputs` field. This ensures commands execute in the correct order. ```json { "$schema": "https://schema.railpack.com", "steps": { "new-step": { "inputs": [ { "step": "build" } ], "commands": ["echo 'Hello, world!'"] }, } } ``` -------------------------------- ### Extending Build Commands and Deploy Inputs Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/file.mdx Demonstrates extending existing arrays in the configuration. The 'build' step adds a custom script, and the 'deploy' section adds a Docker image layer. ```json { "steps": { "build": { // Runs ./my-custom-build.sh after the auto-generated build commands "commands": ["...", "./my-custom-build.sh"] } }, "deploy": { "inputs": [ "...", // Copies the neofetch binary into the final image on top of the auto-generated image { "image": "macabees/neofetch", "include": ["/usr/bin/neofetch"] } ] } } ``` -------------------------------- ### Interactive Debugging with Delve Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Start an interactive debugging session for the CLI build process using Delve. ```bash mise run debug-cli build $(pwd) ``` -------------------------------- ### Background Worker Procfile Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/config/procfile.mdx Example of a Procfile defining a worker process type for running a Python background task. ```yaml worker: python worker.py ``` -------------------------------- ### Create Directory for Project and Documentation Source: https://github.com/railwayapp/railpack/blob/main/examples/node-tanstack-start/README.md Create a new directory to house the TanStack website repository and the project repository you intend to work on. ```sh mkdir tanstack ``` -------------------------------- ### Railpack Info Command Source: https://context7.com/railwayapp/railpack/llms.txt Get detailed information about a project's detected configuration, dependencies, and build requirements. ```APIDOC ## POST /railpack info ### Description Get detailed information about a project's detected configuration, dependencies, and build requirements. ### Method POST ### Endpoint /railpack info ### Parameters #### Path Parameters - **./my-app** (string) - Required - Path to the project directory. #### Query Parameters - **--format** (string) - Optional - Output format (json or pretty-printed). Defaults to pretty-printed. - **--out** (string) - Optional - Save info to a file. ### Request Example ```bash # Pretty-printed output railpack info ./my-app # JSON output for programmatic use railpack info --format json ./my-app # Save info to file railpack info --format json --out build-info.json ./my-app ``` ### Response #### Success Response (200) - **project_type** (string) - Detected project type (e.g., nodejs, python). - **dependencies** (array) - List of detected dependencies. - **build_requirements** (object) - Information about build requirements. #### Response Example ```json { "project_type": "nodejs", "dependencies": [ "express", "react" ], "build_requirements": { "node_version": "18.x", "npm_version": "9.x" } } ``` ``` -------------------------------- ### Configure Environment Variables for Builds Source: https://context7.com/railwayapp/railpack/llms.txt Set environment variables to configure build commands, package installations, and deployment settings. ```bash # Set build command export RAILPACK_BUILD_CMD="npm run build:production" # Set install command export RAILPACK_INSTALL_CMD="npm ci --production" # Set start command export RAILPACK_START_CMD="node server.js" # Install additional mise packages export RAILPACK_PACKAGES="python@3.13 jq@latest pipx:httpie" # Install apt packages during build export RAILPACK_BUILD_APT_PACKAGES="git curl wget" # Install apt packages in final image export RAILPACK_DEPLOY_APT_PACKAGES="ca-certificates" # Disable specific caches or all caches export RAILPACK_DISABLE_CACHES="npm" export RAILPACK_DISABLE_CACHES="*" ``` -------------------------------- ### Run BuildKit Directly with Buildctl Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Use the `buildctl` command to run BuildKit directly, specifying local contexts, the frontend, and outputting the result to Docker. ```bash buildctl build \ --local context=examples/node-bun \ --local dockerfile=test \ --frontend=gateway.v0 \ --opt source=ghcr.io/railwayapp/railpack:railpack-frontend \ --output type=docker,name=test | docker load ``` -------------------------------- ### Override Rust Version Configuration Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/languages/rust.md Use this variable to override the Rust version detected by Railpack. Example shows version 1.85.1. ```sh RAILPACK_RUST_VERSION="1.85.1" ``` -------------------------------- ### Preview Production Build Locally Source: https://github.com/railwayapp/railpack/blob/main/examples/node-nuxt/README.md Use these commands to locally preview the production build of your Nuxt application. Select the command that matches your package manager. ```bash # npm npm run preview ``` ```bash # pnpm pnpm preview ``` ```bash # yarn yarn preview ``` ```bash # bun bun run preview ``` -------------------------------- ### Build Directly with Buildctl Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Build directly using 'buildctl', piping the LLB definition from the 'cli build' command. Includes progress and trace logging. ```bash mise run cli build $(pwd) --dump-llb | buildctl build \ --progress=plain \ --trace=build.log \ --local context=. ``` -------------------------------- ### Plan Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/reference/cli.md Analyzes a directory and outputs the build plan that would be used. ```APIDOC ## POST /plan ### Description Analyzes a directory and outputs the build plan that would be used. ### Method POST ### Endpoint /plan ### Parameters #### Query Parameters - **DIRECTORY** (string) - Required - The directory to analyze. #### Request Body - **out** (string) - Optional - Output file name for the plan. - **env** (object) - Optional - Environment variables to set. Format: `KEY=VALUE`. - **previous** (object) - Optional - Versions of packages used for previous builds. Format: `NAME@VERSION`. - **build_cmd** (string) - Optional - Build command to use. - **start_cmd** (string) - Optional - Start command to use. - **config_file** (string) - Optional - Path to config file to use. - **error_missing_start** (boolean) - Optional - Error if no start command is found. Enabled by default on Railway. ``` -------------------------------- ### Prepare Directory for Building with Railpack Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/running-railpack-in-production.mdx Use the prepare command to output the build result to stdout, save the build plan to a file, and save build info to a JSON file. This prepares a directory for building with Railpack. ```sh railpack prepare /dir/to/build --plan-out railpack-plan.json --info-out railpack-info.json ``` -------------------------------- ### Get project info with Railpack Source: https://context7.com/railwayapp/railpack/llms.txt Retrieve detailed information about a project's configuration, dependencies, and build requirements. Output can be pretty-printed or in JSON format. ```bash railpack info ./my-app ``` ```bash railpack info --format json ./my-app ``` ```bash railpack info --format json --out build-info.json ./my-app ``` -------------------------------- ### Build Remix App for Production Source: https://github.com/railwayapp/railpack/blob/main/examples/node-remix/README.md Execute this command to create an optimized production build of your Remix application. This prepares the necessary files for deployment. ```sh npm run build ``` -------------------------------- ### Prepare Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/reference/cli.md Generates build configuration files without performing the actual build. ```APIDOC ## POST /prepare ### Description Generates build configuration files without performing the actual build. This is useful for platforms that want to build with a custom frontend and need to save the build plan to a `railpack-plan.json` file, log the Railpack pretty output to stdout, or save additional build information for later use. ### Method POST ### Endpoint /prepare ### Parameters #### Query Parameters - **DIRECTORY** (string) - Required - The directory to prepare. #### Request Body - **plan_out** (string) - Optional - Output file for the JSON serialized build plan. - **info_out** (string) - Optional - Output file for the JSON serialized build result info. - **env** (object) - Optional - Environment variables to set. Format: `KEY=VALUE`. - **previous** (object) - Optional - Versions of packages used for previous builds. Format: `NAME@VERSION`. - **build_cmd** (string) - Optional - Build command to use. - **start_cmd** (string) - Optional - Start command to use. - **config_file** (string) - Optional - Path to config file to use. - **error_missing_start** (boolean) - Optional - Error if no start command is found. Enabled by default on Railway. ``` -------------------------------- ### Output Railpack Configuration Schema Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/reference/cli.md Run `railpack schema` to get the JSON schema for Railpack configuration files. This schema is used by IDEs for autocompletion and validation. ```bash railpack schema ``` -------------------------------- ### External Store for State Preservation Source: https://github.com/railwayapp/railpack/blob/main/examples/node-vite-svelte/README.md Use an external store to preserve component state during Hot Module Replacement (HMR). This example demonstrates a simple writable store. ```typescript // store.ts // An extremely simple external store import { writable } from 'svelte/store' export default writable(0) ``` -------------------------------- ### Run Build with Custom Frontend Image Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Execute the Docker buildx command to build an application using a custom frontend image specified by a build argument and a generated build plan. ```bash docker buildx \ --build-arg BUILDKIT_SYNTAX="railpack-frontend:local" \ -f test/railpack-plan.json \ examples/node-bun ``` -------------------------------- ### Static Site Build Source: https://context7.com/railwayapp/railpack/llms.txt Build a static site. This is a fallback for HTML/CSS/JS projects when no specific project type is detected. ```bash railpack build ./static-site ``` -------------------------------- ### Add React-Specific ESLint Rules in Vite Source: https://github.com/railwayapp/railpack/blob/main/examples/node-vite-react/README.md Integrate `eslint-plugin-react-x` and `eslint-plugin-react-dom` for enhanced React and React DOM linting. This requires installing these plugins and extending their recommended configurations. ```javascript // eslint.config.js import reactX from 'eslint-plugin-react-x' import reactDom from 'eslint-plugin-react-dom' export default tseslint.config([ globalIgnores(['dist']), { files: ['**/*.{ts,tsx}'] extends: [ // Other configs... // Enable lint rules for React reactX.configs['recommended-typescript'], // Enable lint rules for React DOM reactDom.configs.recommended, ], languageOptions: { parserOptions: { project: ['./tsconfig.node.json', './tsconfig.app.json'], tsconfigRootDir: import.meta.dirname, }, // other options... }, }, ]) ``` -------------------------------- ### Mise Lint and Format Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/guides/developing-locally.md Run linting and formatting checks for the project using mise. ```bash # Lint and format mise run check ``` -------------------------------- ### Build Command Source: https://github.com/railwayapp/railpack/blob/main/docs/src/content/docs/reference/cli.md Builds a container image from a project directory using BuildKit. ```APIDOC ## POST /build ### Description Builds a container image from a project directory using BuildKit. ### Method POST ### Endpoint /build ### Parameters #### Query Parameters - **DIRECTORY** (string) - Required - The directory to build from. #### Request Body - **name** (string) - Optional - Name of the image to build. - **output** (string) - Optional - Output the final filesystem to a local directory. - **platform** (string) - Optional - Platform to build for (e.g. linux/amd64, linux/arm64). - **progress** (string) - Optional - BuildKit progress output mode (auto, plain, tty). Default: `auto`. - **show_plan** (boolean) - Optional - Show the build plan before building. Default: `false`. - **cache_key** (string) - Optional - Unique id to prefix to cache keys. - **env** (object) - Optional - Environment variables to set. Format: `KEY=VALUE`. - **previous** (object) - Optional - Versions of packages used for previous builds. Format: `NAME@VERSION`. - **build_cmd** (string) - Optional - Build command to use. - **start_cmd** (string) - Optional - Start command to use. - **config_file** (string) - Optional - Path to config file to use. - **error_missing_start** (boolean) - Optional - Error if no start command is found. Enabled by default on Railway. ```