BlogsCompanyContactFAQsProductsServicesWhy Us
Brownsmith Dynamics

Services, products, company information, learning, and contact paths in one place.

HomeBlogsCompanyContactFAQsProductsServicesWhy Us

Services

AI ImplementationAI-Native SystemsWeb DevelopmentBusiness AutomationCustom SoftwareMCP DevelopmentLegacy ModernisationData and ReportingSEO, AEO and GEOPerformance MarketingTechnical Writing
  1. Home
  2. From Repository to Production
  3. Compose Environment Files and Secrets
  1. Home
  2. Courses
  3. Self Hosting Open Source Applications
  4. From Repository to Production
  5. Compose Environment Files and Secrets

Design, development, automation, SEO, and marketing systems for the AI age.

contact@brownsmithdynamics.com
RSS feed
BlogsCompanyContactFAQsProductsServicesWhy Us
Hostinger Partner affiliate marketing link

Affiliate link: Brownsmith Dynamics may receive a benefit if you purchase through this referral.

Sitemap

HomeProductsCoursesMCP DevelopmentServicesAI ImplementationAI-Native SystemsWeb DevelopmentBusiness AutomationCustom SoftwareLegacy ModernisationData and ReportingSEO, AEO and GEOPerformance MarketingTechnical WritingContact
Expand to See the Full SitemapCollapse the Full Sitemap

Core Pages

CompanyWhy UsAgent SkillsCase StudiesFAQsToolsQuizPrivacy PolicySubstack Publication

Founder Learning

Course BundleBuilding an AI-Native BusinessMVP Building for FoundersProduct and Interface DesignFrontend for FoundersBackend for FoundersDatabases for FoundersInfrastructure and DeploymentAI-Assisted Product BuildingTesting and Quality AssuranceSecurity, Ownership, and OperationsDesigning Work for AI AgentsSelf-Hosting Open-Source Applications

AI-Native Systems

AI-Native Business SystemsPublic AI DocumentationStructured Business Datallms.txt

Product Pages

Fonte UIPrivate Agent WorkspaceWeb Conversation EnginePrivate Model InfrastructureWorkflow Automation HubData Intelligence WorkbenchGrowth Intelligence PlatformWorkforce Intelligence SuiteContract & Compliance DeskIndustrial Operations PlatformHealthcare Operations WorkbenchLearning Operations PlatformSecurity Operations ConsoleProperty Intelligence SuiteCommerce Intelligence PlatformScreen Context AssistantPrompt Composer

Contact and Discovery

contact@brownsmithdynamics.comXML Sitemap

Core Pages

CompanyHomeWhy UsProductsCoursesAgent SkillsCase StudiesMCP DevelopmentFAQsToolsQuizPrivacy PolicySubstack Publication

Services

ServicesAI ImplementationAI-Native SystemsWeb DevelopmentBusiness AutomationCustom SoftwareMCP DevelopmentLegacy ModernisationData and ReportingSEO, AEO and GEOPerformance MarketingTechnical Writing

Founder Learning

Course BundleBuilding an AI-Native BusinessMVP Building for FoundersProduct and Interface DesignFrontend for FoundersBackend for FoundersDatabases for FoundersInfrastructure and DeploymentAI-Assisted Product BuildingTesting and Quality AssuranceSecurity, Ownership, and OperationsDesigning Work for AI AgentsSelf-Hosting Open-Source Applications

AI-Native Systems

AI-Native Business SystemsMCP DevelopmentPublic AI DocumentationStructured Business Datallms.txt

Product Pages

Fonte UIPrivate Agent WorkspaceWeb Conversation EnginePrivate Model InfrastructureWorkflow Automation HubData Intelligence WorkbenchGrowth Intelligence PlatformWorkforce Intelligence SuiteContract & Compliance DeskIndustrial Operations PlatformHealthcare Operations WorkbenchLearning Operations PlatformSecurity Operations ConsoleProperty Intelligence SuiteCommerce Intelligence PlatformScreen Context AssistantPrompt Composer

Contact and Discovery

Contactcontact@brownsmithdynamics.comXML Sitemap
Course Navigation
Self-Hosting Open-Source Applications
  1. 1.Self-Hosting Economics and Responsibility
  2. 2.Preparing a VPS, DNS, Ports, and TLS
  3. 3.Git and Repository Preparation
  4. 4.Building and Inspecting a Docker Image
  5. 5.Compose, Environment Files, and Secrets
  6. 6.Deploying with Coolify or Dokploy
  7. 7.OAuth and API Key Management
  8. 8.AI APIs and MCP Services
  9. 9.Private Access with Tailscale
  10. 10.Production Deployment and Recovery Capstone
Self-Hosting Open-Source Applications
  1. 1.Self-Hosting Economics and Responsibility
  2. 2.Preparing a VPS, DNS, Ports, and TLS
  3. 3.Git and Repository Preparation
  4. 4.Building and Inspecting a Docker Image
  5. 5.Compose, Environment Files, and Secrets
  6. 6.Deploying with Coolify or Dokploy
  7. 7.OAuth and API Key Management
  8. 8.AI APIs and MCP Services
  9. 9.Private Access with Tailscale
  10. 10.Production Deployment and Recovery Capstone
  1. Courses
  2. /
  3. Self-Hosting Open-Source Applications
  4. /
  5. From Repository to Production
  6. /
  7. Compose, Environment Files, and Secrets

