### Gunicorn with Virtual Environment Path Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app This command demonstrates how to run Gunicorn when it's installed within a virtual environment. It specifies the path to the Gunicorn binary. ```bash venv/bin/gunicorn --bind 0.0.0.0:3000 wsgi:app ``` -------------------------------- ### Nixpacks Build Log Sample (Bash) Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/logging This snippet shows a sample output from a Nixpacks build process, illustrating the setup, install, and start commands used to create a Docker image. It is part of the build logs and helps in understanding the build environment and dependencies. ```bash ... 10:57:40 AM: 10:57:40 AM: ╔═══════════════════════════════ Nixpacks v1.6.0 ══════════════════════════════╗ 10:57:40 AM: ║ setup │ python38, gcc ║ 10:57:40 AM: ║──────────────────────────────────────────────────────────────────────────────║ 10:57:40 AM: ║ install │ python -m venv /opt/venv && . /opt/venv/bin/activate && pip ║ 10:57:40 AM: ║ │ install -r requirements.txt ║ 10:57:40 AM: ║──────────────────────────────────────────────────────────────────────────────║ 10:57:40 AM: ║ start │ gunicorn --bind 0.0.0.0:3000 wsgi:app ║ 10:57:40 AM: ╚══════════════════════════════════════════════════════════════════════════════╝ 10:57:40 AM: ... ``` -------------------------------- ### Install Flask and Gunicorn Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app This command uses pip, Python's package installer, to install the Flask web framework and Gunicorn, a WSGI HTTP server. These are essential for running a Python web application. ```bash pip install flask gunicorn ``` -------------------------------- ### Install Gems and Create Database for Rails App Source: https://www.flightcontrol.dev/docs/getting-started/ruby/creating-rails-app After creating a Rails application, navigate into the project directory and run 'bundle install' to install necessary gems, including the 'pg' gem for PostgreSQL. Then, create the development and test databases using 'rails db:create'. This requires PostgreSQL to be running locally. ```bash cd shop bundle install rails db:create ``` -------------------------------- ### Basic Flask App Setup (Python) Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app This Python code defines a simple Flask application with a single route '/'. It's configured to run on port 3000 and listen on all IP addresses, which is essential for deployment. ```python from flask import Flask app = Flask(__name__) @app.route("/") def index(): return "Books Index Page" if __name__ == "__main__": app.run(host='0.0.0.0', port=3000) ``` -------------------------------- ### Create a New Rails Application with PostgreSQL Source: https://www.flightcontrol.dev/docs/getting-started/ruby/creating-rails-app This command initializes a new Ruby on Rails project named 'shop' and configures it to use PostgreSQL as the database. Ensure you have Ruby and Rails installed. ```bash rails new shop --database=postgresql ``` -------------------------------- ### Git Commands for Initial Commit Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app These Git commands are used to stage, commit, and push the Flask project files to a remote GitHub repository, preparing it for deployment. ```bash git add *.py requirements.txt Procfile git commit -m "Initial commit" git remote add origin YOUR_GITHUB_REPO_URL git push -u origin main ``` -------------------------------- ### Generate requirements.txt Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app This command generates a 'requirements.txt' file, which lists all the Python packages and their exact versions installed in the current virtual environment. This file is used to recreate the environment on other machines or for deployment. ```bash pip freeze > requirements.txt ``` -------------------------------- ### Example Scheduler Service Configuration Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/scheduler A comprehensive example demonstrating how to configure a scheduler service with multiple jobs. It includes settings for start command, schedule, timezone, timeout, CPU, and memory for each job. ```json { "type": "scheduler", "jobs": { "daily-report": { "startCommand": "php artisan reports:generate-daily", "schedule": "0 0 * * *", "timezone": "America/New_York", "timeout": 30, "cpu": 1, "memory": 2 }, "weekly-cleanup": { "startCommand": "php artisan storage:cleanup", "schedule": "0 0 * * 0", "timezone": "UTC", "timeout": 60, "cpu": 0.5, "memory": 1 }, "manual-data-sync": { "startCommand": "php artisan data:sync", "schedule": "manual", "cpu": 2, "memory": 4 } } } ``` -------------------------------- ### Procfile for Flightcontrol Deployment Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app This Procfile specifies the command Flightcontrol will use to start the web service. It uses Gunicorn to run the Flask application. ```plaintext web: gunicorn --bind 0.0.0.0:3000 wsgi:app ``` -------------------------------- ### Run Remix Development Server Source: https://www.flightcontrol.dev/docs/reference/examples/remix This command starts the Remix development server, allowing you to run the application locally. The application will typically be accessible at `http://localhost:3000`. This command is used after all local setup and configuration changes are complete. ```bash npm run dev ``` -------------------------------- ### Run Rails Development Server Source: https://www.flightcontrol.dev/docs/getting-started/ruby/creating-rails-app Starts the local development server for your Ruby on Rails application. Access your application by navigating to http://localhost:3000/ in your web browser. ```bash rails server ``` -------------------------------- ### Flightcontrol Configuration for Prisma Studio Service Source: https://www.flightcontrol.dev/docs/reference/examples/prisma-studio This JSON snippet defines a 'web' type service for Prisma Studio within a Flightcontrol deployment. It specifies resource allocation (CPU, memory), build and start commands, port, build type, and environment variables, including secrets fetched from AWS Parameter Store. ```json { "id": "prisma-studio", "name": "Prisma Studio", "type": "web", "target": {"type": "fargate"}, "cpu": 0.25, "memory": 0.5, "buildCommand": "npm i pm2", "startCommand": "pm2 start \"npx prisma studio\" && caddy run", "port": 80, "buildType": "nixpacks", "envVariables": { "NIXPACKS_PKGS": "caddy", "PRISMA_STUDIO_USERNAME": "", "PRISMA_STUDIO_PASSWORD_HASH": { "fromParameterStore": "PRISMA_STUDIO_PASSWORD_HASH" }, "DATABASE_URL": { "fromParameterStore": "DATABASE_URL" } } } ``` -------------------------------- ### Configure Static Site Build Commands Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/static Defines commands for installing dependencies, building the application, and performing post-build actions for static sites. These commands are executed within the specified basePath. ```yaml basePath: "./apps/frontend" installCommand: "./install.sh" buildCommand: "blitz build" postBuildCommand: "./postBuildCommand.sh" ``` -------------------------------- ### Configure Yarn Install Caching with Nixpacks Source: https://www.flightcontrol.dev/docs/tips/speeding-up-nixpacks-builds This example demonstrates how to configure `nixpacks.toml` to cache the Yarn install phase. By specifying files such as `yarn.lock`, `package.json`, and relevant configuration files, Nixpacks can intelligently skip reinstallations, leading to faster build cycles. This is particularly beneficial for complex projects and monorepos. ```toml [phases.install] onlyIncludeFiles = [ ".npmrc", "package.json", "yarn.lock", "turbo.json", ".yarnrc.yml", ".yarn", "packages/ui/package.json", "packages/types/package.json", "apps/web/package.json", "apps/api/package.json", ] ``` -------------------------------- ### Nixpacks Build Options Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/network-server Configure Nixpacks builds with custom paths, install, build, post-build, and start commands. ```APIDOC ## Nixpacks Build Options ### Description Configure Nixpacks builds with custom paths, install, build, post-build, and start commands. ### Method N/A (Configuration Options) ### Endpoint N/A (Configuration Options) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **basePath** (string) - Optional - The directory containing your application code, relative to the repository root. Defaults to `.`. Only supported when `buildType: nixpacks`. - **installCommand** (string) - Optional - The command used to install dependencies for your build. Defaults to an intelligent guess based on language and framework. - **buildCommand** (string) - Optional - The command used to build your application. Defaults to an intelligent guess based on language and framework. - **postBuildCommand** (string) - Optional - A build hook to run any operation after your build is complete. Requires `buildCommand` to be set. Defaults to empty. - **startCommand** (string) - Optional - The command used to start your application. Defaults to an intelligent guess based on language and framework. ### Request Example ```json { "buildType": "nixpacks", "basePath": "./apps/frontend", "installCommand": "./install.sh", "buildCommand": "blitz build", "postBuildCommand": "./postBuildCommand.sh", "startCommand": "blitz start" } ``` ### Response #### Success Response (200) N/A (Configuration Options) #### Response Example N/A ``` -------------------------------- ### Push Rails Project to GitHub using Git Commands Source: https://www.flightcontrol.dev/docs/getting-started/ruby/creating-rails-app This snippet demonstrates the command-line Git operations required to add all project files, commit them with an initial message, link the local repository to a remote GitHub origin, and push the code to the main branch. Ensure you replace 'YOUR_GITHUB_REPO_URL' with your actual repository URL. ```bash git add . git commit -m "Initial commit" git remote add origin YOUR_GITHUB_REPO_URL git push -u origin main ``` -------------------------------- ### Configure Node/Express Web App Deployment with Flightcontrol Source: https://www.flightcontrol.dev/docs/reference/examples/node This JSON configuration defines a web service for a Node.js/Express application within Flightcontrol. It specifies build and start commands, environment variables sourced from a database service, and resource allocation. The configuration assumes a standard Node.js project structure and may require adjustments to `buildCommand` and `startCommand` based on your `package.json`. ```json { "$schema": "https://app.flightcontrol.dev/schema.json", "environments": [ { "id": "production", "name": "Production", "region": "us-west-1", "source": { "branch": "main" }, "services": [ { "id": "my-webapp", "name": "My Webapp", "type": "web", "target": {"type": "fargate"}, "buildType": "nixpacks", "ci": { "type": "ec2" }, "cpu": 0.5, "memory": 1, "minInstances": 1, "maxInstances": 1, "buildCommand": "npm run build", "startCommand": "npm run start", "envVariables": { "DATABASE_URL": { "fromService": { "id": "db", "value": "dbConnectionString" } } } }, { "id": "db", "name": "Database", "type": "rds", "engine": "postgres", "engineVersion": "13", "instanceSize": "db.t4g.micro", "storage": 20, "private": false } ] } ] } ``` -------------------------------- ### Caddyfile Configuration for Prisma Studio Source: https://www.flightcontrol.dev/docs/reference/examples/prisma-studio This Caddyfile configures a reverse proxy to Prisma Studio, adding HTTP Basic Authentication using environment variables for username and a hashed password. It specifies the admin interface to be off and logs requests. ```caddyfile { debug admin off } # Note: the urls use `http`, not `https` because `https` is added at a higher layer http://admin.yourproductiondomain.com { reverse_proxy 0.0.0.0:5555 log basicauth { {$PRISMA_STUDIO_USERNAME} {$PRISMA_STUDIO_PASSWORD_HASH} } } ``` -------------------------------- ### Run Prisma Migrate for Postgres Source: https://www.flightcontrol.dev/docs/reference/examples/remix This command initializes the database schema for PostgreSQL using Prisma Migrate. It applies the initial migration after the database provider has been changed. This command creates a `migrations` folder with the necessary SQL scripts. ```bash npx prisma migrate dev --name init ``` -------------------------------- ### Activate Python Virtual Environment Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app These commands activate the previously created Python virtual environment. Activation is crucial to ensure that packages are installed within the isolated environment. The activation command differs between Linux/Mac and Windows. ```bash . venv/bin/activate ``` ```bash venv\Scripts\activate ``` -------------------------------- ### Configure Docker Deployment with Docker Hub Authentication Source: https://www.flightcontrol.dev/docs/reference/examples/docker This configuration demonstrates how to set up a Docker deployment in Flightcontrol. It specifies the build type as 'docker', the Dockerfile path, and context. It also shows how to use environment variables DOCKER_USERNAME and DOCKER_PASSWORD, fetched from Parameter Store, to authenticate with Docker Hub and avoid pull rate limits. ```json { "environments": [ { "id": "production", "name": "Production", "region": "us-west-2", "source": { "branch": "main" }, "services": [ { "id": "my-webapp", "name": "My Webapp", "type": "web", "target": {"type": "fargate"}, "buildType": "docker", "ci": { "type": "ec2" }, "dockerfilePath": "Dockerfile", "dockerContext": ".", "cpu": 0.25, "memory": 0.5, "port": 8080, "minInstances": 1, "maxInstances": 1, "envVariables": { "DATABASE_URL": { "fromService": { "id": "db", "value": "dbConnectionString" } }, "DOCKER_USERNAME": { "fromParameterStore": "docker.hub.username" }, "DOCKER_PASSWORD": { "fromParameterStore": "docker.hub.password" } } }, { "id": "db", "name": "Database", "type": "rds", "engine": "postgres", "engineVersion": "12", "instanceSize": "db.t4g.micro", "storage": 20, "private": false } ] } ] } ``` -------------------------------- ### Combine Build Command with Asset Precompilation (Rails) Source: https://www.flightcontrol.dev/docs/guides/advanced/database-migrations This example shows how to combine asset precompilation with database migrations in a single build command for Rails. It ensures both processes run sequentially. ```bash rails assets:precompile && rails db:migrate ``` -------------------------------- ### Check Python Version Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app This command checks the installed Python version on your system. It's a prerequisite for setting up the Flask application. If 'python --version' fails or shows an older version, 'python3 --version' can be tried. ```bash python --version ``` ```bash python3 --version ``` -------------------------------- ### Get Services API Request Examples (cURL) Source: https://www.flightcontrol.dev/docs/reference/http-api/services/get-services Demonstrates how to call the Get Services API using cURL. Includes examples for basic requests, pagination, filtering by type and project, and retrieving only preview or standard services. ```curl curl -X GET "https://api.flightcontrol.dev/v1/services" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```curl curl -X GET "https://api.flightcontrol.dev/v1/services?skip=50&take=50" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```curl curl -X GET "https://api.flightcontrol.dev/v1/services?type=web&projectId=cm2jl7psl0000718o04s31mz9" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```curl curl -X GET "https://api.flightcontrol.dev/v1/services?environmentType=preview" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```curl curl -X GET "https://api.flightcontrol.dev/v1/services?environmentType=standard" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Get Service Scaling Info Error Responses Source: https://www.flightcontrol.dev/docs/reference/http-api/services/get-scaling Examples of error responses for the get service scaling info endpoint, including 404 Not Found, 401 Unauthorized, and 403 Forbidden. ```json { "message": "Service not found", "errorCode": "FC:Request:Error:NOT_FOUND" } ``` ```json { "message": "Please use an API key for this request", "errorCode": "FC:Request:Error:UNAUTHORIZED" } ``` ```json { "message": "User doesn't have permission to access this service", "errorCode": "FC:Request:Error:FORBIDDEN" } ``` -------------------------------- ### Plan Nixpacks Build Steps Locally Source: https://www.flightcontrol.dev/docs/concepts/nixpacks Use the `nixpacks plan` command to view the steps Nixpacks will take to build a Docker image without actually building it. This is helpful for understanding the build process. ```bash nixpacks plan . ``` -------------------------------- ### Create Remix Jokes Application with CLI Source: https://www.flightcontrol.dev/docs/reference/examples/remix This command uses `npx` to create a new Remix application from an official template. It prompts the user for project name, language (TypeScript/JavaScript), and package installation. The output includes package installation progress and confirmation. ```bash npx create-remix@latest --template examples/_official-jokes ``` -------------------------------- ### Gunicorn Command for Flask App Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app This command starts the Flask application using the Gunicorn web server. It binds to all IP addresses on port 3000 and uses the `wsgi:app` configuration. ```bash gunicorn --bind 0.0.0.0:3000 wsgi:app ``` -------------------------------- ### Get Service Scaling Info (cURL) Source: https://www.flightcontrol.dev/docs/reference/http-api/services/get-scaling Example using cURL to retrieve scaling information for a given service ID. Requires an Authorization header with a Bearer token. ```shell curl -X GET https://api.flightcontrol.com/v1/services/cmds18v130000485zbcat00xy/scaling \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Configure Nixpacks Start Command Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/web Defines the command used to start the application after it has been built with Nixpacks. An intelligent default is provided based on detected language and framework. ```json { "startCommand": "blitz start" } ``` -------------------------------- ### Preview RDS With Web Example Configuration Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/preview-environment This example demonstrates how to configure a preview environment that includes an RDS database and a backend API. The backend API's DATABASE_URL is dynamically set using the connection string from the preview database service. ```json { "environments": [ // ...otherEnvironments, { // Preview environment (`pr: true`) "id": "preview", "name": "Preview", "region": "us-west-1", "source": { "pr": true, "filter": { "toBranches": ["main"] } }, "services": [ { "id": "preview-db", "name": "Database", "type": "rds", "engine": "postgres" // ...restOfConfig }, { "id": "backend-api", "envVariables": { "DATABASE_URL": { "fromService": { "id": "preview-db", "value": "dbConnectionString" } } } // ...restOfConfig } ] } ] } ``` -------------------------------- ### Get Job Execution Status (cURL) Source: https://www.flightcontrol.dev/docs/reference/http-api/scheduler/get-job-execution This example demonstrates how to use cURL to first trigger a job execution and then poll for its status using the Flightcontrol API. It requires an API key and the service and job identifiers. ```bash # First, trigger a job execution curl -X POST https://api.flightcontrol.dev/v1/services/{serviceId}/job/{jobGivenId}/execution \ -H "Authorization: Bearer: YOUR_API_KEY" \ -H "Content-Type: application/json" # Response: {"jobExecutionId": "cl2kx7acm00003f6gobvidq2i"} # Then, check the status curl https://api.flightcontrol.dev/v1/job-executions/cl2kx7acm00003f6gobvidq2i \ -H "Authorization: Bearer: YOUR_API_KEY" ``` -------------------------------- ### Start Command for Gatsby Server Source: https://www.flightcontrol.dev/docs/reference/examples/gatsby Command to start the Gatsby development server, listening on port 3000 and all network interfaces. ```bash gatsby serve --port 3000 -H 0.0.0.0 ``` -------------------------------- ### From Repository Build Configuration Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/network-server-private Configure 'From Repository' builds by providing containerImage details including registryId, repository, and tag. This allows using images directly from a specified container registry. The startCommand can override the default entrypoint. ```yaml buildType: "fromRepository" containerImage: registryId: "ecr-9l03731" repository: "node:18-slim" tag: "latest" startCommand: ["/bin/bash", "-c", "node index.js"] ``` -------------------------------- ### Get Service Scaling Info Success Response Source: https://www.flightcontrol.dev/docs/reference/http-api/services/get-scaling Example of a successful JSON response (200 OK) when retrieving service scaling information. It includes details about current, desired, running, and pending instances, as well as autoscaling configuration. ```json { "serviceId": "cmds18v130000485zbcat00xy", "currentInstances": 3, "desiredInstances": 3, "runningInstances": 3, "pendingInstances": 0, "autoscalingEnabled": true, "minInstances": 1, "maxInstances": 10 } ``` -------------------------------- ### AWS Account Response Example (JSON) Source: https://www.flightcontrol.dev/docs/reference/http-api/aws-accounts/get-aws-account This is an example of the JSON response received when successfully retrieving AWS account details from the Flightcontrol API. It includes the Flightcontrol internal ID, the connected AWS account ID, the account name, and its current connection status. ```json { "id": "cmadqj0k400000cjs6wwu2n5y", "connectedAwsAccountId": "123456789012", "name": "My AWS Account", "status": "CONNECTED" } ``` -------------------------------- ### Configure 'fromRepository' Build Type Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/web Specifies a container image directly from a container registry. Requires the registry ID, repository name, and optionally a tag. This allows using pre-built images from registries like ECR. The `startCommand` can override the default command in the specified image. ```json { "containerImage": { "registryId": "ecr-9l03731", "repository": "node:18-slim", "tag": "latest" }, "startCommand": ["/bin/bash", "-c", "npm start"] } ``` -------------------------------- ### Nixpacks Build Configuration Options Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/network-server-private Configure Nixpacks builds with options like basePath, installCommand, buildCommand, postBuildCommand, and startCommand. basePath specifies the application code directory, while the command options define dependency installation, build execution, post-build hooks, and application startup. ```yaml buildType: nixpacks basePath?: "./apps/frontend" installCommand: "./install.sh" buildCommand: "blitz build" postBuildCommand: "./postBuildCommand.sh" startCommand: "blitz start" ``` -------------------------------- ### Get AWS Account Status Source: https://www.flightcontrol.dev/docs/reference/http-api/projects/create-project Retrieve the connection status of an AWS account. This is useful to ensure the AWS account is ready before proceeding with project setup. ```APIDOC ## GET /v1/aws-accounts/{AWS_ACCOUNT_ID} ### Description Retrieves the connection status of a specified AWS account. ### Method GET ### Endpoint /v1/aws-accounts/{AWS_ACCOUNT_ID} ### Parameters #### Path Parameters - **AWS_ACCOUNT_ID** (string) - Required - The ID of the AWS account to check. #### Query Parameters None #### Request Body None ### Request Example ```bash curl --request GET \ --url https://api.flightcontrol.dev/v1/aws-accounts/${AWS_ACCOUNT_ID} \ --header 'Authorization: Bearer ${TOKEN}' ``` ### Response #### Success Response (200) - **status** (string) - The connection status of the AWS account (e.g., "CONNECTED"). #### Response Example ```json { "status": "CONNECTED" } ``` ``` -------------------------------- ### Create Python Virtual Environment Source: https://www.flightcontrol.dev/docs/getting-started/python/creating-flask-app These commands create a virtual environment named 'venv' for isolating Python project dependencies. The command varies based on the operating system (Linux/Mac vs. Windows). ```bash python3 -m venv venv ``` ```bash py -m venv venv ``` -------------------------------- ### Create Environment API Request Example Source: https://www.flightcontrol.dev/docs/reference/http-api/environments/create-environment Example of a POST request to create a new environment. This includes the endpoint URL, headers, and a sample request body with parameters like name, region, source, services, VPC, and environment variables. ```bash curl -X POST \ https://api.flightcontrol.dev/v1/projects/{projectId}/environments \ -H 'Authorization: Bearer [API key]' \ -H 'Content-Type: application/json' \ -d '{ "name": "production", "region": "us-east-1", "source": { "branch": "main", "trigger": "push" }, "services": [ { "id": "app-service", "name": "my-app", "type": "backend", "port": 8080 } ], "vpc": { "id": "vpc-1234567890abcdef0", "cidr": "10.0.0.0/24", "private": true }, "envVariables": { "DATABASE_URL": "postgres://user:password@host:port/dbName" } }' ``` -------------------------------- ### Dockerfile Build Configuration Options Source: https://www.flightcontrol.dev/docs/guides/flightcontrol/using-code/network-server-private Customize Dockerfile builds using dockerfilePath, dockerContext, startCommand, and injectEnvVariablesInDockerfile. dockerfilePath points to the Dockerfile, dockerContext defines the build context, startCommand overrides the Docker image's CMD, and injectEnvVariablesInDockerfile controls environment variable injection. ```yaml buildType: dockerfile dockerfilePath: "packages/web/Dockerfile" dockerContext: "packages/web" startCommand: ["/bin/bash", "-c", "node index.js"] injectEnvVariablesInDockerfile: false ```