Phase Console

repository·main·Indexed 21 days ago

https://github.com/phasehq/console

An open-source platform for securing and deploying application secrets across the development lifecycle. Phase provides a centralized dashboard (Phase Console) for secret management, RBAC, and automated syncing to platforms like GitHub, Vercel, AWS, Kubernetes, GitLab, and Nomad. It includes a CLI for local secret injection and official SDKs for Node.js, Python, and Golang.

Tokens
9.8K
Snippets
41
Records
49
Agent score
75%

What's inside phasehq-console

  1. Overview of Phase Platform

    main

    Phase is an open-source platform designed for engineering teams to secure and deploy application secrets from development to production. It provides a centralized dashboard (Phase Console) for managing secrets and environment variables, a CLI for local development and secret injection, and various integrations for automated secret syncing.

    Key capabilities include:

    • Secret Management: Manage secrets across environments, track version history, and view diffs.
    • Role-Based Access Control (RBAC): Fine-grained, cryptographic access control per application and environment.
    • Secret Syncing: Automatically sync secrets to platforms like GitHub, Vercel, AWS Secrets Manager, and Kubernetes via the Phase Secrets Operator.
    • Programmatic Access: Manage secrets via a REST API or language-specific SDKs (Node.js, Python, Golang).
  2. Regenerate GraphQL code from schema

    main

    If the backend GraphQL schema (schema.graphql) has been upgraded, you must regenerate the frontend GraphQL types and hooks to maintain compatibility. Navigate to the frontend directory and run the codegen command.

    cd frontend && yarn codegen
  3. Generate GraphQL schema for the frontend

    main

    The backend uses Graphene to provide a GraphQL API. To keep the frontend in sync, you must generate the GraphQL schema file.

    If running locally via Django management commands:

    ./manage.py graphql_schema --schema backend.schema.schema --out ../frontend/apollo/schema.graphql

    If running within a development Docker environment:

    docker compose -f dev-docker-compose.yml exec backend python manage.py graphql_schema --schema backend.schema.schema --out schema.graphql

    After generation, ensure the schema is overwritten in /frontend/apollo/schema.graphql. Note that you must also generate TypeScript types separately by following the instructions in frontend/README.md.

  4. Get started with Phase

    main

    To begin using Phase, you can choose between the managed Phase Cloud service or self-hosting the platform on your own infrastructure.

    Use Phase Cloud

    The fastest way to get started is to sign up via the Phase Console.

    Self-host Phase

    You can deploy the Phase Console on your own infrastructure using several supported methods:

    • Docker Compose
    • Kubernetes (via Helm chart)
    • AWS
    • AWS EKS (via Helm chart)
    • Google Cloud Platform (GCP)
    • Azure
    • DigitalOcean

    For detailed deployment instructions, refer to the Self-hosting Phase documentation.

  5. Run the Phase Console development server

    main

    To start the Phase Console frontend in development mode, use your preferred package manager to run the dev script. The application will be available at http://localhost:3000.

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
  6. Create dummy users for testing

    main

    To mock UI screens and workflows, you can generate fake users and assign them to an organization using the create_dummy_users management command.

    Prerequisites

    1. Install development dependencies in your virtual environment:
      pip install -r dev-requirements.txt
    2. Perform a manual signup and create an organization via the application.

    Execution Steps

    If using Docker, first find your backend container ID using docker ps, then shell into it:

    docker exec -it <container_id> /bin/sh

    Run the command to create users. It is recommended to use the --domain flag to make these users easily identifiable for future cleanup.

    python manage.py create_dummy_users --count 10 --org "OrgName" --domain "example.com"
  7. Configure Phase self-hosting via Docker Compose

    main

    Phase can be self-hosted using the provided docker-compose.yml configuration. The setup orchestrates several services including an Nginx reverse proxy, a Next.js frontend, a Python backend, a migration runner, a background worker, PostgreSQL, and Redis.

    To configure the environment, you must provide a .env file containing the following variables used by the services:

    # Example .env requirements based on docker-compose.yml
    HTTP_PROTOCOL=http
    HOST=localhost
    DATABASE_NAME=phase
    DATABASE_USER=phase
    DATABASE_PASSWORD=password
  8. Reference: create_dummy_users management command

    main

    The create_dummy_users command is used to populate the backend with fake user data for development and testing purposes.

    python manage.py create_dummy_users \
      --count <number> \
      --org <organization_name> \
      --domain <email_domain>
  9. Phase CLI Commands Reference

    main

    The Phase CLI allows you to manage secrets and environment variables from your terminal. Use phase --help to see all available commands.

    Authentication and Project Setup

    • auth: Authenticate with Phase.
    • init: Link your local project with a Phase app.
    • users whoami: See details of the current user.
    • users switch: Switch between Phase users, organizations, and hosts.
    • users logout: Logout from the CLI.

    Secret Management

    • secrets list: List all secrets.
    • secrets get: Retrieve a specific secret by its key.
    • secrets create: Create a new secret.
    • secrets update: Update an existing secret.
    • secrets delete: Delete a secret.
    • secrets import: Import secrets from a .env file.
    • secrets export: Export secrets in a .env format.

    Application Execution

    • run: Run a command and inject secrets as environment variables.
    • shell: Launch a sub-shell with secrets provided as environment variables (BETA).

    Utility

    • console: Open the Phase Console in your web browser.
    • docs: Open the Phase CLI documentation in your browser.
    • update: Update the Phase CLI to the latest version.
    # Example: List all secrets
    phase secrets list
    
    # Example: Run an application with injected secrets
    phase run npm start
    
    # Example: Import secrets from a local file
    phase secrets import .env