Compose, Environment Files, and Secrets

Compose should define services, pinned images, private networks, volumes, health checks, and non-secret defaults. Real secrets belong outside Git and should be injected at runtime through the strongest mechanism the platform supports.

15 minute lessonUpdated July 30, 2026intermediate

What You Will Be Able to Decide

  • Explain the role of compose, environment files, and secrets in a self-hosted system.
  • Apply the procedure to a real open-source deployment.
  • Recognise unsafe defaults and verify the resulting control.
  • Record enough evidence for another operator to repeat or recover the work.

Most useful self-hosted applications are systems rather than single processes. An application, database, queue, and reverse proxy may have different lifecycles but still need one understandable deployment definition.

Docker Compose expresses those relationships in YAML. It can create private networks and named volumes, pass configuration, order startup dependencies, and define health checks.

An environment file is convenient, but convenience is not encryption. Its filesystem permissions, backup path, platform visibility, and Git exclusions still matter.

Technical term

Runtime secret

Sensitive data made available to a running service without baking it into the image or committing it to source control.

It is a key issued when a worker starts a shift, not a key photographed into the construction plans.

The Working Model

Compose interpolation can read values from a local `.env`, while a service-level `env_file` passes variables into the container. Those are different stages. Use `docker compose config` to inspect the resolved model, but avoid exposing its output when it includes secret values.

Put databases and supporting services on a private network. Use named volumes for durable data and document exactly what each volume contains. A volume is persistence, not a backup: deletion, corruption, or host loss can still remove it.

Where the deployment platform supports secret files or an external secret manager, prefer them for high-value credentials. Always restrict file permissions and rotate any credential that has entered Git history, logs, screenshots, or shell history.

Implementation Procedure

  1. Copy `.env.example` to `.env`, generate unique values, restrict access, and confirm `.env` is ignored by Git.
  2. Pin each service image and define a restart policy.
  3. Create a private application network and publish only the web entry point.
  4. Declare named volumes for databases, uploads, and other durable paths.
  5. Resolve and review the Compose model, start it, inspect health, then recreate it to test persistence.
services:
  app:
    image: ghcr.io/example/project:1.4.2
    restart: unless-stopped
    env_file: .env
    ports:
      - "127.0.0.1:8080:3000"
    volumes:
      - app-data:/data
    networks: [private]

volumes:
  app-data:

networks:
  private:
    internal: true

Knowledge Check

What is the difference between persistence and backup?

Controlled Practice and Fragile Practice

Controlled Practice

The deployment stays explainable, constrained, and recoverable.

  • Commit `.env.example`; ignore and protect `.env`.
  • Name every persistent volume and include it in the recovery plan.
  • Review the fully resolved Compose model before deployment.

Fragile Practice

Convenient shortcuts create hidden exposure or an unrecoverable dependency.

  • Assuming a named volume is automatically backed up.
  • Using the same default password in staging and production.
  • Publishing every service port to make connectivity easier.

Exercise

Apply the Boundary

Select the production-safe characteristics of a Compose deployment.

Select all answers that apply

Verification and Recovery Evidence

  • `docker compose ps` reports the intended services and health states.
  • The database cannot be reached directly from the public internet.
  • A fresh container can use the existing volume and a restore test can rebuild that volume from backup.

Knowledge Check

What should happen after a secret is committed to Git?

Warning Signs

  • The Compose file uses default credentials shown in upstream examples.
  • No one knows which volume contains uploads or the primary database.
  • Resolved configuration is pasted into public support channels.

Questions to Ask a Consultant

  • Which configuration is safe to commit and which values require rotation?
  • Can every named volume be mapped to a backup and restore procedure?
  • Which services genuinely need to communicate with each other?

Exercise

Founder Decision Note

Record the decision, its current constraint, recommended option, main reason, primary risk, and the condition that would make you revisit it.

Key takeaway

Key Takeaway

Compose turns architecture into a reviewable file. Use that visibility to constrain networks, declare persistence, and keep real secrets out of source history.

Apply This Decision to Your Product.

Understanding a technical concept is useful. Applying it still depends on your product, users, budget, data, and operating constraints.

Brownsmith Dynamics can review an MVP scope, technical proposal, architecture, deployment plan, AI-assisted workflow, or existing application.

For corrections, questions, and suggested improvements to this lesson, contact us directly.

Book a Technical Consultation Ask a Question or Suggest an Improvement
Previous LessonBuilding and Inspecting a Docker ImageNext Lesson Deploying with Coolify or Dokploy

Related Lessons

  • Building and Inspecting a Docker Image
  • Deploying with Coolify or Dokploy

On This Lesson

  1. Runtime Secret
  2. The Working Model
  3. Implementation Procedure
  4. Knowledge Check
  5. Controlled Practice and Fragile Practice
  6. Apply the Boundary
  7. Verification and Recovery Evidence
  8. Knowledge Check
  9. Warning Signs
  10. Questions to Ask
  11. Key Takeaway